use of org.apache.synapse.eventing.SynapseSubscription in project wso2-synapse by wso2.
the class MessageBuilderTest method testSubscriptionMessageBuilderScenarioTwo.
public void testSubscriptionMessageBuilderScenarioTwo() {
String addressUrl = "http://synapse.test.com/eventing/subscriptions";
String message = "<wse:Unsubscribe xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).getAxis2MessageContext();
msgCtx.setTo(new EndpointReference(addressUrl));
String id = addIdentifierHeader(msgCtx);
SubscriptionMessageBuilder.resetErrorInfo();
SynapseSubscription sub = SubscriptionMessageBuilder.createUnSubscribeMessage(msgCtx);
assertEquals(id, sub.getId());
assertEquals(addressUrl, sub.getAddressUrl());
assertNull(SubscriptionMessageBuilder.getErrorCode());
assertNull(SubscriptionMessageBuilder.getErrorReason());
assertNull(SubscriptionMessageBuilder.getErrorSubCode());
} catch (Exception e) {
e.printStackTrace();
fail("Error while constructing the sample subscription request: " + e.getMessage());
}
}
use of org.apache.synapse.eventing.SynapseSubscription in project wso2-synapse by wso2.
the class MessageBuilderTest method testSubscriptionMessageBuilderScenarioFive.
public void testSubscriptionMessageBuilderScenarioFive() {
String addressUrl = "http://synapse.test.com/eventing/subscriptions";
String message = "<wse:Renew xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">\n" + " <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires>\n" + "</wse:Renew>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).getAxis2MessageContext();
msgCtx.setTo(new EndpointReference(addressUrl));
String id = addIdentifierHeader(msgCtx);
SubscriptionMessageBuilder.resetErrorInfo();
SynapseSubscription sub = SubscriptionMessageBuilder.createRenewSubscribeMessage(msgCtx);
assertNull(id, sub.getId());
assertEquals(addressUrl, sub.getAddressUrl());
assertNotNull(SubscriptionMessageBuilder.getErrorCode());
assertNotNull(SubscriptionMessageBuilder.getErrorReason());
assertNotNull(SubscriptionMessageBuilder.getErrorSubCode());
} catch (Exception e) {
e.printStackTrace();
fail("Error while constructing the sample subscription request: " + e.getMessage());
}
}
use of org.apache.synapse.eventing.SynapseSubscription in project wso2-synapse by wso2.
the class MessageBuilderTest method testSubscriptionMessageBuilderScenarioOne.
public void testSubscriptionMessageBuilderScenarioOne() {
String subManUrl = "http://synapse.test.com/eventing/subscriptions";
String addressUrl = "http://www.other.example.com/OnStormWarning";
String filterDialect = "http://www.example.org/topicFilter";
String filter = "weather.storms";
Date date = new Date(System.currentTimeMillis() + 3600000);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
String message = "<wse:Subscribe xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\" " + " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" " + " xmlns:ew=\"http://www.example.com/warnings\">\n" + " <wse:EndTo>\n" + " <wsa:Address>http://www.example.com/MyEventSink</wsa:Address>\n" + " <wsa:ReferenceProperties>\n" + " <ew:MySubscription>2597</ew:MySubscription>\n" + " </wsa:ReferenceProperties>\n" + " </wse:EndTo>\n" + " <wse:Delivery>\n" + " <wse:NotifyTo>\n" + " <wsa:Address>" + addressUrl + "</wsa:Address>\n" + " <wsa:ReferenceProperties>\n" + " <ew:MySubscription>2597</ew:MySubscription>\n" + " </wsa:ReferenceProperties>\n" + " </wse:NotifyTo>\n" + " </wse:Delivery>\n" + " <wse:Expires>" + ConverterUtil.convertToString(cal) + "</wse:Expires>\n" + " <wse:Filter xmlns:ow=\"http://www.example.org/oceanwatch\"\n" + " Dialect=\"" + filterDialect + "\" >" + filter + "</wse:Filter>\n" + "</wse:Subscribe>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).getAxis2MessageContext();
msgCtx.setTo(new EndpointReference(subManUrl));
SubscriptionMessageBuilder.resetErrorInfo();
SynapseSubscription sub = SubscriptionMessageBuilder.createSubscription(msgCtx);
assertEquals(subManUrl, sub.getSubManUrl());
assertEquals(addressUrl, sub.getAddressUrl());
assertEquals(addressUrl, sub.getEndpointUrl());
assertEquals(filterDialect, sub.getFilterDialect());
assertEquals(filter, sub.getFilterValue());
assertEquals(date, sub.getExpires().getTime());
assertNull(SubscriptionMessageBuilder.getErrorCode());
assertNull(SubscriptionMessageBuilder.getErrorReason());
assertNull(SubscriptionMessageBuilder.getErrorSubCode());
} catch (Exception e) {
fail("Error while constructing the sample subscription request: " + e.getMessage());
}
}
use of org.apache.synapse.eventing.SynapseSubscription in project wso2-synapse by wso2.
the class ResponseMessageBuilderTest method testGetStatusResponse.
public void testGetStatusResponse() {
String id = UIDGenerator.generateURNString();
String addressUrl = "http://synapse.test.com/eventing/sunscriptions";
Date date = new Date(System.currentTimeMillis() + 3600000);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
SynapseSubscription sub = new SynapseSubscription();
sub.setId(id);
sub.setSubManUrl(addressUrl);
sub.setExpires(cal);
String expected = "<wse:GetStatusResponse xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">" + "<wse:Expires>" + ConverterUtil.convertToString(cal) + "</wse:Expires>" + "</wse:GetStatusResponse>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext("<empty/>", null).getAxis2MessageContext();
ResponseMessageBuilder builder = new ResponseMessageBuilder(msgCtx);
SOAPEnvelope env = builder.genGetStatusResponse(sub);
OMElement resultOm = env.getBody().getFirstElement();
OMElement expectedOm = AXIOMUtil.stringToOM(expected);
assertTrue(compare(expectedOm, resultOm));
} catch (Exception e) {
fail("Error while constructing the test message context: " + e.getMessage());
}
}
use of org.apache.synapse.eventing.SynapseSubscription in project wso2-synapse by wso2.
the class ResponseMessageBuilderTest method testRenewResponse.
public void testRenewResponse() {
String id = UIDGenerator.generateURNString();
String addressUrl = "http://synapse.test.com/eventing/sunscriptions";
Date date = new Date(System.currentTimeMillis() + 3600000);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
SynapseSubscription sub = new SynapseSubscription();
sub.setId(id);
sub.setSubManUrl(addressUrl);
sub.setExpires(cal);
String expected = "<wse:RenewResponse xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">" + "<wse:Expires>" + ConverterUtil.convertToString(cal) + "</wse:Expires>" + "</wse:RenewResponse>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext("<empty/>", null).getAxis2MessageContext();
ResponseMessageBuilder builder = new ResponseMessageBuilder(msgCtx);
SOAPEnvelope env = builder.genRenewSubscriptionResponse(sub);
OMElement resultOm = env.getBody().getFirstElement();
OMElement expectedOm = AXIOMUtil.stringToOM(expected);
assertTrue(compare(expectedOm, resultOm));
} catch (Exception e) {
fail("Error while constructing the test message context: " + e.getMessage());
}
}
Aggregations