use of org.apache.johnzon.core.JsonLongImpl in project activemq-artemis by apache.
the class ManagementWithPagingServerTest method testListMessagesAsJSON.
@Test
public void testListMessagesAsJSON() throws Exception {
SimpleString address = RandomUtil.randomSimpleString();
SimpleString queue = RandomUtil.randomSimpleString();
session1.createQueue(address, queue, null, true);
QueueControl queueControl = createManagementControl(address, queue);
int num = 1000;
SenderThread sender = new SenderThread(address, num, 0);
ReceiverThread receiver = new ReceiverThread(queue, num, 0);
// kick off sender
sender.start();
// wait for all messages sent
sender.join();
assertNull(sender.getError());
long count = queueControl.countMessages(null);
assertEquals(num, count);
String result = queueControl.listMessagesAsJSON(null);
JsonArray array = JsonUtil.readJsonArray(result);
List<Long> longs = new ArrayList<>();
for (JsonValue jsonValue : array) {
JsonValue val = ((JsonObject) jsonValue).get("messageID");
Long l = ((JsonLongImpl) val).longValue();
if (longs.contains(l)) {
System.out.println("ManagementWithPagingServerTest.testListMessagesAsJSON");
}
longs.add(l);
System.out.println("jsonValue = " + jsonValue);
}
assertEquals(num, array.size());
// kick off receiver
receiver.start();
receiver.join();
assertNull(receiver.getError());
result = queueControl.listMessagesAsJSON(null);
array = JsonUtil.readJsonArray(result);
assertEquals(0, array.size());
}
Aggregations