Search in sources :

Example 11 with ObjectFactory

use of org.apache.cxf.ws.eventing.ObjectFactory in project cxf by apache.

the class SubscriptionEndTest method doTest.

@Test
public void doTest() throws IOException {
    NotificatorService service = createNotificatorService();
    service.start();
    Subscribe subscribe = new Subscribe();
    EndpointReferenceType eventSinkERT = new EndpointReferenceType();
    AttributedURIType eventSinkAddr = new AttributedURIType();
    String eventSinkURL = TestUtil.generateRandomURLWithLocalTransport();
    eventSinkAddr.setValue(eventSinkURL);
    eventSinkERT.setAddress(eventSinkAddr);
    subscribe.setDelivery(new DeliveryType());
    subscribe.getDelivery().getContent().add(new ObjectFactory().createNotifyTo(eventSinkERT));
    JAXBElement<String> idqn = new JAXBElement<String>(new QName("http://www.example.org", "MyReferenceParameter"), String.class, "380");
    ReferenceParametersType myParams = new ReferenceParametersType();
    myParams.getAny().add(idqn);
    eventSinkERT.setReferenceParameters(myParams);
    EndpointReferenceType endToERT = new EndpointReferenceType();
    AttributedURIType endToAddr = new AttributedURIType();
    String endToURL = TestUtil.generateRandomURLWithLocalTransport();
    endToAddr.setValue(endToURL);
    endToERT.setAddress(endToAddr);
    subscribe.setEndTo(endToERT);
    SubscribeResponse response = eventSourceClient.subscribeOp(subscribe);
    Element referenceParams = (Element) response.getSubscriptionManager().getReferenceParameters().getAny().get(0);
    Server endToEndpoint = createEndToEndpointWithReferenceParametersAssertion(endToURL, myParams);
    TestingEndToEndpointImpl.RECEIVED_ENDS.set(0);
    SingletonSubscriptionManagerContainer.getInstance().subscriptionEnd(UUID.fromString(referenceParams.getTextContent()), "Sorry, " + "but we don't like you anymore", SubscriptionEndStatus.SOURCE_CANCELLING);
    for (int i = 0; i < 10; i++) {
        if (TestingEndToEndpointImpl.RECEIVED_ENDS.get() == 1) {
            break;
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
    }
    endToEndpoint.stop();
    if (TestingEndToEndpointImpl.RECEIVED_ENDS.get() != 1) {
        Assert.fail("TestingEndToEndpointImpl should have received 1 subscription end notification but received " + TestingEndToEndpointImpl.RECEIVED_ENDS.get());
    }
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Server(org.apache.cxf.endpoint.Server) QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) NotificatorService(org.apache.cxf.ws.eventing.backend.notification.NotificatorService) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Subscribe(org.apache.cxf.ws.eventing.Subscribe) JAXBElement(javax.xml.bind.JAXBElement) SubscribeResponse(org.apache.cxf.ws.eventing.SubscribeResponse) ObjectFactory(org.apache.cxf.ws.eventing.ObjectFactory) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) DeliveryType(org.apache.cxf.ws.eventing.DeliveryType) Test(org.junit.Test) SimpleEventingIntegrationTest(org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest)

Aggregations

AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)11 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)11 ObjectFactory (org.apache.cxf.ws.eventing.ObjectFactory)11 DeliveryType (org.apache.cxf.ws.eventing.DeliveryType)10 Subscribe (org.apache.cxf.ws.eventing.Subscribe)10 Server (org.apache.cxf.endpoint.Server)9 ExpirationType (org.apache.cxf.ws.eventing.ExpirationType)9 NotificatorService (org.apache.cxf.ws.eventing.backend.notification.NotificatorService)9 SimpleEventingIntegrationTest (org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest)9 Test (org.junit.Test)9 Emitter (org.apache.cxf.ws.eventing.backend.notification.emitters.Emitter)8 EmitterImpl (org.apache.cxf.ws.eventing.backend.notification.emitters.EmitterImpl)8 FireEvent (org.apache.cxf.ws.eventing.integration.notificationapi.FireEvent)8 FilterType (org.apache.cxf.ws.eventing.FilterType)4 JAXBElement (javax.xml.bind.JAXBElement)2 QName (javax.xml.namespace.QName)2 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)2 FormatType (org.apache.cxf.ws.eventing.FormatType)1 SubscribeResponse (org.apache.cxf.ws.eventing.SubscribeResponse)1 EarthquakeEvent (org.apache.cxf.ws.eventing.integration.notificationapi.EarthquakeEvent)1