Search in sources :

Example 51 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class JMSConsumer6Test method testPassMessageListenerIntoCreateConsumer.

@Test
public void testPassMessageListenerIntoCreateConsumer() throws Exception {
    final AtomicInteger counter = new AtomicInteger(0);
    final CountDownLatch done = new CountDownLatch(1);
    // Receive a message with the JMS API
    connection.start();
    ActiveMQSession session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, destinationType);
    MessageConsumer consumer = session.createConsumer(destination, new MessageListener() {

        @Override
        public void onMessage(Message m) {
            counter.incrementAndGet();
            if (counter.get() == 4) {
                done.countDown();
            }
        }
    });
    assertNotNull(consumer);
    // Send the messages
    sendMessages(session, destination, 4);
    assertTrue(done.await(1000, TimeUnit.MILLISECONDS));
    Thread.sleep(200);
    // Make sure only 4 messages were delivered.
    assertEquals(4, counter.get());
}
Also used : ActiveMQMessageConsumer(org.apache.activemq.ActiveMQMessageConsumer) MessageConsumer(javax.jms.MessageConsumer) ActiveMQSession(org.apache.activemq.ActiveMQSession) TextMessage(javax.jms.TextMessage) Message(javax.jms.Message) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MessageListener(javax.jms.MessageListener) CountDownLatch(java.util.concurrent.CountDownLatch) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) BasicOpenWireTest(org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest) Test(org.junit.Test)

Example 52 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class LDAPAuthorizationMapTest method testComposite.

@Test
public void testComposite() {
    ActiveMQDestination q1 = new ActiveMQQueue("queue1,topic://topic1");
    Set<GroupPrincipal> aclsq1 = authMap.getWriteACLs(q1);
    assertEquals(0, aclsq1.size());
}
Also used : GroupPrincipal(org.apache.activemq.jaas.GroupPrincipal) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Test(org.junit.Test)

Example 53 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class LDAPAuthorizationMapTest method testGetAdminACLs.

/*
    * Test method for 'org.apache.activemq.security.LDAPAuthorizationMap.getAdminACLs(ActiveMQDestination)'
    */
@Test
public void testGetAdminACLs() {
    ActiveMQDestination q1 = new ActiveMQQueue("queue1");
    Set<GroupPrincipal> aclsq1 = authMap.getAdminACLs(q1);
    assertEquals(1, aclsq1.size());
    assertTrue(aclsq1.contains(new GroupPrincipal("role1")));
    ActiveMQDestination t1 = new ActiveMQTopic("topic1");
    Set<GroupPrincipal> aclst1 = authMap.getAdminACLs(t1);
    assertEquals(1, aclst1.size());
    assertTrue(aclst1.contains(new GroupPrincipal("role1")));
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) GroupPrincipal(org.apache.activemq.jaas.GroupPrincipal) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Test(org.junit.Test)

Example 54 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class LDAPAuthorizationMapTest method testAdvisory.

@Test
public void testAdvisory() {
    ActiveMQDestination dest = AdvisorySupport.getConnectionAdvisoryTopic();
    Set<GroupPrincipal> acls = authMap.getWriteACLs(dest);
    assertEquals(1, acls.size());
    assertTrue(acls.contains(new GroupPrincipal("role3")));
}
Also used : GroupPrincipal(org.apache.activemq.jaas.GroupPrincipal) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Test(org.junit.Test)

Example 55 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class LDAPAuthorizationMapTest method testGetReadACLs.

/*
    * Test method for 'org.apache.activemq.security.LDAPAuthorizationMap.getReadACLs(ActiveMQDestination)'
    */
@Test
public void testGetReadACLs() {
    ActiveMQDestination q1 = new ActiveMQQueue("queue1");
    Set<GroupPrincipal> aclsq1 = authMap.getReadACLs(q1);
    assertEquals(1, aclsq1.size());
    assertTrue(aclsq1.contains(new GroupPrincipal("role1")));
    ActiveMQDestination t1 = new ActiveMQTopic("topic1");
    Set<GroupPrincipal> aclst1 = authMap.getReadACLs(t1);
    assertEquals(1, aclst1.size());
    assertTrue(aclst1.contains(new GroupPrincipal("role2")));
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) GroupPrincipal(org.apache.activemq.jaas.GroupPrincipal) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Test(org.junit.Test)

Aggregations

ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)165 Session (javax.jms.Session)62 MessageConsumer (javax.jms.MessageConsumer)49 Message (org.apache.activemq.command.Message)46 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)45 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)44 SessionInfo (org.apache.activemq.command.SessionInfo)44 ProducerInfo (org.apache.activemq.command.ProducerInfo)42 Test (org.junit.Test)41 Message (javax.jms.Message)40 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)40 TextMessage (javax.jms.TextMessage)31 BasicOpenWireTest (org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest)24 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)22 MessageProducer (javax.jms.MessageProducer)18 XATransactionId (org.apache.activemq.command.XATransactionId)15 CountDownLatch (java.util.concurrent.CountDownLatch)14 ActiveMQMessageProducer (org.apache.activemq.ActiveMQMessageProducer)12 MessageAck (org.apache.activemq.command.MessageAck)12 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)11