use of org.apache.cxf.ws.eventing.FormatType in project cxf by apache.
the class NotificationTest method basicReceptionOfWrappedEvents.
@Test
public void basicReceptionOfWrappedEvents() throws IOException {
NotificatorService service = createNotificatorService();
Subscribe subscribe = new Subscribe();
ExpirationType exp = new ExpirationType();
exp.setValue(DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
subscribe.setExpires(exp);
EndpointReferenceType eventSinkERT = new EndpointReferenceType();
AttributedURIType eventSinkAddr = new AttributedURIType();
String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
eventSinkAddr.setValue(url);
eventSinkERT.setAddress(eventSinkAddr);
subscribe.setDelivery(new DeliveryType());
subscribe.getDelivery().getContent().add(new ObjectFactory().createNotifyTo(eventSinkERT));
FormatType formatType = new FormatType();
formatType.setName(EventingConstants.DELIVERY_FORMAT_WRAPPED);
subscribe.setFormat(formatType);
eventSourceClient.subscribeOp(subscribe);
eventSourceClient.subscribeOp(subscribe);
eventSourceClient.subscribeOp(subscribe);
Server eventSinkServer = createWrappedEventSink(url);
TestingWrappedEventSinkImpl.RECEIVED_FIRES.set(0);
service.start();
Emitter emitter = new EmitterImpl(service);
emitter.dispatch(new FireEvent("Canada", 8));
for (int i = 0; i < 10; i++) {
if (TestingWrappedEventSinkImpl.RECEIVED_FIRES.get() == 3) {
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
eventSinkServer.stop();
if (TestingWrappedEventSinkImpl.RECEIVED_FIRES.get() != 3) {
Assert.fail("TestingWrappedEventSinkImpl should have received 3 events but received " + TestingWrappedEventSinkImpl.RECEIVED_FIRES.get());
}
}
Aggregations