Package org.apache.synapse

Examples of org.apache.synapse.Mediator


        assertEquals("Test Property", ctx.getProperty("testPropInMC"));
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithMessagePropertiesCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'><property name=\"testProp\" " +
                        "value=\"TestProperty\" expression=\"//testNode\"/></pojoCommand>"), new Properties());
        POJOCommandTestHelper.reset();
        MessageContext ctx = new TestMessageContext();
        SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
        envelope.getBody().addChild(createOMElement("<original><testNode/></original>"));
        ctx.setEnvelope(envelope);
        pcm.mediate(ctx);
        assertEquals("TestProperty", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertEquals("<original>TestProperty</original>", ctx.getEnvelope().getBody().getFirstOMChild().toString());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }
View Full Code Here


        assertEquals("<original>TestProperty</original>", ctx.getEnvelope().getBody().getFirstOMChild().toString());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithContextR$UPropertiesCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'><property name=\"ctxTest\" " +
                        "context-name=\"testCtxProp\" action=\"ReadAndUpdateContext\"/></pojoCommand>"), new Properties());
        POJOCommandTestHelper.reset();
        MessageContext ctx = new TestMessageContext();
        ctx.setProperty("testCtxProp", "test");
        pcm.mediate(ctx);
        assertEquals("testcommand", ctx.getProperty("testCtxProp").toString());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }
View Full Code Here

        super.tearDown();
        fac = null;
    }

    public void testClonningScenarioOne() throws Exception {
        Mediator clone = fac.createMediator(createOMElement("<clone " +
            "xmlns=\"http://ws.apache.org/ns/synapse\"><target soapAction=\"urn:clone\" " +
            "sequence=\"seqRef\"/><target to=\"http://test\"><sequence><sequence " +
            "key=\"seqRef\"/></sequence></target></clone>"), new Properties());
        clone.mediate(testCtx);
        while(helperMediator.getMediatedContext(1) == null) {
            Thread.sleep(100);
        }
        MessageContext mediatedCtx = helperMediator.getMediatedContext(0);
        String formerSAction = mediatedCtx.getSoapAction();
View Full Code Here

            assertEquals(mediatedCtx.getSoapAction(), "urn:clone");
        }
    }

    public void testClonningWithContinueParent() throws Exception {
        Mediator clone = fac.createMediator(createOMElement("<clone continueParent=\"true\" " +
            "xmlns=\"http://ws.apache.org/ns/synapse\"><target soapAction=\"urn:clone\" " +
            "sequence=\"seqRef\"/><target to=\"http://test\"><sequence><sequence " +
            "key=\"seqRef\"/></sequence></target></clone>"), new Properties());
        assertTrue(clone.mediate(testCtx));
        while(helperMediator.getMediatedContext(1) == null) {
            Thread.sleep(100);
        }
        MessageContext mediatedCtx = helperMediator.getMediatedContext(0);
        assertTrue(mediatedCtx.getEnvelope().getBody().getFirstElement() == null);
View Full Code Here

* XPath parameters at runtime.
*/
public class ClassMediatorTest extends AbstractMediatorTestCase {

    public void testMediationWithoutProperties() throws Exception {
        Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
        cm.mediate(new TestMessageContext());
        assertTrue(ClassMediatorTestMediator.invoked);
    }
View Full Code Here

        cm.mediate(new TestMessageContext());
        assertTrue(ClassMediatorTestMediator.invoked);
    }

    public void testMediationWithLiteralProperties() throws Exception {
        Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'><property name='testProp' value='testValue'/></class>"), new Properties());
        cm.mediate(new TestMessageContext());
        assertTrue(ClassMediatorTestMediator.invoked);
        assertTrue(ClassMediatorTestMediator.testProp.equals("testValue"));
    }
View Full Code Here

        assertTrue(ClassMediatorTestMediator.invoked);
        assertTrue(ClassMediatorTestMediator.testProp.equals("testValue"));
    }

    public void testInitializationAndMedition() throws Exception {
        Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
        ((ManagedLifecycle) cm).init(new Axis2SynapseEnvironment(new SynapseConfiguration()));
        assertTrue(ClassMediatorTestMediator.initialized);
        cm.mediate(new TestMessageContext());
        assertTrue(ClassMediatorTestMediator.invoked);
    }
View Full Code Here

        cm.mediate(new TestMessageContext());
        assertTrue(ClassMediatorTestMediator.invoked);
    }

    public void testDestroy() throws Exception {
        Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
        cm.mediate(new TestMessageContext());
        assertTrue(ClassMediatorTestMediator.invoked);
        ((ManagedLifecycle) cm).destroy();
        assertTrue(ClassMediatorTestMediator.destroyed);
    }
View Full Code Here

        super.tearDown();
        fac = null;
    }

    public void testIterationScenarioOne() throws Exception {
        Mediator iterate = fac.createMediator(createOMElement("<iterate " +
            "expression=\"//original/itr\" xmlns=\"http://ws.apache.org/ns/synapse\">" +
            "<target soapAction=\"urn:iterate\" sequence=\"seqRef\"/></iterate>"), new Properties());
        helperMediator.clearMediatedContexts();
        iterate.mediate(testCtx);
        while(helperMediator.getMediatedContext(1) == null) {
            Thread.sleep(100);
        }
        MessageContext mediatedCtx = helperMediator.getMediatedContext(0);
        assertEquals(mediatedCtx.getSoapAction(), "urn:iterate");
View Full Code Here

                .getBody().getFirstElement().getText(), helperMediator.getCheckString());
        }
    }

    public void testIterationWithPreservePayload() throws Exception {
        Mediator iterate = fac.createMediator(createOMElement("<iterate " +
            "expression=\"//original/itr\" preservePayload=\"true\" attachPath=\"//original\" " +
            "xmlns=\"http://ws.apache.org/ns/synapse\"><target soapAction=\"urn:iterate\" " +
            "sequence=\"seqRef\"/></iterate>"), new Properties());
        iterate.mediate(testCtx);
        while(helperMediator.getMediatedContext(1) == null) {
            Thread.sleep(100);
        }
        MessageContext mediatedCtx = helperMediator.getMediatedContext(0);
        assertEquals(mediatedCtx.getSoapAction(), "urn:iterate");
View Full Code Here

TOP

Related Classes of org.apache.synapse.Mediator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.