use of org.apache.activemq.broker.TransportConnectionState in project activemq-artemis by apache.
the class SimpleAuthenticationPluginTest method testSecurityContextClearedOnPurge.
public void testSecurityContextClearedOnPurge() throws Exception {
connection.close();
ActiveMQConnectionFactory tcpFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
ActiveMQConnection conn = (ActiveMQConnection) tcpFactory.createConnection("user", "password");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
final int numDests = broker.getRegionBroker().getDestinations().length;
for (int i = 0; i < 10; i++) {
MessageProducer p = sess.createProducer(new ActiveMQQueue("USERS.PURGE." + i));
p.close();
}
assertTrue("dests are purged", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
LOG.info("dests, orig: " + numDests + ", now: " + broker.getRegionBroker().getDestinations().length);
return (numDests + 1) == broker.getRegionBroker().getDestinations().length;
}
}));
// verify removed from connection security context
TransportConnection brokerConnection = broker.getTransportConnectors().get(0).getConnections().get(0);
TransportConnectionState transportConnectionState = brokerConnection.lookupConnectionState(conn.getConnectionInfo().getConnectionId());
assertEquals("no destinations", 0, transportConnectionState.getContext().getSecurityContext().getAuthorizedWriteDests().size());
}
Aggregations