Search in sources :

Example 81 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue 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 82 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue 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)

Example 83 with ActiveMQQueue

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

the class SecurityJMXTest method testBrowseExpiredMessages.

public void testBrowseExpiredMessages() throws Exception {
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
    JMXConnector connector = JMXConnectorFactory.connect(url, null);
    connector.connect();
    MBeanServerConnection connection = connector.getMBeanServerConnection();
    ObjectName name = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost," + "destinationType=Queue,destinationName=TEST.Q");
    QueueViewMBean queueMbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, QueueViewMBean.class, true);
    HashMap<String, String> headers = new HashMap<>();
    headers.put("timeToLive", Long.toString(2000));
    headers.put("JMSDeliveryMode", Integer.toString(DeliveryMode.PERSISTENT));
    queueMbean.sendTextMessage(headers, "test", "system", "manager");
    // allow message to expire on the queue
    TimeUnit.SECONDS.sleep(4);
    Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection("system", "manager");
    c.start();
    // browser consumer will force expiration check on addConsumer
    QueueBrowser browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("TEST.Q"));
    assertTrue("no message in the q", !browser.getEnumeration().hasMoreElements());
    // verify dlq got the message, no security exception as brokers context is now used
    browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("ActiveMQ.DLQ"));
    assertTrue("one message in the dlq", browser.getEnumeration().hasMoreElements());
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) HashMap(java.util.HashMap) JMXConnector(javax.management.remote.JMXConnector) QueueViewMBean(org.apache.activemq.broker.jmx.QueueViewMBean) Connection(javax.jms.Connection) MBeanServerConnection(javax.management.MBeanServerConnection) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) MBeanServerConnection(javax.management.MBeanServerConnection) QueueBrowser(javax.jms.QueueBrowser) ObjectName(javax.management.ObjectName)

Example 84 with ActiveMQQueue

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

the class SecurityTestSupport method initCombosForTestGuestSendFails.

/**
 * @see {@link CombinationTestSupport}
 */
public void initCombosForTestGuestSendFails() {
    addCombinationValues("userName", new Object[] { "guest" });
    addCombinationValues("password", new Object[] { "password" });
    addCombinationValues("destination", new Object[] { new ActiveMQQueue("GUESTS.BY_PASS,TEST"), new ActiveMQQueue("TEST"), new ActiveMQTopic("TEST"), new ActiveMQQueue("USERS.FOO"), new ActiveMQTopic("USERS.FOO") });
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue)

Example 85 with ActiveMQQueue

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

the class SecurityTestSupport method initCombosForTestUserReceiveFails.

/**
 * @see {@link CombinationTestSupport}
 */
public void initCombosForTestUserReceiveFails() {
    addCombinationValues("userName", new Object[] { "user" });
    addCombinationValues("password", new Object[] { "password" });
    addCombinationValues("destination", new Object[] { new ActiveMQQueue("USERS.BY_PASS, TEST"), new ActiveMQQueue("TEST"), new ActiveMQTopic("TEST"), new ActiveMQQueue("GUEST.BAR"), new ActiveMQTopic("GUEST.BAR") });
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue)

Aggregations

ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)239 Session (javax.jms.Session)81 MessageProducer (javax.jms.MessageProducer)78 MessageConsumer (javax.jms.MessageConsumer)76 TextMessage (javax.jms.TextMessage)73 Test (org.junit.Test)66 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)54 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)44 Message (javax.jms.Message)36 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)33 Connection (javax.jms.Connection)32 Destination (javax.jms.Destination)27 CountDownLatch (java.util.concurrent.CountDownLatch)20 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)18 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)18 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)18 SessionInfo (org.apache.activemq.command.SessionInfo)18 Message (org.apache.activemq.command.Message)17 BasicOpenWireTest (org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest)16 ProducerInfo (org.apache.activemq.command.ProducerInfo)16