int consumerPort = TestUtilServer.getAvailablePort();
String brokerEpr = "http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/EventingService";
WseMsgBrokerClient topicOnlyReceiverApi = new WseMsgBrokerClient();
topicOnlyReceiverApi.init(brokerEpr);
NotificationReciever topicOnlyMsgReceiver = new NotificationReciever("Topic Only");
String[] topicConsumerEPRs = topicOnlyReceiverApi.startConsumerService(consumerPort, topicOnlyMsgReceiver);
assertTrue("invalid consumer eprs returned", topicConsumerEPRs.length > 0);
String topicOnlySubId = topicOnlyReceiverApi.subscribe(topicConsumerEPRs[0], topic, null);
System.out.println("Topic only subscription ID: " + topicOnlySubId);
WseMsgBrokerClient xpathAndTopicReceiverApi = new WseMsgBrokerClient();
xpathAndTopicReceiverApi.init(brokerEpr);
NotificationReciever topicAndXpathMsgReceiver = new NotificationReciever("Topic And Xpath");
String[] topicAndXpathConsumerEPRs = xpathAndTopicReceiverApi.startConsumerService(consumerPort + 1,
topicAndXpathMsgReceiver);
assertTrue("invalid consumer eprs returned", topicAndXpathConsumerEPRs.length > 0);
String topicAndXpathSubId = xpathAndTopicReceiverApi.subscribe(topicAndXpathConsumerEPRs[0], topic,
xpathExpression);
System.out.println("Xpath and Topic subscription ID: " + topicAndXpathSubId);
WseMsgBrokerClient senderApi = new WseMsgBrokerClient();
senderApi.init(brokerEpr);
try {
senderApi.publish(topic, AXIOMUtil.stringToOM(matchingMsg));
senderApi.publish(topic, AXIOMUtil.stringToOM(unmatchingMsg));
Thread.sleep(5000);
assertTrue("topic only reciever should get all messages" + topicOnlyMsgReceiver.getMsgQueue().size(),
topicOnlyMsgReceiver.getMsgQueue().size() == 2);