String consJsonStr = control.listConsumersAsJSON(connectionID);
assertNotNull(consJsonStr);
JMSConsumerInfo[] consumerInfos = JMSConsumerInfo.from(consJsonStr);
assertEquals(1, consumerInfos.length);
JMSConsumerInfo consumerInfo = consumerInfos[0];
assertNotNull(consumerInfo.getConsumerID());
assertEquals(connectionID, consumerInfo.getConnectionID());
assertEquals(queue.getQueueName(), consumerInfo.getDestinationName());
assertEquals("queue", consumerInfo.getDestinationType());
assertNull(consumerInfo.getFilter());
assertEquals(false, consumerInfo.isBrowseOnly());
assertEquals(false, consumerInfo.isDurable());
assertTrue(startTime <= consumerInfo.getCreationTime() && consumerInfo.getCreationTime() <= System.currentTimeMillis());
consumer.close();
consJsonStr = control.listConsumersAsJSON(connectionID);
assertNotNull(consJsonStr);
consumerInfos = JMSConsumerInfo.from(consJsonStr);
assertEquals(0, consumerInfos.length);
// create a queue browser
QueueBrowser browser = session.createBrowser(queue);
// the server resources are created when the browser starts enumerating
browser.getEnumeration();
consJsonStr = control.listConsumersAsJSON(connectionID);
assertNotNull(consJsonStr);
System.out.println(consJsonStr);
consumerInfos = JMSConsumerInfo.from(consJsonStr);
assertEquals(1, consumerInfos.length);
consumerInfo = consumerInfos[0];
assertNotNull(consumerInfo.getConsumerID());
assertEquals(connectionID, consumerInfo.getConnectionID());
assertEquals(queue.getQueueName(), consumerInfo.getDestinationName());
assertEquals("queue", consumerInfo.getDestinationType());
assertNull(consumerInfo.getFilter());
assertEquals(true, consumerInfo.isBrowseOnly());
assertEquals(false, consumerInfo.isDurable());
assertTrue(startTime <= consumerInfo.getCreationTime() && consumerInfo.getCreationTime() <= System.currentTimeMillis());
browser.close();
// create a regular consumer w/ filter on a temp topic
String filter = "color = 'red'";
consumer = session.createConsumer(temporaryTopic, filter);
consJsonStr = control.listConsumersAsJSON(connectionID);
assertNotNull(consJsonStr);
System.out.println(consJsonStr);
consumerInfos = JMSConsumerInfo.from(consJsonStr);
assertEquals(1, consumerInfos.length);
consumerInfo = consumerInfos[0];
assertNotNull(consumerInfo.getConsumerID());
assertEquals(connectionID, consumerInfo.getConnectionID());
assertEquals(temporaryTopic.getTopicName(), consumerInfo.getDestinationName());
assertEquals("temptopic", consumerInfo.getDestinationType());
assertEquals(filter, consumerInfo.getFilter());
assertEquals(false, consumerInfo.isBrowseOnly());
assertEquals(false, consumerInfo.isDurable());
assertTrue(startTime <= consumerInfo.getCreationTime() && consumerInfo.getCreationTime() <= System.currentTimeMillis());
consumer.close();
connection.close();
}