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