Package org.apache.synapse

Examples of org.apache.synapse.Mediator.mediate()


    public void testPojoWithoutPropertiesCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
        POJOCommandTestHelper.reset();
        pcm.mediate(new TestMessageContext());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithPropertiesCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
View Full Code Here


        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'><property name=\"testProp\" " +
                        "expression=\"fn:concat('XPATH ', 'FUNC')\" action=\"ReadMessage\"/></pojoCommand>"), new Properties());
        POJOCommandTestHelper.reset();
        pcm.mediate(new TestMessageContext());
        assertEquals("XPATH FUNC", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithStaticPropertiesCommandImpl() throws Exception {
View Full Code Here

        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=\"Test Property\"/></pojoCommand>"), new Properties());
        POJOCommandTestHelper.reset();
        pcm.mediate(new TestMessageContext());
        assertEquals("Test Property", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithContextPropertiesCommandImpl() throws Exception {
View Full Code Here

                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'><property name=\"testProp\" " +
                        "value=\"Test Property\" context-name=\"testPropInMC\"/></pojoCommand>"), new Properties());
        POJOCommandTestHelper.reset();
        MessageContext ctx = new TestMessageContext();
        pcm.mediate(ctx);
        assertEquals("Test Property", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertEquals("Test Property", ctx.getProperty("testPropInMC"));
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }
View Full Code Here

        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

                        "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

    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

    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

    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);
    }

    public void testMediationWithLiteralProperties() throws Exception {
        Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
View Full Code Here

    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"));
    }

    public void testInitializationAndMedition() throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.