Search in sources :

Example 71 with ActiveMQQueue

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

the class AbstractCachedLDAPAuthorizationMapLegacyTest method testRenamePermission.

@Test
public void testRenamePermission() throws Exception {
    map.query();
    // Test for a permission rename
    connection.delete(new Dn("cn=Read,cn=TEST.FOO," + getQueueBaseDn()));
    Thread.sleep(2000);
    Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 0, failedACLs.size());
    failedACLs = map.getWriteACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 2, failedACLs.size());
    connection.rename(new Dn("cn=Write,cn=TEST.FOO," + getQueueBaseDn()), new Rdn("cn=Read"));
    Thread.sleep(2000);
    failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 2, failedACLs.size());
    failedACLs = map.getWriteACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 0, failedACLs.size());
}
Also used : ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Dn(org.apache.directory.shared.ldap.model.name.Dn) Rdn(org.apache.directory.shared.ldap.model.name.Rdn) Test(org.junit.Test)

Example 72 with ActiveMQQueue

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

the class AbstractCachedLDAPAuthorizationMapLegacyTest method testRestart.

public void testRestart(final boolean sync) throws Exception {
    if (sync) {
        // ldap connection can be slow to close
        map.setRefreshInterval(1000);
    }
    map.query();
    Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("FAILED"));
    assertEquals("set size: " + failedACLs, 0, failedACLs.size());
    failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 2, failedACLs.size());
    getLdapServer().stop();
    // wait for the context to be closed
    // as we can't rely on ldar server isStarted()
    Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            if (sync) {
                return !map.isContextAlive();
            } else {
                return map.context == null;
            }
        }
    });
    failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 2, failedACLs.size());
    getLdapServer().start();
    Thread.sleep(2000);
    connection = getLdapConnection();
    LdifReader reader = new LdifReader(getAddLdif());
    for (LdifEntry entry : reader) {
        connection.add(entry.getEntry());
    }
    reader.close();
    assertTrue("did not get expected size. ", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return map.getReadACLs(new ActiveMQQueue("FAILED")).size() == 2;
        }
    }));
}
Also used : LdifReader(org.apache.directory.shared.ldap.model.ldif.LdifReader) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Wait(org.apache.activemq.util.Wait) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) LdifEntry(org.apache.directory.shared.ldap.model.ldif.LdifEntry)

Example 73 with ActiveMQQueue

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

the class AbstractCachedLDAPAuthorizationMapLegacyTest method testQuery.

@Test
public void testQuery() throws Exception {
    map.query();
    Set<?> readACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + readACLs, 2, readACLs.size());
    assertTrue("Contains admin group", readACLs.contains(ADMINS));
    assertTrue("Contains users group", readACLs.contains(USERS));
    Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("FAILED"));
    assertEquals("set size: " + failedACLs, 0, failedACLs.size());
}
Also used : ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Test(org.junit.Test)

Example 74 with ActiveMQQueue

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

the class AbstractCachedLDAPAuthorizationMapLegacyTest method testChange.

@Test
public void testChange() throws Exception {
    map.query();
    // Change permission entry
    Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 2, failedACLs.size());
    Dn dn = new Dn("cn=read,cn=TEST.FOO," + getQueueBaseDn());
    ModifyRequest request = new ModifyRequestImpl();
    request.setName(dn);
    setupModifyRequest(request);
    connection.modify(request);
    Thread.sleep(2000);
    failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 1, failedACLs.size());
    // Change destination entry
    request = new ModifyRequestImpl();
    request.setName(new Dn("cn=TEST.FOO," + getQueueBaseDn()));
    request.add("description", "This is a description!  In fact, it is a very good description.");
    connection.modify(request);
    Thread.sleep(2000);
    failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 1, failedACLs.size());
}
Also used : ModifyRequestImpl(org.apache.directory.shared.ldap.model.message.ModifyRequestImpl) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Dn(org.apache.directory.shared.ldap.model.name.Dn) ModifyRequest(org.apache.directory.shared.ldap.model.message.ModifyRequest) Test(org.junit.Test)

Example 75 with ActiveMQQueue

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

the class AbstractCachedLDAPAuthorizationMapLegacyTest method testRenameDestination.

@Test
public void testRenameDestination() throws Exception {
    map.query();
    // Test for a destination rename
    Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 2, failedACLs.size());
    connection.rename(new Dn("cn=TEST.FOO," + getQueueBaseDn()), new Rdn("cn=TEST.BAR"));
    Thread.sleep(2000);
    failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
    assertEquals("set size: " + failedACLs, 0, failedACLs.size());
    failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.BAR"));
    assertEquals("set size: " + failedACLs, 2, failedACLs.size());
}
Also used : ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Dn(org.apache.directory.shared.ldap.model.name.Dn) Rdn(org.apache.directory.shared.ldap.model.name.Rdn) Test(org.junit.Test)

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