Search in sources :

Example 6 with EventException

use of org.wso2.eventing.exceptions.EventException in project wso2-synapse by wso2.

the class SynapseEventSourceTest method renewTest.

public void renewTest() {
    Date date = new Date(System.currentTimeMillis() + 3600000 * 2);
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    String message = "<wse:Renew xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">\n" + "   <wse:Expires>" + ConverterUtil.convertToString(cal) + "</wse:Expires>\n" + "</wse:Renew>";
    try {
        MessageContext msgCtx = createMessageContext(message, EventingConstants.WSE_RENEW);
        QName qname = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_IDENTIFIER, "wse");
        TestUtils.addSOAPHeaderBlock(msgCtx, qname, id);
        source.receive(msgCtx);
    } catch (Exception ignored) {
    }
    try {
        assertEquals(1, subMan.getSubscriptions().size());
        SynapseSubscription s = (SynapseSubscription) subMan.getSubscription(this.id);
        assertEquals(SUB_MAN_URL, s.getSubManUrl());
        assertEquals(ADDR_URL, s.getAddressUrl());
        assertEquals(FILTER_DIALECT, s.getFilterDialect());
        assertEquals(FILTER, s.getFilterValue());
        assertEquals(date, s.getExpires().getTime());
    } catch (EventException e) {
        fail("Eventing exception occured while accessing the subscription manager");
    }
}
Also used : EventException(org.wso2.eventing.exceptions.EventException) QName(javax.xml.namespace.QName) Calendar(java.util.Calendar) MessageContext(org.apache.axis2.context.MessageContext) Date(java.util.Date) EventException(org.wso2.eventing.exceptions.EventException)

Example 7 with EventException

use of org.wso2.eventing.exceptions.EventException in project wso2-synapse by wso2.

the class SynapseEventSourceTest method unsubscribeTest.

public void unsubscribeTest() {
    String message = "<wse:Unsubscribe xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>";
    try {
        MessageContext msgCtx = createMessageContext(message, EventingConstants.WSE_UNSUBSCRIBE);
        QName qname = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_IDENTIFIER, "wse");
        TestUtils.addSOAPHeaderBlock(msgCtx, qname, id);
        source.receive(msgCtx);
    } catch (Exception ignored) {
    }
    try {
        assertEquals(0, subMan.getSubscriptions().size());
    } catch (EventException e) {
        fail("Eventing exception occured while accessing the subscription manager");
    }
}
Also used : EventException(org.wso2.eventing.exceptions.EventException) QName(javax.xml.namespace.QName) MessageContext(org.apache.axis2.context.MessageContext) EventException(org.wso2.eventing.exceptions.EventException)

Example 8 with EventException

use of org.wso2.eventing.exceptions.EventException in project wso2-synapse by wso2.

the class SynapseEventSourceTest method subscribeTest.

private void subscribeTest() {
    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>" + ADDR_URL + "</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=\"" + FILTER_DIALECT + "\" >" + FILTER + "</wse:Filter>\n" + "</wse:Subscribe>";
    try {
        MessageContext msgCtx = createMessageContext(message, EventingConstants.WSE_SUBSCRIBE);
        source.receive(msgCtx);
    } catch (Exception ignored) {
    }
    try {
        assertEquals(1, subMan.getSubscriptions().size());
        SynapseSubscription s = (SynapseSubscription) subMan.getSubscriptions().get(0);
        assertEquals(SUB_MAN_URL, s.getSubManUrl());
        assertEquals(ADDR_URL, s.getAddressUrl());
        assertEquals(FILTER_DIALECT, s.getFilterDialect());
        assertEquals(FILTER, s.getFilterValue());
        assertEquals(date, s.getExpires().getTime());
        id = s.getId();
    } catch (EventException e) {
        fail("Eventing exception occured while accessing the subscription manager");
    }
}
Also used : EventException(org.wso2.eventing.exceptions.EventException) Calendar(java.util.Calendar) MessageContext(org.apache.axis2.context.MessageContext) Date(java.util.Date) EventException(org.wso2.eventing.exceptions.EventException)

Aggregations

EventException (org.wso2.eventing.exceptions.EventException)6 Calendar (java.util.Calendar)3 Date (java.util.Date)3 QName (javax.xml.namespace.QName)3 OMElement (org.apache.axiom.om.OMElement)3 MessageContext (org.apache.axis2.context.MessageContext)3 Iterator (java.util.Iterator)2 OMAttribute (org.apache.axiom.om.OMAttribute)2 SynapseEventSource (org.apache.synapse.eventing.SynapseEventSource)2 SynapseSubscription (org.apache.synapse.eventing.SynapseSubscription)2 SubscriptionManager (org.wso2.eventing.SubscriptionManager)2 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1 SynapseException (org.apache.synapse.SynapseException)1 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)1 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)1 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)1 ResponseMessageBuilder (org.apache.synapse.eventing.builders.ResponseMessageBuilder)1 DefaultInMemorySubscriptionManager (org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager)1 Test (org.junit.Test)1 Subscription (org.wso2.eventing.Subscription)1