Search in sources :

Example 16 with NotificationMessageHolderType

use of org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType in project cxf by apache.

the class WsnBrokerTest method testNullPublisherReference.

@Test
public void testNullPublisherReference() throws Exception {
    TestConsumer consumerCallback = new TestConsumer();
    Consumer consumer = new Consumer(consumerCallback, "http://localhost:" + port2 + "/test/consumer");
    Subscription subscription = notificationBroker.subscribe(consumer, "myTopicNullEPR");
    Publisher publisher = new Publisher(null, null);
    Registration registration = notificationBroker.registerPublisher(publisher, "myTopicNullEPR", false);
    synchronized (consumerCallback.notifications) {
        notificationBroker.notify(publisher, "myTopicNullEPR", 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.getInstance().getWSAAddress(subscription.getEpr()), WSNHelper.getInstance().getWSAAddress(message.getSubscriptionReference()));
    subscription.unsubscribe();
    registration.destroy();
    publisher.stop();
    consumer.stop();
}
Also used : Consumer(org.apache.cxf.wsn.client.Consumer) Registration(org.apache.cxf.wsn.client.Registration) QName(javax.xml.namespace.QName) 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)

Example 17 with NotificationMessageHolderType

use of org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType in project cxf by apache.

the class WsnBrokerTest method testPullPointWithQueueName.

@Test
public void testPullPointWithQueueName() throws Exception {
    PullPoint pullPoint = createPullPoint.create("testQueue");
    Subscription subscription = notificationBroker.subscribe(pullPoint, "myTopic");
    notificationBroker.notify("myTopic", new JAXBElement<String>(new QName("urn:test:org", "foo"), String.class, "bar"));
    boolean received = false;
    for (int i = 0; i < 50; i++) {
        List<NotificationMessageHolderType> messages = pullPoint.getMessages(10);
        if (!messages.isEmpty()) {
            received = true;
            break;
        }
        Thread.sleep(100);
    }
    assertTrue(received);
    subscription.unsubscribe();
    pullPoint.destroy();
}
Also used : QName(javax.xml.namespace.QName) JaxwsCreatePullPoint(org.apache.cxf.wsn.services.JaxwsCreatePullPoint) PullPoint(org.apache.cxf.wsn.client.PullPoint) CreatePullPoint(org.apache.cxf.wsn.client.CreatePullPoint) Subscription(org.apache.cxf.wsn.client.Subscription) NotificationMessageHolderType(org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType) JaxwsCreatePullPoint(org.apache.cxf.wsn.services.JaxwsCreatePullPoint) PullPoint(org.apache.cxf.wsn.client.PullPoint) CreatePullPoint(org.apache.cxf.wsn.client.CreatePullPoint) Test(org.junit.Test)

Aggregations

NotificationMessageHolderType (org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)14 Subscription (org.apache.cxf.wsn.client.Subscription)8 QName (javax.xml.namespace.QName)7 Test (org.junit.Test)7 JAXBException (javax.xml.bind.JAXBException)6 Consumer (org.apache.cxf.wsn.client.Consumer)6 Notify (org.oasis_open.docs.wsn.b_2.Notify)5 JMSException (javax.jms.JMSException)4 Message (javax.jms.Message)3 TextMessage (javax.jms.TextMessage)3 Publisher (org.apache.cxf.wsn.client.Publisher)3 Registration (org.apache.cxf.wsn.client.Registration)3 Element (org.w3c.dom.Element)3 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 CreatePullPoint (org.apache.cxf.wsn.client.CreatePullPoint)2 PullPoint (org.apache.cxf.wsn.client.PullPoint)2 JaxwsCreatePullPoint (org.apache.cxf.wsn.services.JaxwsCreatePullPoint)2 GetMessagesResponse (org.oasis_open.docs.wsn.b_2.GetMessagesResponse)2