use of org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint in project cxf by apache.
the class SimpleEventingIntegrationTest method createSubscriptionManagerClient.
/**
* Convenience method to create a client for the testing Subscription Manager
* which is located at local://SimpleSubscriptionManager.
* You have to specify the reference parameters you obtained from the Event Source
* when your subscription was created.
*
* @return a JAX-WS client set up for managing the subscription you had created using the Event Source
*/
public SubscriptionManagerEndpoint createSubscriptionManagerClient(ReferenceParametersType refs) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setBus(bus);
factory.setServiceClass(SubscriptionManagerEndpoint.class);
factory.setAddress(URL_SUBSCRIPTION_MANAGER);
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
ReferenceParametersAddingHandler handler = new ReferenceParametersAddingHandler(refs);
factory.getHandlers().add(handler);
return (SubscriptionManagerEndpoint) factory.create();
}
use of org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint 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()));
}
use of org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint 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));
}
use of org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint 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));
}
use of org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint 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