public void testPublisherOnDemand() throws Exception {
TestConsumer consumerCallback = new TestConsumer();
Consumer consumer = new Consumer(consumerCallback, "http://localhost:" + port2 + "/test/consumer");
PublisherCallback publisherCallback = new PublisherCallback();
Publisher publisher = new Publisher(publisherCallback, "http://localhost:"
+ port2 + "/test/publisher");
Registration registration = notificationBroker.registerPublisher(publisher,
Arrays.asList("myTopic1",
"myTopic2"), true);
Subscription subscription = notificationBroker.subscribe(consumer, "myTopic1");
assertTrue(publisherCallback.subscribed.await(5, TimeUnit.SECONDS));
synchronized (consumerCallback.notifications) {
notificationBroker.notify(publisher, "myTopic1",
new JAXBElement<String>(new QName("urn:test:org", "foo"),
String.class, "bar"));
consumerCallback.notifications.wait(1000000);
}
subscription.unsubscribe();
assertTrue(publisherCallback.unsubscribed.await(5, TimeUnit.SECONDS));
registration.destroy();
publisher.stop();
consumer.stop();
}