Search in sources :

Example 1 with CustomType

use of org.apache.cxf.wsn.types.CustomType in project cxf by apache.

the class WsnBrokerTest method testPublisherCustomType.

@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()));
    assertNotNull(message.getMessage().getAny());
    assertTrue(message.getMessage().getAny().getClass().getName(), message.getMessage().getAny() instanceof CustomType);
    subscription.unsubscribe();
    registration.destroy();
    publisher.stop();
    consumer.stop();
}
Also used : CustomType(org.apache.cxf.wsn.types.CustomType) Consumer(org.apache.cxf.wsn.client.Consumer) Registration(org.apache.cxf.wsn.client.Registration) Publisher(org.apache.cxf.wsn.client.Publisher) Subscription(org.apache.cxf.wsn.client.Subscription) NotificationMessageHolderType(org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType) Test(org.junit.Test)

Aggregations

Consumer (org.apache.cxf.wsn.client.Consumer)1 Publisher (org.apache.cxf.wsn.client.Publisher)1 Registration (org.apache.cxf.wsn.client.Registration)1 Subscription (org.apache.cxf.wsn.client.Subscription)1 CustomType (org.apache.cxf.wsn.types.CustomType)1 Test (org.junit.Test)1 NotificationMessageHolderType (org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)1