Search in sources :

Example 21 with ExpirationType

use of org.apache.cxf.ws.eventing.ExpirationType 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

ExpirationType (org.apache.cxf.ws.eventing.ExpirationType)21 Subscribe (org.apache.cxf.ws.eventing.Subscribe)17 DeliveryType (org.apache.cxf.ws.eventing.DeliveryType)16 SimpleEventingIntegrationTest (org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest)16 Test (org.junit.Test)16 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)9 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)9 ObjectFactory (org.apache.cxf.ws.eventing.ObjectFactory)9 Server (org.apache.cxf.endpoint.Server)8 NotificatorService (org.apache.cxf.ws.eventing.backend.notification.NotificatorService)8 Emitter (org.apache.cxf.ws.eventing.backend.notification.emitters.Emitter)8 EmitterImpl (org.apache.cxf.ws.eventing.backend.notification.emitters.EmitterImpl)8 FireEvent (org.apache.cxf.ws.eventing.integration.notificationapi.FireEvent)8 SubscribeResponse (org.apache.cxf.ws.eventing.SubscribeResponse)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)5 FilterType (org.apache.cxf.ws.eventing.FilterType)5 GetStatus (org.apache.cxf.ws.eventing.GetStatus)4 SubscriptionManagerEndpoint (org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint)4 GetStatusResponse (org.apache.cxf.ws.eventing.GetStatusResponse)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2