public void testTopicSubscriptions()
throws Exception
{
ComponentType type = KnownComponentTypes.JMSDestination.Topic.getType();
ManagementView managementView = getManagementView();
ManagedComponent topic = managementView.getComponent("testCreateTopic", type);
assertNotNull(topic);
// Subscribe to a topic and validate the subscription shows up in the list op
InitialContext ctx = super.getInitialContext();
Topic topicDest = (Topic) ctx.lookup("testCreateTopic");
TopicConnectionFactory tcf = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
TopicConnection tc = tcf.createTopicConnection();
tc.start();
TopicSession ts = tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer mc = ts.createConsumer(topicDest);
MessageProducer mp = ts.createProducer(topicDest);
Message helloMsg = ts.createTextMessage("Hello from testCreateTopic");
mp.send(helloMsg);
log.info("Producer sent: "+helloMsg);
Message response = mc.receive();
log.info("Consumer saw: "+response);
// Check some stats
log.info(topic.getProperties().keySet());
ManagedProperty NonDurableSubscriptionsCount = topic.getProperty("nonDurableSubscriptionsCount");
assertNotNull(NonDurableSubscriptionsCount);
log.info(NonDurableSubscriptionsCount);
SimpleValue NonDurableSubscriptionsCountMV = (SimpleValue) NonDurableSubscriptionsCount.getValue();
log.info(NonDurableSubscriptionsCountMV);
assertTrue(NonDurableSubscriptionsCountMV.compareTo(SimpleValueSupport.wrap(0)) > 0);
Set<ManagedOperation> ops = topic.getOperations();
log.info("Topic ops: "+ops);
Map<String, ManagedOperation> opsByName = new HashMap<String, ManagedOperation>();
for(ManagedOperation op : ops)
opsByName.put(op.getName(), op);
ManagedOperation listNonDurableSubscriptions = opsByName.get("listNonDurableSubscriptions");