use of org.apache.activemq.artemis.api.core.management.AddressControl in project activemq-artemis by apache.
the class AddressControlTest method testGetRoles.
@Test
public void testGetRoles() throws Exception {
SimpleString address = RandomUtil.randomSimpleString();
SimpleString queue = RandomUtil.randomSimpleString();
Role role = new Role(RandomUtil.randomString(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean());
session.createQueue(address, queue, true);
AddressControl addressControl = createManagementControl(address);
Object[] roles = addressControl.getRoles();
Assert.assertEquals(0, roles.length);
Set<Role> newRoles = new HashSet<>();
newRoles.add(role);
server.getSecurityRepository().addMatch(address.toString(), newRoles);
roles = addressControl.getRoles();
Assert.assertEquals(1, roles.length);
Object[] r = (Object[]) roles[0];
Assert.assertEquals(role.getName(), r[0]);
Assert.assertEquals(CheckType.SEND.hasRole(role), r[1]);
Assert.assertEquals(CheckType.CONSUME.hasRole(role), r[2]);
Assert.assertEquals(CheckType.CREATE_DURABLE_QUEUE.hasRole(role), r[3]);
Assert.assertEquals(CheckType.DELETE_DURABLE_QUEUE.hasRole(role), r[4]);
Assert.assertEquals(CheckType.CREATE_NON_DURABLE_QUEUE.hasRole(role), r[5]);
Assert.assertEquals(CheckType.DELETE_NON_DURABLE_QUEUE.hasRole(role), r[6]);
Assert.assertEquals(CheckType.MANAGE.hasRole(role), r[7]);
session.deleteQueue(queue);
}
use of org.apache.activemq.artemis.api.core.management.AddressControl in project activemq-artemis by apache.
the class AddressControlTest method testGetAddress.
@Test
public void testGetAddress() throws Exception {
SimpleString address = RandomUtil.randomSimpleString();
SimpleString queue = RandomUtil.randomSimpleString();
session.createQueue(address, queue, false);
AddressControl addressControl = createManagementControl(address);
Assert.assertEquals(address.toString(), addressControl.getAddress());
session.deleteQueue(queue);
}
use of org.apache.activemq.artemis.api.core.management.AddressControl in project activemq-artemis by apache.
the class ActiveMQServerControlTest method testCreateAndDestroyQueue_4.
@Test
public void testCreateAndDestroyQueue_4() throws Exception {
SimpleString address = RandomUtil.randomSimpleString();
SimpleString name = RandomUtil.randomSimpleString();
boolean durable = RandomUtil.randomBoolean();
boolean purgeOnNoConsumers = RandomUtil.randomBoolean();
boolean autoCreateAddress = true;
int maxConsumers = RandomUtil.randomInt();
ActiveMQServerControl serverControl = createManagementControl();
checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
serverControl.createQueue(address.toString(), RoutingType.ANYCAST.toString(), name.toString(), null, durable, maxConsumers, purgeOnNoConsumers, autoCreateAddress);
checkResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
QueueControl queueControl = ManagementControlHelper.createQueueControl(address, name, RoutingType.ANYCAST, mbeanServer);
Assert.assertEquals(address.toString(), queueControl.getAddress());
Assert.assertEquals(name.toString(), queueControl.getName());
Assert.assertNull(queueControl.getFilter());
Assert.assertEquals(durable, queueControl.isDurable());
Assert.assertEquals(purgeOnNoConsumers, queueControl.isPurgeOnNoConsumers());
Assert.assertEquals(maxConsumers, queueControl.getMaxConsumers());
Assert.assertEquals(false, queueControl.isTemporary());
checkResource(ObjectNameBuilder.DEFAULT.getAddressObjectName(address));
AddressControl addressControl = ManagementControlHelper.createAddressControl(address, mbeanServer);
Assert.assertEquals(address.toString(), addressControl.getAddress());
serverControl.destroyQueue(name.toString(), true, true);
checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
checkNoResource(ObjectNameBuilder.DEFAULT.getAddressObjectName(address));
}
use of org.apache.activemq.artemis.api.core.management.AddressControl in project activemq-artemis by apache.
the class TopicControlClusterTest method testClusteredSubscriptionCount.
@Test
public void testClusteredSubscriptionCount() throws Exception {
final String topicName = "t1";
final SimpleString simpleTopicName = SimpleString.toSimpleString(topicName);
try (Connection conn1 = cf1.createConnection();
Connection conn2 = cf2.createConnection()) {
conn1.setClientID("someClient1");
conn2.setClientID("someClient2");
Topic topic1 = createTopic(topicName);
Topic topic2 = (Topic) context2.lookup("/topic/" + topicName);
Session session1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
session1.createDurableSubscriber(topic1, "sub1_1");
session1.createDurableSubscriber(topic1, "sub1_2");
Session session2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
session2.createDurableSubscriber(topic2, "sub2");
AddressControl topicControl1 = ManagementControlHelper.createAddressControl(simpleTopicName, mBeanServer1);
AddressControl topicControl2 = ManagementControlHelper.createAddressControl(simpleTopicName, mBeanServer2);
assertTrue("There should be 3 subscriptions on the topic, 2 local and 1 remote.", Wait.waitFor(() -> topicControl1.getQueueNames().length == 3, 2000));
assertTrue("There should be 3 subscriptions on the topic, 1 local and 2 remote.", Wait.waitFor(() -> topicControl2.getQueueNames().length == 3, 2000));
}
jmsServer1.destroyTopic("t1");
jmsServer2.destroyTopic("t1");
}
use of org.apache.activemq.artemis.api.core.management.AddressControl in project activemq-artemis by apache.
the class BridgeTestBase method checkNoSubscriptions.
protected void checkNoSubscriptions(final Topic topic, final int index) throws Exception {
ManagementService managementService = server0.getManagementService();
if (index == 1) {
managementService = server1.getManagementService();
}
AddressControl topicControl = (AddressControl) managementService.getResource(ResourceNames.ADDRESS + topic.getTopicName());
if (topicControl != null) {
Assert.assertEquals(0, topicControl.getQueueNames().length);
}
}
Aggregations