use of org.apache.cxf.ws.eventing.DeliveryType in project cxf by apache.
the class SubscriptionManagementTest method renewWithDateTime.
/**
* Tests the Renew operation, while specifying an xs:dateTime in the renew request,
* eg. the subscriber requests to set the subscription expiration to a specific date/time.
*/
@Test
public void renewWithDateTime() throws IOException {
Subscribe subscribe = new Subscribe();
ExpirationType exp = new ExpirationType();
exp.setValue(DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp(// 5 minutes
"2018-10-21T14:52:46.826+02:00")));
subscribe.setExpires(exp);
DeliveryType delivery = new DeliveryType();
subscribe.setDelivery(delivery);
subscribe.getDelivery().getContent().add(createDummyNotifyTo());
SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
SubscriptionManagerEndpoint client = createSubscriptionManagerClient(resp.getSubscriptionManager().getReferenceParameters());
GetStatusResponse response = client.getStatusOp(new GetStatus());
String expirationBefore = response.getGrantedExpires().getValue();
System.out.println("EXPIRES before renew: " + expirationBefore);
Assert.assertTrue(expirationBefore.length() > 0);
Renew renewRequest = new Renew();
ExpirationType renewExp = new ExpirationType();
renewExp.setValue(DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp(// 10 minutes
"2056-10-21T14:54:46.826+02:00")));
renewRequest.setExpires(renewExp);
client.renewOp(renewRequest);
response = client.getStatusOp(new GetStatus());
String expirationAfter = response.getGrantedExpires().getValue();
System.out.println("EXPIRES after renew: " + expirationAfter);
Assert.assertFalse("Renew request should change the expiration time at least a bit", expirationAfter.equals(expirationBefore));
}
use of org.apache.cxf.ws.eventing.DeliveryType in project cxf by apache.
the class CreateSubscriptionServlet method createSubscribeMessage.
public Subscribe createSubscribeMessage(String targetURL, String filter, String expires) throws DatatypeConfigurationException {
Subscribe sub = new Subscribe();
// expires
if (expires != null) {
sub.setExpires(new ExpirationType());
sub.getExpires().setValue(expires);
}
// delivery
EndpointReferenceType eventSink = new EndpointReferenceType();
AttributedURIType eventSinkAddr = new AttributedURIType();
eventSinkAddr.setValue(targetURL);
eventSink.setAddress(eventSinkAddr);
sub.setDelivery(new DeliveryType());
sub.getDelivery().getContent().add(new ObjectFactory().createNotifyTo(eventSink));
// filter
if (filter != null && filter.length() > 0) {
sub.setFilter(new FilterType());
sub.getFilter().getContent().add(filter);
}
return sub;
}
Aggregations