SimpleString address = RandomUtil.randomSimpleString();
SimpleString queue = RandomUtil.randomSimpleString();
session.createQueue(address, queue, null, false);
QueueControl queueControl = createManagementControl(address, queue);
ClientProducer producer = session.createProducer(address);
ClientMessage matchingMessage = session.createMessage(false);
matchingMessage.putLongProperty(key, matchingValue);
producer.send(matchingMessage);
ClientMessage unmatchingMessage = session.createMessage(false);
unmatchingMessage.putLongProperty(key, unmatchingValue);
producer.send(unmatchingMessage);
String jsonString = queueControl.listMessagesAsJSON(filter);
Assert.assertNotNull(jsonString);
JSONArray array = new JSONArray(jsonString);
Assert.assertEquals(1, array.length());
Assert.assertEquals(matchingValue, array.getJSONObject(0).get("key"));
ManagementTestBase.consumeMessages(2, session, queue);
jsonString = queueControl.listMessagesAsJSON(filter);
Assert.assertNotNull(jsonString);
array = new JSONArray(jsonString);
Assert.assertEquals(0, array.length());
session.deleteQueue(queue);