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());
}
}
Aggregations