Package org.mule.api.processor.policy

Examples of org.mule.api.processor.policy.AroundPolicy


public class PolicyTestCase extends AbstractMuleTestCase
{

    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


                                                            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

                public MuleEvent process(MuleEvent event) throws MuleException
                {
                    return doProcess(event);
                }
            });
            final AroundPolicy entryPoint = activePolicies.get(0);
            result = entryPoint.invoke(invocation);
        }
        else
        {
            // direct invocation
            result = doProcess(event);
View Full Code Here

TOP

Related Classes of org.mule.api.processor.policy.AroundPolicy

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.