Search in sources :

Example 16 with DeliveryType

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));
}
Also used : GetStatusResponse(org.apache.cxf.ws.eventing.GetStatusResponse) 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) Renew(org.apache.cxf.ws.eventing.Renew) 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)

Example 17 with DeliveryType

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;
}
Also used : FilterType(org.apache.cxf.ws.eventing.FilterType) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) ObjectFactory(org.apache.cxf.ws.eventing.ObjectFactory) ExpirationType(org.apache.cxf.ws.eventing.ExpirationType) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Subscribe(org.apache.cxf.ws.eventing.Subscribe) DeliveryType(org.apache.cxf.ws.eventing.DeliveryType)

Aggregations

DeliveryType (org.apache.cxf.ws.eventing.DeliveryType)17 Subscribe (org.apache.cxf.ws.eventing.Subscribe)17 ExpirationType (org.apache.cxf.ws.eventing.ExpirationType)16 SimpleEventingIntegrationTest (org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest)16 Test (org.junit.Test)16 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)10 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)10 ObjectFactory (org.apache.cxf.ws.eventing.ObjectFactory)10 Server (org.apache.cxf.endpoint.Server)9 NotificatorService (org.apache.cxf.ws.eventing.backend.notification.NotificatorService)9 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)7 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 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 GetStatusResponse (org.apache.cxf.ws.eventing.GetStatusResponse)3 JAXBElement (javax.xml.bind.JAXBElement)2