Search in sources :

Example 1 with TransportConnectionState

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());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnection(org.apache.activemq.broker.TransportConnection) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) TransportConnectionState(org.apache.activemq.broker.TransportConnectionState) MessageProducer(javax.jms.MessageProducer) Session(javax.jms.Session)

Aggregations

MessageProducer (javax.jms.MessageProducer)1 Session (javax.jms.Session)1 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)1 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1 TransportConnection (org.apache.activemq.broker.TransportConnection)1 TransportConnectionState (org.apache.activemq.broker.TransportConnectionState)1 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)1