@Test
public void testResetsAfterReconnect() throws Exception
{

    RecordingListener recordingListener = new RecordingListener();
    TestRetryPolicy retryPolicy = new TestRetryPolicy();
    CircuitBreakingConnectionStateListener listener = new CircuitBreakingConnectionStateListener(dummyClient, recordingListener, retryPolicy, service);
    synchronized(listener)  // don't let retry policy run while we're pushing state changes
    {
        listener.stateChanged(dummyClient, ConnectionState.LOST);
        listener.stateChanged(dummyClient, ConnectionState.LOST);   // second LOST ignored
    }
    Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.LOST);
    Assert.assertTrue(recordingListener.stateChanges.isEmpty());
    listener.stateChanged(dummyClient, ConnectionState.RECONNECTED);   // causes circuit to close on next retry
    Assert.assertEquals(timing.takeFromQueue(recordingListener.stateChanges), ConnectionState.RECONNECTED);
}