* @throws IOException
*/
@Test
public void testExpirationGrantingWithoutBestEffort() throws IOException {
// we specify a xs:duration
Subscribe subscribe = new Subscribe();
ExpirationType exp = new ExpirationType();
exp.setValue(
DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
subscribe.setExpires(exp);
DeliveryType delivery = new DeliveryType();
subscribe.setDelivery(delivery);
subscribe.getDelivery().getContent().add(createDummyNotifyTo());
SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
Assert.assertTrue(
"Specification requires that EventSource return a xs:duration "
+ "expirationType if a xs:duration was requested by client",
DurationAndDateUtil.isDuration(resp.getGrantedExpires().getValue()));
// we specify a xs:dateTime
subscribe = new Subscribe();
exp = new ExpirationType();
XMLGregorianCalendar dateRequest =
(XMLGregorianCalendar)DurationAndDateUtil.parseDurationOrTimestamp("2138-06-26T12:23:12.000-01:00");
exp.setValue(DurationAndDateUtil.convertToXMLString(dateRequest));
subscribe.setExpires(exp);
delivery = new DeliveryType();
subscribe.setDelivery(delivery);
subscribe.getDelivery().getContent().add(createDummyNotifyTo());
resp = eventSourceClient.subscribeOp(subscribe);
Assert.assertTrue(
"Specification requires that EventSource return a "
+ "xs:dateTime expirationType if a xs:dateTime was requested by client",
DurationAndDateUtil.isXMLGregorianCalendar(resp.getGrantedExpires().getValue()));
XMLGregorianCalendar returned = DurationAndDateUtil.parseXMLGregorianCalendar(
resp.getGrantedExpires().getValue());
System.out.println("granted expiration: " + returned.normalize().toXMLFormat());
System.out.println("requested expiration: " + dateRequest.normalize().toXMLFormat());
Assert.assertTrue("Server should have returned exactly the same date as we requested",
returned.equals(dateRequest));
// we don't specify anything
subscribe = new Subscribe();
delivery = new DeliveryType();
subscribe.setDelivery(delivery);
subscribe.getDelivery().getContent().add(createDummyNotifyTo());
resp = eventSourceClient.subscribeOp(subscribe);
Assert.assertTrue(
"Specification requires that EventSource return a xs:duration "
+ "expirationType if no specific expirationType was requested by client",
DurationAndDateUtil.isDuration(resp.getGrantedExpires().getValue()));