use of org.apache.cxf.ws.eventing.Unsubscribe in project cxf by apache.
the class SubscriptionManagementTest method unsubscribeAndThenGetStatus.
/**
* Tries to create a subscription, then cancel it, then obtain its status.
* The last mentioned operation should fail.
*/
@Test
public void unsubscribeAndThenGetStatus() throws Exception {
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 subscribeResponse = eventSourceClient.subscribeOp(subscribe);
SubscriptionManagerEndpoint client = createSubscriptionManagerClient(subscribeResponse.getSubscriptionManager().getReferenceParameters());
UnsubscribeResponse unsubscribeResponse = client.unsubscribeOp(new Unsubscribe());
Assert.assertNotNull(unsubscribeResponse);
try {
client.getStatusOp(new GetStatus());
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
Assert.assertTrue(ex.getFault().getFaultCode().contains(UnknownSubscription.LOCAL_PART));
Assert.assertTrue(ex.getFault().getTextContent().contains(UnknownSubscription.REASON));
return;
}
Assert.fail("The subscription manager should have refused to send status of a cancelled subscription");
}
Aggregations