@Test
public void testReconnect() {

    new TestKit(actorSystem) {{
        final Props props =
                AmqpClientActor.propsForTests(connection, getRef(), getRef(),
                        (connection1, exceptionListener) -> mockConnection);
        final ActorRef amqpClientActor = actorSystem.actorOf(props);
        watch(amqpClientActor);
        amqpClientActor.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef());
        expectMsg(CONNECTED_SUCCESS);
        // introduce artificial code difference from RabbitMQClientActorTest.testReconnect
        for (int i = 0; i < 10; ++i) {
            amqpClientActor.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef());
            expectMsg(DISCONNECTED_SUCCESS);
            amqpClientActor.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef());
            expectMsg(CONNECTED_SUCCESS);
        }
        amqpClientActor.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef());
        expectMsg(DISCONNECTED_SUCCESS);
    }};
}