use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class AsyncRequestReplyRequesterTestCase method testResponseEventsCleanedUp.
@Test
public void testResponseEventsCleanedUp() throws Exception {
RelaxedAsyncReplyMP mp = new RelaxedAsyncReplyMP(muleContext);
try {
CoreEvent event = eventBuilder(muleContext).message(of("message1")).groupCorrelation(Optional.of(GroupCorrelation.of(0, 3))).build();
SensingNullMessageProcessor listener = getSensingNullMessageProcessor();
mp.setListener(listener);
mp.setReplySource(listener.getMessageSource());
mp.process(event);
Map<String, PrivilegedEvent> responseEvents = mp.getResponseEvents();
assertThat(responseEvents.entrySet(), empty());
} finally {
mp.stop();
}
}
use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class AsyncRequestReplyRequesterTestCase method testSingleEventTimeout.
@Test
public void testSingleEventTimeout() throws Exception {
asyncReplyMP = new TestAsyncRequestReplyRequester(muleContext);
asyncReplyMP.setTimeout(1);
SensingNullMessageProcessor target = getSensingNullMessageProcessor();
target.setWaitTime(30000);
AsyncDelegateMessageProcessor asyncMP = createAsyncMessageProcessor(target);
initialiseIfNeeded(asyncMP, true, muleContext);
asyncMP.start();
asyncReplyMP.setListener(asyncMP);
asyncReplyMP.setReplySource(target.getMessageSource());
asyncReplyMP.setMuleContext(muleContext);
CoreEvent event = eventBuilder(muleContext).message(of(TEST_MESSAGE)).build();
try {
asyncReplyMP.process(event);
fail("ResponseTimeoutException expected");
} catch (Exception e) {
assertThat(e, instanceOf(ResponseTimeoutException.class));
}
}
use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class AsyncRequestReplyRequesterTestCase method testSingleEventNoTimeoutAsync.
@Test
public void testSingleEventNoTimeoutAsync() throws Exception {
asyncReplyMP = new TestAsyncRequestReplyRequester(muleContext);
SensingNullMessageProcessor target = getSensingNullMessageProcessor();
AsyncDelegateMessageProcessor asyncMP = createAsyncMessageProcessor(target);
initialiseIfNeeded(asyncMP, true, muleContext);
asyncMP.start();
asyncReplyMP.setListener(asyncMP);
asyncReplyMP.setReplySource(target.getMessageSource());
asyncReplyMP.setMuleContext(muleContext);
CoreEvent resultEvent = asyncReplyMP.process(testEvent());
// Can't assert same because we copy event for async and also on async reply currently
assertEquals(((PrivilegedEvent) testEvent()).getMessageAsString(muleContext), ((PrivilegedEvent) resultEvent).getMessageAsString(muleContext));
}
use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class DefaultSchedulerMessageSourceTestCase method simplePoll.
@Test
public void simplePoll() throws Exception {
DefaultSchedulerMessageSource schedulerMessageSource = createMessageSource();
SensingNullMessageProcessor flow = getSensingNullMessageProcessor();
schedulerMessageSource.setListener(flow);
schedulerMessageSource.setAnnotations(singletonMap(LOCATION_KEY, TEST_CONNECTOR_LOCATION));
schedulerMessageSource.trigger();
new PollingProber(RECEIVE_TIMEOUT, 100).check(new Probe() {
@Override
public boolean isSatisfied() {
return flow.event != null;
}
@Override
public String describeFailure() {
return "flow event never set by the source flow";
}
});
}
use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.
the class ForeachTestCase method failingNestedProcessorInChain.
@Test
public void failingNestedProcessorInChain() 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);
processInChain(foreach, eventBuilder(muleContext).message(of(new DummyNestedIterableClass().iterator())).build());
} finally {
assertThat(firstProcessor.invocations, equalTo(1));
}
}
Aggregations