use of org.mule.runtime.core.privileged.routing.CompositeRoutingException in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method errorDelayed.
@Test
@Description("When an error occurs all routes are executed regardless and a CompositeRoutingException is thrown containing a RoutingResult with details of both failures and successes.")
public void errorDelayed() throws Throwable {
Processor processorSpy = createProcessorSpy(testEvent().getMessage());
RuntimeException exception1 = new IllegalStateException();
RoutingPair failingPair1 = of(testEvent(), createFailingRoutingPair(exception1));
RuntimeException exception2 = new UnsupportedOperationException();
RoutingPair failingPair2 = of(testEvent(), createFailingRoutingPair(exception2));
RuntimeException exception3 = new IndexOutOfBoundsException();
RoutingPair failingPair3 = of(testEvent(), createFailingRoutingPair(exception3));
RoutingPair okPair = of(testEvent(), createChain(processorSpy));
expectedException.expect(instanceOf(CompositeRoutingException.class));
invokeStrategyBlocking(strategy, testEvent(), asList(failingPair1, failingPair2, failingPair3, okPair), throwable -> {
verify(processorSpy, times(1)).process(any(CoreEvent.class));
CompositeRoutingException compositeRoutingException = assertCompositeRoutingException(throwable, 3);
RoutingResult routingResult = assertRoutingResult(compositeRoutingException, 1, 3);
assertThat(routingResult.getFailures().get("0").getCause(), is(exception1));
assertThat(routingResult.getFailures().get("1").getCause(), is(exception2));
assertThat(routingResult.getFailures().get("2").getCause(), is(exception3));
assertThat(routingResult.getFailures().get("3"), is(nullValue()));
});
}
use of org.mule.runtime.core.privileged.routing.CompositeRoutingException in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method error.
@Test
@Description("Errors are thrown via CompositeRoutingException with RoutingResult containing details of failures.")
public void error() throws Throwable {
RuntimeException exception = new IllegalStateException();
RoutingPair failingPair = of(testEvent(), createFailingRoutingPair(exception));
expectedException.expect(instanceOf(CompositeRoutingException.class));
invokeStrategyBlocking(strategy, testEvent(), asList(failingPair), throwable -> {
CompositeRoutingException compositeRoutingException = assertCompositeRoutingException(throwable, 1);
RoutingResult routingResult = assertRoutingResult(compositeRoutingException, 0, 1);
assertThat(routingResult.getFailures().get("0").getCause(), is(exception));
});
}
use of org.mule.runtime.core.privileged.routing.CompositeRoutingException in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method timeout.
@Test
@Description("When a route timeout occurs a CompositeRoutingException is thrown with details of timeout error in RoutingResult.")
public void timeout() throws Throwable {
strategy = createStrategy(processingStrategy, 1, true, 50);
expectedException.expect(instanceOf(CompositeRoutingException.class));
invokeStrategyBlocking(strategy, testEvent(), asList(createRoutingPairWithSleep(of(1), 250)), throwable -> {
CompositeRoutingException compositeRoutingException = assertCompositeRoutingException(throwable, 1);
RoutingResult routingResult = assertRoutingResult(compositeRoutingException, 0, 1);
assertThat(routingResult.getFailures().get("0").getCause(), instanceOf(TimeoutException.class));
});
}
use of org.mule.runtime.core.privileged.routing.CompositeRoutingException in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method assertCompositeRoutingException.
private CompositeRoutingException assertCompositeRoutingException(Throwable throwable, int errors) {
assertThat(throwable, instanceOf(CompositeRoutingException.class));
CompositeRoutingException compositeRoutingException = (CompositeRoutingException) throwable;
assertThat(compositeRoutingException.getErrors().size(), is(errors));
return compositeRoutingException;
}
use of org.mule.runtime.core.privileged.routing.CompositeRoutingException in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method timeoutDelayed.
@Test
@Description("When a route timeout occurs all routes are still executed and a CompositeRoutingException is thrown with details of timeout error and successful routes in RoutingResult.")
public void timeoutDelayed() throws Throwable {
strategy = createStrategy(processingStrategy, 1, true, 50);
Message pair2Result = of(2);
Processor pair2Processor = createProcessorSpy(pair2Result);
RoutingPair pair2 = of(testEvent(), createChain(pair2Processor));
expectedException.expect(instanceOf(CompositeRoutingException.class));
invokeStrategyBlocking(strategy, testEvent(), asList(createRoutingPairWithSleep(of(1), 250), pair2), throwable -> {
verify(pair2Processor, times(1)).process(any(CoreEvent.class));
CompositeRoutingException compositeRoutingException = assertCompositeRoutingException(throwable, 1);
RoutingResult routingResult = assertRoutingResult(compositeRoutingException, 1, 1);
assertThat(routingResult.getFailures().get("0").getCause(), instanceOf(TimeoutException.class));
assertThat(routingResult.getResults().get("1"), is(pair2Result));
});
}
Aggregations