diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java index 526a5ae2ac..34928bc692 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java @@ -1434,6 +1434,66 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertEquals(1, second.getJsonNumber("consumerCount").longValue()); } + @Test + public void testListQueues() throws Exception { + SimpleString queueName1 = new SimpleString("my_queue_one"); + SimpleString queueName2 = new SimpleString("my_queue_two"); + SimpleString queueName3 = new SimpleString("other_queue_three"); + + ActiveMQServerControl serverControl = createManagementControl(); + + server.addAddressInfo(new AddressInfo(queueName1, RoutingType.ANYCAST)); + server.createQueue(queueName1, RoutingType.ANYCAST, queueName1, null, false, false); + + server.addAddressInfo(new AddressInfo(queueName2, RoutingType.ANYCAST)); + server.createQueue(queueName2, RoutingType.ANYCAST, queueName2, null, false, false); + + server.addAddressInfo(new AddressInfo(queueName3, RoutingType.ANYCAST)); + server.createQueue(queueName3, RoutingType.ANYCAST, queueName3, null, false, false); + + //test with filter that matches 2 queues + HashMap optionMap = new HashMap<>(); + optionMap.put("field", "name"); + optionMap.put("operation", "CONTAINS"); + optionMap.put("value", "my_queue"); + JsonObject optionjsonObject = JsonUtil.toJsonObject(optionMap); + String optionString = optionjsonObject.toString(); + + String queuesAsJsonString = serverControl.listQueues(optionString, 1, 50); + + JsonObject queuesAsJsonObject = JsonUtil.readJsonObject(queuesAsJsonString); + JsonArray array = (JsonArray) queuesAsJsonObject.get("data"); + + Assert.assertEquals("number of queues returned from query", 2, array.size()); + Assert.assertTrue(array.getJsonObject(0).getString("name").contains("my_queue")); + Assert.assertTrue(array.getJsonObject(1).getString("name").contains("my_queue")); + + //test with an empty filter + optionMap = new HashMap<>(); + optionMap.put("field", ""); + optionMap.put("operation", ""); + optionMap.put("value", ""); + optionjsonObject = JsonUtil.toJsonObject(optionMap); + optionString = optionjsonObject.toString(); + + queuesAsJsonString = serverControl.listQueues(optionString, 1, 50); + + queuesAsJsonObject = JsonUtil.readJsonObject(queuesAsJsonString); + array = (JsonArray) queuesAsJsonObject.get("data"); + + // at least 3 queues or more + Assert.assertTrue("number of queues returned from query", 3 <= array.size()); + + //test with small page size + queuesAsJsonString = serverControl.listQueues(optionString, 1, 1); + + queuesAsJsonObject = JsonUtil.readJsonObject(queuesAsJsonString); + array = (JsonArray) queuesAsJsonObject.get("data"); + + Assert.assertEquals("number of queues returned from query", 1, array.size()); + + } + @Test public void testConnectorServiceManagement() throws Exception { ActiveMQServerControl managementControl = createManagementControl(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java index 9408fdb324..8910b1c0c9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java @@ -916,36 +916,35 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes public String listSessions(@Parameter(name = "Filter String") String filter, @Parameter(name = "Page Number") int page, @Parameter(name = "Page Size") int pageSize) throws Exception { - return null; + return (String) proxy.invokeOperation("listSessions", filter, page, pageSize); } @Override public String listConsumers(@Parameter(name = "Options") String options, @Parameter(name = "Page Number") int page, @Parameter(name = "Page Size") int pageSize) throws Exception { - return null; + return (String) proxy.invokeOperation("listConsumers", options, page, pageSize); } - @Override public String listProducers(@Parameter(name = "Options") String options, @Parameter(name = "Page Number") int page, @Parameter(name = "Page Size") int pageSize) throws Exception { - return null; + return (String) proxy.invokeOperation("listProducers", options, page, pageSize); } @Override public String listAddresses(@Parameter(name = "Options") String options, @Parameter(name = "Page Number") int page, @Parameter(name = "Page Size") int pageSize) throws Exception { - return null; + return (String) proxy.invokeOperation("listAddresses", options, page, pageSize); } @Override public String listQueues(@Parameter(name = "Options") String options, @Parameter(name = "Page Number") int page, @Parameter(name = "Page Size") int pageSize) throws Exception { - return null; + return (String) proxy.invokeOperation("listQueues", options, page, pageSize); } }; }