public void testPublisher() throws Exception {
TestConsumer consumerCallback = new TestConsumer();
Consumer consumer = new Consumer(consumerCallback, "http://localhost:" + port2 + "/test/consumer");
Subscription subscription = notificationBroker.subscribe(consumer, "myTopic");
PublisherCallback publisherCallback = new PublisherCallback();
Publisher publisher = new Publisher(publisherCallback, "http://localhost:" + port2
+ "/test/publisher");
Registration registration = notificationBroker.registerPublisher(publisher, "myTopic");
synchronized (consumerCallback.notifications) {
notificationBroker.notify(publisher, "myTopic",
new JAXBElement<String>(new QName("urn:test:org", "foo"),
String.class, "bar"));
consumerCallback.notifications.wait(1000000);
}
assertEquals(1, consumerCallback.notifications.size());
NotificationMessageHolderType message = consumerCallback.notifications.get(0);
assertEquals(WSNHelper.getWSAAddress(subscription.getEpr()),
WSNHelper.getWSAAddress(message.getSubscriptionReference()));
assertEquals(WSNHelper.getWSAAddress(publisher.getEpr()),
WSNHelper.getWSAAddress(message.getProducerReference()));
subscription.unsubscribe();
registration.destroy();
publisher.stop();
consumer.stop();
}