Search in sources :

Example 6 with TestMessageProcessor

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

the class ChoiceRouterTestCase method testAddAndDeleteRoute.

@Test
public void testAddAndDeleteRoute() throws Exception {
    MessageProcessorChain mp = newChain(empty(), new TestMessageProcessor("bar"));
    choiceRouter.addRoute(payloadZapExpression(), mp);
    choiceRouter.removeRoute(mp);
    choiceRouter.setRouterStatistics(new RouterStatistics(TYPE_OUTBOUND));
    choiceRouter.setMuleContext(muleContext);
    choiceRouter.initialise();
    CoreEvent inputEvent = zapEvent();
    assertThat(process(choiceRouter, inputEvent), is(inputEvent));
}
Also used : MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) RouterStatistics(org.mule.runtime.core.api.management.stats.RouterStatistics) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) Test(org.junit.Test)

Example 7 with TestMessageProcessor

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

the class ChoiceRouterTestCase method testUpdateRoute.

@Test
public void testUpdateRoute() throws Exception {
    MessageProcessorChain mp = newChain(empty(), new TestMessageProcessor("bar"));
    choiceRouter.addRoute(payloadPazExpression(), mp);
    choiceRouter.updateRoute(payloadZapExpression(), mp);
    choiceRouter.setMuleContext(muleContext);
    choiceRouter.initialise();
    assertThat(process(choiceRouter, zapEvent()).getMessage().getPayload().getValue(), is("zap:bar"));
}
Also used : MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) Test(org.junit.Test)

Example 8 with TestMessageProcessor

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

the class ForeachTestCase method batchSizeWithCollectionAttributes.

@Test
public void batchSizeWithCollectionAttributes() throws Exception {
    Foreach foreachMp = createForeach();
    List<Processor> processors = getSimpleMessageProcessors(new TestMessageProcessor("zas"));
    foreachMp.setMessageProcessors(processors);
    foreachMp.setBatchSize(2);
    foreachMp.setCollectionExpression("vars.collection");
    initialiseIfNeeded(foreachMp, muleContext);
    foreachMp.process(eventBuilder(muleContext).addVariable("collection", asList(1, 2, 3)).message(of(null)).build());
    assertThat(processedEvents, hasSize(2));
    assertThat(((PrivilegedEvent) processedEvents.get(0)).getMessageAsString(muleContext), is("[1, 2]:foo:zas"));
    assertThat(((PrivilegedEvent) processedEvents.get(1)).getMessageAsString(muleContext), is("[3]:foo:zas"));
}
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) Test(org.junit.Test)

Example 9 with TestMessageProcessor

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

the class ForeachTestCase method batchSize.

@Test
public void batchSize() throws Exception {
    Foreach foreachMp = createForeach();
    List<Processor> processors = getSimpleMessageProcessors(new TestMessageProcessor("zas"));
    foreachMp.setMessageProcessors(processors);
    foreachMp.setBatchSize(2);
    initialiseIfNeeded(foreachMp, muleContext);
    foreachMp.process(eventBuilder(muleContext).message(of(asList(1, 2, 3))).build());
    assertThat(processedEvents, hasSize(2));
    assertThat(((PrivilegedEvent) processedEvents.get(0)).getMessageAsString(muleContext), is("[1, 2]:foo:zas"));
    assertThat(((PrivilegedEvent) processedEvents.get(1)).getMessageAsString(muleContext), is("[3]:foo:zas"));
}
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) 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