@Test
public void testPublisherCustomType() throws Exception {
notificationBroker.setExtraClasses(CustomType.class);
TestConsumer consumerCallback = new TestConsumer();
Consumer consumer = new Consumer(consumerCallback,
"http://localhost:" + port2 + "/test/consumer",
CustomType.class);
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 CustomType(1, 2));
consumerCallback.notifications.wait(1000000);
}
assertEquals(1, consumerCallback.notifications.size());
NotificationMessageHolderType message = consumerCallback.notifications.get(0);
assertEquals(WSNHelper.getInstance().getWSAAddress(subscription.getEpr()),
WSNHelper.getInstance().getWSAAddress(message.getSubscriptionReference()));
assertEquals(WSNHelper.getInstance().getWSAAddress(publisher.getEpr()),
WSNHelper.getInstance().getWSAAddress(message.getProducerReference()));
assertTrue(message.getMessage().getAny() instanceof CustomType);
subscription.unsubscribe();
registration.destroy();
publisher.stop();
consumer.stop();
}