Search in sources :

Example 1 with Unsubscribe

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");
}
Also used : ExpirationType(org.apache.cxf.ws.eventing.ExpirationType) SubscriptionManagerEndpoint(org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint) Subscribe(org.apache.cxf.ws.eventing.Subscribe) SubscribeResponse(org.apache.cxf.ws.eventing.SubscribeResponse) UnsubscribeResponse(org.apache.cxf.ws.eventing.UnsubscribeResponse) Unsubscribe(org.apache.cxf.ws.eventing.Unsubscribe) DeliveryType(org.apache.cxf.ws.eventing.DeliveryType) GetStatus(org.apache.cxf.ws.eventing.GetStatus) Test(org.junit.Test) SimpleEventingIntegrationTest(org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest)

Aggregations

DeliveryType (org.apache.cxf.ws.eventing.DeliveryType)1 ExpirationType (org.apache.cxf.ws.eventing.ExpirationType)1 GetStatus (org.apache.cxf.ws.eventing.GetStatus)1 Subscribe (org.apache.cxf.ws.eventing.Subscribe)1 SubscribeResponse (org.apache.cxf.ws.eventing.SubscribeResponse)1 Unsubscribe (org.apache.cxf.ws.eventing.Unsubscribe)1 UnsubscribeResponse (org.apache.cxf.ws.eventing.UnsubscribeResponse)1 SimpleEventingIntegrationTest (org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest)1 SubscriptionManagerEndpoint (org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint)1 Test (org.junit.Test)1