Search in sources :

Example 1 with GetStatusResponse

use of org.apache.cxf.ws.eventing.GetStatusResponse in project cxf by apache.

the class AbstractSubscriptionManager method getStatusOp.

@Override
public GetStatusResponse getStatusOp(GetStatus body) {
    String uuid = retrieveSubscriptionUUID();
    LOG.info("received GetStatus message for UUID=" + uuid);
    SubscriptionTicket ticket = obtainTicketFromDatabaseOrThrowFault(uuid);
    GetStatusResponse response = new GetStatusResponse();
    response.setGrantedExpires(DurationAndDateUtil.toExpirationTypeContainingGregorianCalendar(ticket.getExpires()));
    return response;
}
Also used : GetStatusResponse(org.apache.cxf.ws.eventing.GetStatusResponse) SubscriptionTicket(org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket)

Example 2 with GetStatusResponse

use of org.apache.cxf.ws.eventing.GetStatusResponse in project cxf by apache.

the class SubscriptionManagementTest method getStatus.

/**
 * Creates a subscription and then retrieves its status from the Subscription Manager.
 */
@Test
public void getStatus() 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 resp = eventSourceClient.subscribeOp(subscribe);
    SubscriptionManagerEndpoint client = createSubscriptionManagerClient(resp.getSubscriptionManager().getReferenceParameters());
    GetStatusResponse response = client.getStatusOp(new GetStatus());
    System.out.println("EXPIRES: " + response.getGrantedExpires().getValue());
    Assert.assertTrue("GetStatus operation should return a XMLGregorianCalendar", DurationAndDateUtil.isXMLGregorianCalendar(response.getGrantedExpires().getValue()));
}
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) 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 3 with GetStatusResponse

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

use of org.apache.cxf.ws.eventing.GetStatusResponse in project cxf by apache.

the class SubscriptionManagementTest method renewWithDuration.

/**
 * Tests the Renew operation, while specifying an xs:duration in the renew request,
 * eg. the subscriber requests to prolong the subscription by a specific amount of time.
 */
@Test
public void renewWithDuration() throws IOException {
    Subscribe subscribe = new Subscribe();
    ExpirationType exp = new ExpirationType();
    exp.setValue(DurationAndDateUtil.convertToXMLString(// 5 minutes
    DurationAndDateUtil.parseDurationOrTimestamp("PT5M0S")));
    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(// 10 minutes
    DurationAndDateUtil.parseDurationOrTimestamp("PT10M0S")));
    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)

Aggregations

GetStatusResponse (org.apache.cxf.ws.eventing.GetStatusResponse)4 DeliveryType (org.apache.cxf.ws.eventing.DeliveryType)3 ExpirationType (org.apache.cxf.ws.eventing.ExpirationType)3 GetStatus (org.apache.cxf.ws.eventing.GetStatus)3 Subscribe (org.apache.cxf.ws.eventing.Subscribe)3 SubscribeResponse (org.apache.cxf.ws.eventing.SubscribeResponse)3 SimpleEventingIntegrationTest (org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest)3 SubscriptionManagerEndpoint (org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint)3 Test (org.junit.Test)3 Renew (org.apache.cxf.ws.eventing.Renew)2 SubscriptionTicket (org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket)1