Examples of MessageProcessorChain


Examples of org.mule.api.processor.MessageProcessorChain

        processors = endpoint.getResponseMessageProcessors();
        assertNotNull(processors);

        assertEquals(1, processors.size());
        assertTrue(processors.get(0) instanceof MessageProcessorChain);
        MessageProcessorChain chain = (MessageProcessorChain) processors.get(0);
        assertEquals("3", ((TestMessageProcessor) chain.getMessageProcessors().get(0)).getLabel());
        assertEquals("4", ((TestMessageProcessor) chain.getMessageProcessors().get(1)).getLabel());
    }
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

        processors = endpoint.getResponseMessageProcessors();
        assertNotNull(processors);
        assertEquals(1, processors.size());
        assertTrue(processors.get(0) instanceof MessageProcessorChain);
        MessageProcessorChain chain = (MessageProcessorChain) processors.get(0);
        assertEquals(2, chain.getMessageProcessors().size());
        assertEquals("C", ((TestMessageProcessor) chain.getMessageProcessors().get(0)).getLabel());
        assertEquals("D", ((TestMessageProcessor) chain.getMessageProcessors().get(1)).getLabel());

        MessageProcessor mp =
            ((OutboundPassThroughRouter) ((OutboundRouterCollection)muleContext.getRegistry().lookupService("localEndpoints").
                getOutboundMessageProcessor()).getRoutes().get(0)).getRoute("ep4");

        endpoint = (ImmutableEndpoint) mp;
        processors = endpoint.getMessageProcessors();
        assertNotNull(processors);
        assertEquals(2, processors.size());
        assertEquals("E", ((TestMessageProcessor) processors.get(0)).getLabel());
        assertEquals("F", ((TestMessageProcessor) processors.get(1)).getLabel());

        processors = endpoint.getResponseMessageProcessors();
        assertNotNull(processors);
        assertEquals(1, processors.size());
        assertTrue(processors.get(0) instanceof MessageProcessorChain);
        chain = (MessageProcessorChain) processors.get(0);
        assertEquals(2, chain.getMessageProcessors().size());
        assertEquals("G", ((TestMessageProcessor) chain.getMessageProcessors().get(0)).getLabel());
        assertEquals("H", ((TestMessageProcessor) chain.getMessageProcessors().get(1)).getLabel());
    }
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

    public void testSinglePolicy() throws Exception
    {
        AroundPolicy ap = new TestPolicy("test around policy");

        // this is our regular chain that should get a policy applied
        MessageProcessorChain chain = DefaultMessageProcessorChain.from(
                                                             new StringAppendTransformer("first"),
                                                             new StringAppendTransformer(" second"));
        initialiseObject(chain);

        // test registration
        assertEquals("No policies should have been registered.", 0, chain.getPolicies().list().size());
        chain.getPolicies().add(ap);
        assertSame("Policy has not been registered.", ap, chain.getPolicies().list().iterator().next());

        System.out.println(chain);

        // invoke
        final MuleEvent result = chain.process(getTestEvent("payload "));
        assertNotNull(result);
        final MuleMessage message = result.getMessage();
        assertNotNull(message);
        assertEquals("payload {before} first second {after}", message.getPayload());

        // test cleanup
        final AroundPolicy policy = chain.getPolicies().remove(ap.getName());
        assertSame("Wrong policy returned?", ap, policy);
        assertEquals("No policies should have been registered.", 0, chain.getPolicies().list().size());
    }
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

    public void testMultiplePolicies() throws Exception
    {

        // this is our regular chain that should get a policy applied
        MessageProcessorChain chain = DefaultMessageProcessorChain.from(
                                                            new StringAppendTransformer("first"),
                                                            new StringAppendTransformer(" second"));
        initialiseObject(chain);

        // test registration
        assertEquals("No policies should have been registered.", 0, chain.getPolicies().list().size());
        AroundPolicy policy1 = new TestPolicy("test around policy 1");
        chain.getPolicies().add(policy1);
        // add another policy
        final TestPolicy policy2 = new TestPolicy("test around policy 2");
        chain.getPolicies().add(policy2);
        assertEquals("Wrong policies count.", 2, chain.getPolicies().list().size());

        System.out.println(chain);

        // invoke
        final MuleEvent result = chain.process(getTestEvent("payload "));
        assertNotNull(result);
        final MuleMessage message = result.getMessage();
        assertNotNull(message);
        assertEquals("payload {before} {before} first second {after} {after}", message.getPayload());

        // test cleanup
        final AroundPolicy policy = chain.getPolicies().remove(policy1.getName());
        assertSame("Wrong policy returned?", policy1, policy);
        chain.getPolicies().remove(policy2.getName());
        assertEquals("No policies should have been registered.", 0, chain.getPolicies().list().size());
    }
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

        assertEquals("No policies should have been registered.", 0, chain.getPolicies().list().size());
    }

    public void testDuplicateName() throws Exception
    {
        MessageProcessorChain chain = DefaultMessageProcessorChain.from();
        chain.getPolicies().add(new TestPolicy("test"));
        try
        {
            chain.getPolicies().add(new TestPolicy("test"));
            fail("Should've thrown an exception, no duplicates allowed");
        }
        catch (IllegalArgumentException e)
        {
            System.out.println(e);
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

            restul.getMessageAsString());
    }

    public void testMixStaticFactoryt() throws Exception
    {
        MessageProcessorChain chain = DefaultMessageProcessorChain.from(new TestIntercepting(),
            new TestNonIntercepting(), new TestNonIntercepting(), new TestIntercepting(),
            new TestNonIntercepting(), new TestNonIntercepting());
        MuleEvent restul = chain.process(getTestEventUsingFlow(""));
        assertEquals(
            "InterceptingMessageProcessorMessageProcessorMessageProcessorInterceptingMessageProcessorMessageProcessorMessageProcessor",
            restul.getMessageAsString());
    }
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

            restul.getMessageAsString());
    }

    public void testMix2StaticFactory() throws Exception
    {
        MessageProcessorChain chain = DefaultMessageProcessorChain.from(new TestNonIntercepting(),
            new TestIntercepting(), new TestNonIntercepting(), new TestNonIntercepting(),
            new TestNonIntercepting(), new TestIntercepting());
        MuleEvent restul = chain.process(getTestEventUsingFlow(""));
        assertEquals(
            "MessageProcessorInterceptingMessageProcessorMessageProcessorMessageProcessorMessageProcessorInterceptingMessageProcessor",
            restul.getMessageAsString());
    }
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

        }

        MessageProcessor proxyMessageProcessor;
        if (cachingStrategy != null)
        {
            final MessageProcessorChain cachedMessageProcessors = proxyBuilder.build();

            proxyMessageProcessor = new MessageProcessor()
            {

                @Override
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

        DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder(flow);
        builder.chain(preMessageProcessors);

        builder.chain(staticChain);
        builder.chain(postMessageProcessors);
        MessageProcessorChain newChain = builder.build();

        Lifecycle preChainOld = preChain;
        Lifecycle postChainOld = postChain;
        preChain = new SimpleMessageProcessorChain(preMessageProcessors);
        postChain = new SimpleMessageProcessorChain(postMessageProcessors);
View Full Code Here

Examples of org.mule.api.processor.MessageProcessorChain

        processors = endpoint.getResponseMessageProcessors();
        assertNotNull(processors);

        assertEquals(1, processors.size());
        assertTrue(processors.get(0) instanceof MessageProcessorChain);
        MessageProcessorChain chain = (MessageProcessorChain) processors.get(0);
        assertEquals("3", ((TestMessageProcessor) chain.getMessageProcessors().get(0)).getLabel());
        assertEquals("4", ((TestMessageProcessor) chain.getMessageProcessors().get(1)).getLabel());
    }
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.