use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class ForeachTestCase method failingNestedProcessor.
@Test
public void failingNestedProcessor() throws Exception {
RuntimeException throwable = new BufferOverflowException();
Foreach foreach = createForeach();
SensingNullMessageProcessor firstProcessor = new SensingNullMessageProcessor();
InternalTestProcessor failingProcessor = event -> {
throw throwable;
};
foreach.setMessageProcessors(asList(firstProcessor, failingProcessor));
initialiseIfNeeded(foreach, muleContext);
try {
expectNestedProessorException(throwable, failingProcessor);
process(foreach, eventBuilder(muleContext).message(of(new DummyNestedIterableClass().iterator())).build(), false);
} finally {
assertThat(firstProcessor.invocations, equalTo(1));
}
}
use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class SimpleCollectionAggregatorTestCase method testAggregateMultipleEvents.
@Test
public void testAggregateMultipleEvents() throws Exception {
Flow flow = createAndRegisterFlow(muleContext, APPLE_FLOW, componentLocator);
assertNotNull(flow);
SimpleCollectionAggregator router = new SimpleCollectionAggregator();
SensingNullMessageProcessor sensingMessageProcessor = getSensingNullMessageProcessor();
router.setListener(sensingMessageProcessor);
router.setAnnotations(getAppleFlowComponentLocationAnnotations());
initialiseIfNeeded(router, true, muleContext);
EventContext executionContext = create(flow, TEST_CONNECTOR_LOCATION, "foo");
Message message1 = Message.of("test event A");
Message message2 = Message.of("test event B");
Message message3 = Message.of("test event C");
CoreEvent event1 = InternalEvent.builder(executionContext).message(message1).groupCorrelation(Optional.of(GroupCorrelation.of(0, 3))).build();
CoreEvent event2 = InternalEvent.builder(executionContext).message(message2).build();
CoreEvent event3 = InternalEvent.builder(executionContext).message(message3).build();
assertNull(router.process(event1));
assertNull(router.process(event2));
CoreEvent resultEvent = router.process(event3);
assertNotNull(sensingMessageProcessor.event);
assertThat(resultEvent, equalTo(sensingMessageProcessor.event));
Message nextMessage = sensingMessageProcessor.event.getMessage();
assertNotNull(nextMessage);
assertTrue(nextMessage.getPayload().getValue() instanceof List<?>);
List<InternalMessage> list = (List<InternalMessage>) nextMessage.getPayload().getValue();
assertEquals(3, list.size());
String[] results = new String[3];
list.stream().map(msg -> msg.getPayload().getValue()).collect(toList()).toArray(results);
// Need to sort result because of MULE-5998
Arrays.sort(results);
assertEquals("test event A", results[0]);
assertEquals("test event B", results[1]);
assertEquals("test event C", results[2]);
}
use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class SimpleCollectionAggregatorTestCase method testAggregateSingleEvent.
@Test
public void testAggregateSingleEvent() throws Exception {
Flow flow = createAndRegisterFlow(muleContext, APPLE_FLOW, componentLocator);
assertNotNull(flow);
SimpleCollectionAggregator router = new SimpleCollectionAggregator();
SensingNullMessageProcessor sensingMessageProcessor = getSensingNullMessageProcessor();
router.setListener(sensingMessageProcessor);
router.setMuleContext(muleContext);
router.setAnnotations(getAppleFlowComponentLocationAnnotations());
initialiseIfNeeded(router, true, muleContext);
EventContext executionContext = create(flow, TEST_CONNECTOR_LOCATION, "foo");
Message message1 = of("test event A");
CoreEvent event1 = InternalEvent.builder(executionContext).message(message1).groupCorrelation(Optional.of(GroupCorrelation.of(0, 1))).build();
CoreEvent resultEvent = router.process(event1);
assertNotNull(sensingMessageProcessor.event);
assertThat(resultEvent, equalTo(sensingMessageProcessor.event));
Message nextMessage = sensingMessageProcessor.event.getMessage();
assertNotNull(nextMessage);
assertTrue(nextMessage.getPayload().getValue() instanceof List<?>);
List<InternalMessage> payload = (List<InternalMessage>) nextMessage.getPayload().getValue();
assertEquals(1, payload.size());
assertEquals("test event A", payload.get(0).getPayload().getValue());
}
use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class SplitAggregateScopeTestCase method failingExpression.
@Test
@DescriptorKey("An invalid collection expression result in a ExpressionRuntimeException")
public void failingExpression() throws Exception {
SensingNullMessageProcessor nullMessageProcessor = new SensingNullMessageProcessor();
router.setMessageProcessors(singletonList(nullMessageProcessor));
router.setCollectionExpression("!@INVALID");
muleContext.getInjector().inject(router);
router.setAnnotations(getAppleFlowComponentLocationAnnotations());
router.initialise();
expectedException.expect(MessagingException.class);
expectedException.expectCause(instanceOf(ExpressionRuntimeException.class));
router.process(testEvent());
}
Aggregations