func newFakeClient(proto, addr string) *fakeclient.FakeClient {
	c := fakeclient.FakeClient{}
	c.SchemeReturns(proto)
	c.AddressReturns(addr)
	return &c
}
	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	"github.com/cloudfoundry/dropsonde/signature"
	"github.com/cloudfoundry/gosteno"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var sharedSecret = []byte("secret")

var _ = Describe("DopplerForwarder", func() {
	var (
		sender     *fake.FakeMetricSender
		clientPool *fakes.FakeClientPool
		client     *fakeclient.FakeClient
		logger     *gosteno.Logger
		forwarder  *dopplerforwarder.DopplerForwarder
		envelope   *events.Envelope
		doneChan   chan struct{}
		bufferSize uint
	)

	BeforeEach(func() {
		sender = fake.NewFakeMetricSender()
		metrics.Initialize(sender, metricbatcher.New(sender, time.Millisecond*10))

		client = &fakeclient.FakeClient{}
		clientPool = &fakes.FakeClientPool{}
		clientPool.RandomClientReturns(client, nil)

		logger = loggertesthelper.Logger()
		loggertesthelper.TestLoggerSink.Clear()
						clientFactory.newClient = func(string) (clientpool.Client, error) {
							return nil, errors.New("boom")
						}
					})

					It("does not include the client", func() {
						pool.SetLegacy(allLegacy, nil)
						Expect(pool.Clients()).To(BeEmpty())
						Expect(loggertesthelper.TestLoggerSink.LogContents()).To(ContainSubstring("Invalid url"))
					})
				})
			})
		})

		Context("when a server no longer exists", func() {
			var fakeClient *fakeclient.FakeClient

			BeforeEach(func() {
				fakeClient = newFakeClient("udp", "host:port")
				clientFactory.newClient = func(string) (clientpool.Client, error) {
					return fakeClient, nil
				}
			})

			It("the client is stopped", func() {
				s := map[string]string{
					"a": "udp://host:port",
				}

				pool.Set(s, nil)
				Expect(fakeClient.CloseCallCount()).To(Equal(0))
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	"github.com/cloudfoundry/dropsonde/signature"
	"github.com/cloudfoundry/gosteno"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var sharedSecret = []byte("secret")

var _ = Describe("DopplerForwarder", func() {
	var (
		sender     *fake.FakeMetricSender
		clientPool *fakes.FakeClientPool
		client     *fakeclient.FakeClient
		logger     *gosteno.Logger
		forwarder  *dopplerforwarder.DopplerForwarder
		envelope   *events.Envelope
	)

	BeforeEach(func() {
		sender = fake.NewFakeMetricSender()
		metrics.Initialize(sender, metricbatcher.New(sender, time.Millisecond*10))

		client = &fakeclient.FakeClient{}
		clientPool = &fakes.FakeClientPool{}
		clientPool.RandomClientReturns(client, nil)

		logger = loggertesthelper.Logger()
		loggertesthelper.TestLoggerSink.Clear()