@Test
public void testTestConnectionFailsOnTimeout() throws JMSException {

    final CountDownLatch latch = new CountDownLatch(1);
    try {
        new TestKit(actorSystem) {{
            when(mockConnection.createSession(anyInt()))
                    .thenAnswer(invocationOnMock -> waitForLatchAndReturn(latch, mockSession));
            final Props props =
                    AmqpClientActor.propsForTests(connection, getRef(), getRef(),
                            (ac, el) -> mockConnection);
            final ActorRef amqpClientActor = actorSystem.actorOf(props);
            amqpClientActor.tell(TestConnection.of(connection, DittoHeaders.empty()), getRef());
            amqpClientActor.tell(FSM.StateTimeout$.MODULE$, amqpClientActor);
            expectMsgClass(Status.Failure.class);
        }};
    } finally {
        latch.countDown();
    }
}