Search in sources :

Example 1 with DefaultInMemorySubscriptionManager

use of org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager in project wso2-synapse by wso2.

the class EventSourceSerializerTest method testSerializeEvent3.

/**
 * Test serializeEventSource with subscriptionManager and assert OMElement returned is not null.
 *
 * @throws XMLStreamException - XMLStreamException
 */
@Test
public void testSerializeEvent3() throws XMLStreamException {
    SynapseEventSource synapseEventSource = new SynapseEventSource("Test");
    SubscriptionManager subscriptionManager = new DefaultInMemorySubscriptionManager();
    synapseEventSource.setSubscriptionManager(subscriptionManager);
    OMElement omElement = EventSourceSerializer.serializeEventSource(null, synapseEventSource);
    Assert.assertNotNull("OMElement cannot be null.", omElement);
}
Also used : SynapseEventSource(org.apache.synapse.eventing.SynapseEventSource) OMElement(org.apache.axiom.om.OMElement) DefaultInMemorySubscriptionManager(org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager) SubscriptionManager(org.wso2.eventing.SubscriptionManager) DefaultInMemorySubscriptionManager(org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager) Test(org.junit.Test)

Example 2 with DefaultInMemorySubscriptionManager

use of org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager in project wso2-synapse by wso2.

the class EventSourceSerializerTest method testSerializeEvent4.

/**
 * Test SerialEvent and assert OMElement returned is not null.
 *
 * @throws XMLStreamException - XMLStreamException
 * @throws EventException     - EventException
 */
@Test
public void testSerializeEvent4() throws XMLStreamException, EventException {
    String inputXML = "      <eventSource name=\"SampleEventSource\" xmlns=\"http://ws.apache.org/ns/synapse\">\n" + "            <subscriptionManager class=\"org.apache.synapse.eventing.managers." + "DefaultInMemorySubscriptionManager\">\n" + "                <property name=\"topicHeaderName\" value=\"Topic\"/>\n" + "                <property name=\"topicHeaderNS\" value=\"http://apache.org/aip\"/>\n" + "            </subscriptionManager>\n" + "            <subscription id=\"mySubscription\">\n" + "                 <filter source =\"synapse/event/test\" dialect=\"http://synapse.apache.org/" + "eventing/dialect/topicFilter\"/>\n" + "                 <endpoint><address uri=\"http://localhost:9000/services/" + "SimpleStockQuoteService\"/></endpoint>\n" + "            </subscription>\n" + "            <subscription id=\"mySubscription2\">\n" + "                 <filter source =\"synapse/event/test\" dialect=\"http://synapse.apache.org/" + "eventing/dialect/topicFilter\"/>\n" + "                 <endpoint><address uri=\"http://localhost:9000/services/" + "SimpleStockQuoteService\"/></endpoint>\n" + "                 <expires>2020-06-27T21:07:00.000-08:00</expires>\n" + "            </subscription>\n" + "      </eventSource>\n";
    OMElement element = AXIOMUtil.stringToOM(inputXML);
    SynapseEventSource synapseEventSource = new SynapseEventSource("Test");
    SubscriptionManager subscriptionManager = new DefaultInMemorySubscriptionManager();
    subscriptionManager.addProperty("Name", "Test");
    SynapseSubscription synapseSubscription = new SynapseSubscription();
    synapseSubscription.setStaticEntry(true);
    Date date = new Date(System.currentTimeMillis() + 3600000);
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    synapseSubscription.setExpires(cal);
    subscriptionManager.subscribe(synapseSubscription);
    synapseEventSource.setSubscriptionManager(subscriptionManager);
    OMElement omElement = EventSourceSerializer.serializeEventSource(element, synapseEventSource);
    Assert.assertNotNull("OMElement cannot be null.", omElement);
}
Also used : SynapseSubscription(org.apache.synapse.eventing.SynapseSubscription) SynapseEventSource(org.apache.synapse.eventing.SynapseEventSource) Calendar(java.util.Calendar) OMElement(org.apache.axiom.om.OMElement) DefaultInMemorySubscriptionManager(org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager) SubscriptionManager(org.wso2.eventing.SubscriptionManager) DefaultInMemorySubscriptionManager(org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager) Date(java.util.Date) Test(org.junit.Test)

Example 3 with DefaultInMemorySubscriptionManager

use of org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager in project wso2-synapse by wso2.

the class SynapseEventSourceTest method setUp.

protected void setUp() throws Exception {
    source = new SynapseEventSource("foo");
    subMan = new DefaultInMemorySubscriptionManager();
    source.setSubscriptionManager(subMan);
}
Also used : DefaultInMemorySubscriptionManager(org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager)

Aggregations

DefaultInMemorySubscriptionManager (org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager)3 OMElement (org.apache.axiom.om.OMElement)2 SynapseEventSource (org.apache.synapse.eventing.SynapseEventSource)2 Test (org.junit.Test)2 SubscriptionManager (org.wso2.eventing.SubscriptionManager)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 SynapseSubscription (org.apache.synapse.eventing.SynapseSubscription)1