Search in sources :

Example 1 with TestMessageProcessor

use of org.mule.tck.testmodels.mule.TestMessageProcessor in project mule by mulesoft.

the class ForeachTestCase method initialise.

@Before
public void initialise() throws MuleException {
    processedEvents = new ArrayList<>();
    simpleForeach = createForeach(getSimpleMessageProcessors(new TestMessageProcessor("zas")));
    nestedForeach = createForeach(getNestedMessageProcessors());
}
Also used : TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) Before(org.junit.Before)

Example 2 with TestMessageProcessor

use of org.mule.tck.testmodels.mule.TestMessageProcessor in project mule by mulesoft.

the class ForeachTestCase method failingExpressionInChain.

@Test
public void failingExpressionInChain() throws Exception {
    Foreach foreach = createForeach();
    foreach.setCollectionExpression("!@INVALID");
    SensingNullMessageProcessor firstProcessor = new SensingNullMessageProcessor();
    List<Processor> processors = getSimpleMessageProcessors(new TestMessageProcessor("zas"));
    processors.add(0, firstProcessor);
    foreach.setMessageProcessors(processors);
    initialiseIfNeeded(foreach, muleContext);
    try {
        expectExpressionException(foreach);
        processInChain(foreach, eventBuilder(muleContext).message(of(new DummyNestedIterableClass().iterator())).build());
    } finally {
        assertThat(firstProcessor.invocations, equalTo(0));
    }
}
Also used : InternalProcessor(org.mule.runtime.core.privileged.processor.InternalProcessor) Processor(org.mule.runtime.core.api.processor.Processor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) Test(org.junit.Test)

Example 3 with TestMessageProcessor

use of org.mule.tck.testmodels.mule.TestMessageProcessor in project mule by mulesoft.

the class ForeachTestCase method failingExpression.

@Test
public void failingExpression() throws Exception {
    Foreach foreach = createForeach();
    foreach.setCollectionExpression("!@INVALID");
    SensingNullMessageProcessor firstProcessor = new SensingNullMessageProcessor();
    List<Processor> processors = getSimpleMessageProcessors(new TestMessageProcessor("zas"));
    processors.add(0, firstProcessor);
    foreach.setMessageProcessors(processors);
    initialiseIfNeeded(foreach, muleContext);
    try {
        expectExpressionException(foreach);
        process(foreach, eventBuilder(muleContext).message(of(new DummyNestedIterableClass().iterator())).build(), false);
    } finally {
        assertThat(firstProcessor.invocations, equalTo(0));
    }
}
Also used : InternalProcessor(org.mule.runtime.core.privileged.processor.InternalProcessor) Processor(org.mule.runtime.core.api.processor.Processor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) Test(org.junit.Test)

Example 4 with TestMessageProcessor

use of org.mule.tck.testmodels.mule.TestMessageProcessor in project mule by mulesoft.

the class ChoiceRouterTestCase method testMatchingRouteWithStatistics.

@Test
public void testMatchingRouteWithStatistics() throws Exception {
    choiceRouter.addRoute(payloadZapExpression(), newChain(empty(), new TestMessageProcessor("bar")));
    choiceRouter.setRouterStatistics(new RouterStatistics(TYPE_OUTBOUND));
    choiceRouter.setMuleContext(muleContext);
    choiceRouter.initialise();
    assertThat(process(choiceRouter, zapEvent()).getMessage().getPayload().getValue(), is("zap:bar"));
}
Also used : RouterStatistics(org.mule.runtime.core.api.management.stats.RouterStatistics) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) Test(org.junit.Test)

Example 5 with TestMessageProcessor

use of org.mule.tck.testmodels.mule.TestMessageProcessor in project mule by mulesoft.

the class ChoiceRouterTestCase method testNoMatchingNorDefaultRoute.

@Test
public void testNoMatchingNorDefaultRoute() throws Exception {
    choiceRouter.addRoute(payloadZapExpression(), newChain(empty(), new TestMessageProcessor("bar")));
    CoreEvent inputEvent = fooEvent();
    assertThat(process(choiceRouter, inputEvent), is(inputEvent));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) Test(org.junit.Test)

Aggregations

TestMessageProcessor (org.mule.tck.testmodels.mule.TestMessageProcessor)9 Test (org.junit.Test)8 Processor (org.mule.runtime.core.api.processor.Processor)4 InternalProcessor (org.mule.runtime.core.privileged.processor.InternalProcessor)4 SensingNullMessageProcessor (org.mule.tck.SensingNullMessageProcessor)4 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)2 RouterStatistics (org.mule.runtime.core.api.management.stats.RouterStatistics)2 MessageProcessorChain (org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain)2 Before (org.junit.Before)1