andytaylor commented on code in PR #4183:
URL: https://github.com/apache/activemq-artemis/pull/4183#discussion_r995646632
##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java:
##########
@@ -441,6 +446,84 @@ public void testGetConsumerJSON() throws Exception {
session.deleteQueue(queue);
}
+ @Test
+ public void testGetConsumerWithMessagesJSON() throws Exception {
+ SimpleString address = RandomUtil.randomSimpleString();
+ SimpleString queue = RandomUtil.randomSimpleString();
+
+ session.createQueue(new
QueueConfiguration(queue).setAddress(address).setDurable(durable));
+
+ QueueControl queueControl = createManagementControl(address, queue);
+
+ ClientProducer producer = session.createProducer(address);
+
+ for (int i = 0; i < 10; i++) {
+ producer.send(session.createMessage(true));
+ }
+
+ Wait.assertEquals(0, () -> queueControl.getConsumerCount());
+
+ ClientConsumer consumer = session.createConsumer(queue);
+ Wait.assertEquals(1, () -> queueControl.getConsumerCount());
+
+ session.start();
+
+ ClientMessage clientMessage = null;
+
+ int size = 0;
+ for (int i = 0; i < 5; i++) {
+ clientMessage = consumer.receiveImmediate();
+ size += clientMessage.getEncodeSize();
+ }
+
+ JsonArray obj =
JsonUtil.readJsonArray(queueControl.listConsumersAsJSON());
+
+ assertEquals(1, obj.size());
+
+ Wait.assertEquals(5, () ->
JsonUtil.readJsonArray(queueControl.listConsumersAsJSON()).get(0).asJsonObject().getInt(ConsumerField.MESSAGES_IN_TRANSIT.getName()));
+
+ obj = JsonUtil.readJsonArray(queueControl.listConsumersAsJSON());
+
+ JsonObject jsonObject = obj.get(0).asJsonObject();
+
+ assertEquals(5,
jsonObject.getInt(ConsumerField.MESSAGES_IN_TRANSIT.getName()));
+
+ assertEquals(size,
jsonObject.getInt(ConsumerField.MESSAGES_IN_TRANSIT_SIZE.getName()));
+
+ assertEquals(5,
jsonObject.getInt(ConsumerField.MESSAGES_DELIVERED.getName()));
+
+ assertEquals(size,
jsonObject.getInt(ConsumerField.MESSAGES_DELIVERED_SIZE.getName()));
+
+ assertEquals(0,
jsonObject.getInt(ConsumerField.MESSAGES_ACKNOWLEDGED.getName()));
+
+ //we cant assume an elapseed time to only checking for its existence
+
assertNotNull(jsonObject.getInt(ConsumerField.LAST_DELIVERED_TIME.getName()));
+
+ assertEquals( 0,
jsonObject.getInt(ConsumerField.LAST_ACKNOWLEDGED_TIME.getName()));
Review Comment:
Ive changed the test to sanity check the times as you suggested
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]