Field statesField = ConnectionStateTracker.class.getDeclaredField("connectionStates");
statesField.setAccessible(true);
ConcurrentHashMap<ConnectionId, ConnectionState> states =
(ConcurrentHashMap<ConnectionId, ConnectionState>) statesField.get(stateTracker);
ConnectionState state = states.get(connection.getConnectionInfo().getConnectionId());
Collection<TransactionState> transactionStates = state.getTransactionStates();
connection.stop();
connection.close();
Assert.assertEquals("Transaction states not cleaned up", 0,transactionStates.size());