func prettyPrint(mts []plugin.PluginMetricType) error {
	var out bytes.Buffer
	mtsb, _, _ := plugin.MarshalPluginMetricTypes(plugin.SnapJSONContentType, mts)
	if err := json.Indent(&out, mtsb, "", "  "); err != nil {
		return err
	}
	fmt.Println(out.String())
	return nil
}
// integration test
func TestRmqIntegration(t *testing.T) {
	mt := plugin.PluginMetricType{
		Namespace_:          []string{"foo", "bar"},
		LastAdvertisedTime_: time.Now(),
		Version_:            1,
		Data_:               1,
	}
	data, _, err := plugin.MarshalPluginMetricTypes(plugin.SnapGOBContentType, []plugin.PluginMetricType{mt})
	Convey("Metric should encode successfully", t, func() {
		Convey("So err should be nil", func() {
			So(err, ShouldBeNil)
		})
	})
	rmqPub := NewRmqPublisher()
	cp, _ := rmqPub.GetConfigPolicy()
	config := map[string]ctypes.ConfigValue{
		"address":       ctypes.ConfigValueStr{Value: "127.0.0.1:5672"},
		"exchange_name": ctypes.ConfigValueStr{Value: "snap"},
		"routing_key":   ctypes.ConfigValueStr{Value: "metrics"},
		"exchange_type": ctypes.ConfigValueStr{Value: "fanout"},
	}
	cfg, _ := cp.Get([]string{""}).Process(config)

	cKill := make(chan struct{})
	cMetrics, errc := connectToAmqp(cKill)
	err = rmqPub.Publish(plugin.SnapGOBContentType, data, *cfg)
	Convey("Publish should successfully publish metric to RabbitMQ server", t, func() {
		Convey("Publish data to RabbitMQ should not error", func() {
			So(err, ShouldBeNil)
		})
		Convey("We should be able to retrieve metric from RabbitMQ Server and validate", func() {
			Convey("Connecting to RabbitMQ server should not error", func() {
				So(errc, ShouldBeNil)
			})
			Convey("Validate metric", func() {
				if err == nil {
					select {
					case metric := <-cMetrics:
						var metrix []plugin.PluginMetricType
						err := json.Unmarshal(metric, &metrix)
						So(err, ShouldBeNil)
						So(metrix[0].Version(), ShouldEqual, mt.Version_)
						cKill <- struct{}{}
					case <-time.After(time.Second * 10):
						t.Fatal("Timeout when waiting for AMQP message")
					}

				}
			})
		})

	})
}