Search in sources :

Example 1 with RandomUtil.randomString

use of org.apache.activemq.artemis.tests.util.RandomUtil.randomString in project activemq-artemis by apache.

the class AddressControlTest method testGetRolesAsJSON.

@Test
public void testGetRolesAsJSON() 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);
    String jsonString = addressControl.getRolesAsJSON();
    Assert.assertNotNull(jsonString);
    RoleInfo[] roles = RoleInfo.from(jsonString);
    Assert.assertEquals(0, roles.length);
    Set<Role> newRoles = new HashSet<>();
    newRoles.add(role);
    server.getSecurityRepository().addMatch(address.toString(), newRoles);
    jsonString = addressControl.getRolesAsJSON();
    Assert.assertNotNull(jsonString);
    roles = RoleInfo.from(jsonString);
    Assert.assertEquals(1, roles.length);
    RoleInfo r = roles[0];
    Assert.assertEquals(role.getName(), roles[0].getName());
    Assert.assertEquals(role.isSend(), r.isSend());
    Assert.assertEquals(role.isConsume(), r.isConsume());
    Assert.assertEquals(role.isCreateDurableQueue(), r.isCreateDurableQueue());
    Assert.assertEquals(role.isDeleteDurableQueue(), r.isDeleteDurableQueue());
    Assert.assertEquals(role.isCreateNonDurableQueue(), r.isCreateNonDurableQueue());
    Assert.assertEquals(role.isDeleteNonDurableQueue(), r.isDeleteNonDurableQueue());
    Assert.assertEquals(role.isManage(), r.isManage());
    session.deleteQueue(queue);
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) AddressControl(org.apache.activemq.artemis.api.core.management.AddressControl) RoleInfo(org.apache.activemq.artemis.api.core.management.RoleInfo) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) RandomUtil.randomString(org.apache.activemq.artemis.tests.util.RandomUtil.randomString) JsonString(javax.json.JsonString) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with RandomUtil.randomString

use of org.apache.activemq.artemis.tests.util.RandomUtil.randomString in project activemq-artemis by apache.

the class AddressControlTest method testGetBindingNames.

@Test
public void testGetBindingNames() throws Exception {
    SimpleString address = RandomUtil.randomSimpleString();
    SimpleString queue = RandomUtil.randomSimpleString();
    String divertName = RandomUtil.randomString();
    session.createQueue(address, queue, false);
    AddressControl addressControl = createManagementControl(address);
    String[] bindingNames = addressControl.getBindingNames();
    assertEquals(1, bindingNames.length);
    assertEquals(queue.toString(), bindingNames[0]);
    server.getActiveMQServerControl().createDivert(divertName, randomString(), address.toString(), RandomUtil.randomString(), false, null, null);
    bindingNames = addressControl.getBindingNames();
    Assert.assertEquals(2, bindingNames.length);
    session.deleteQueue(queue);
    bindingNames = addressControl.getBindingNames();
    assertEquals(1, bindingNames.length);
    assertEquals(divertName.toString(), bindingNames[0]);
}
Also used : AddressControl(org.apache.activemq.artemis.api.core.management.AddressControl) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) RandomUtil.randomString(org.apache.activemq.artemis.tests.util.RandomUtil.randomString) JsonString(javax.json.JsonString) Test(org.junit.Test)

Aggregations

JsonString (javax.json.JsonString)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 AddressControl (org.apache.activemq.artemis.api.core.management.AddressControl)2 RandomUtil.randomString (org.apache.activemq.artemis.tests.util.RandomUtil.randomString)2 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 RoleInfo (org.apache.activemq.artemis.api.core.management.RoleInfo)1 Role (org.apache.activemq.artemis.core.security.Role)1