use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class UntilSuccessfulTestCase method testPermanentDeliveryFailure.
@Test
public void testPermanentDeliveryFailure() throws Exception {
targetMessageProcessor.setNumberOfFailuresToSimulate(Integer.MAX_VALUE);
untilSuccessful.setMuleContext(muleContext);
untilSuccessful.initialise();
untilSuccessful.start();
final CoreEvent testEvent = eventBuilder(muleContext).message(of("ERROR")).build();
expected.expect(MessagingException.class);
expected.expectCause(instanceOf(RetryPolicyExhaustedException.class));
try {
untilSuccessful.process(testEvent);
} finally {
assertEquals(1 + untilSuccessful.getMaxRetries(), targetMessageProcessor.getEventCount());
}
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class UntilSuccessfulTestCase method testSuccessfulDeliveryStreamPayload.
@Test
public void testSuccessfulDeliveryStreamPayload() throws Exception {
untilSuccessful.setMuleContext(muleContext);
untilSuccessful.initialise();
untilSuccessful.start();
final CoreEvent testEvent = eventBuilder(muleContext).message(of(new ByteArrayInputStream("test_data".getBytes()))).build();
assertSame(testEvent.getMessage(), untilSuccessful.process(testEvent).getMessage());
assertTargetEventReceived(testEvent);
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class EventCorrelatorMemoryLeakTestCase method testEventGroupFreedInRoutingException.
@Test
public void testEventGroupFreedInRoutingException() throws Exception {
CoreEvent event = mock(CoreEvent.class);
try {
eventCorrelator.process(event);
fail("Routing Exception must be catched.");
} catch (RoutingException e) {
assertTrue("Event Group wasn't saved", eventGroupWasSaved);
assertThat(countOfEventGroups, is(0));
}
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method flowVarsMerged.
@Test
@Description("After successful completion of all routes the variables from each route are merged into the result.")
public void flowVarsMerged() throws Throwable {
final String beforeVarName = "before";
final String beforeVarValue = "beforeValue";
final String beforeVar2Name = "before2";
final String beforeVar2Value = "before2Value";
final String beforeVar2NewValue = "before2NewValue";
final String fooVarName = "foo";
final String fooVarValue = "fooValue1";
final String fooVar2Name = "foo2";
final String fooVar2Value1 = "foo2Value1";
final String fooVar2Value2 = "foo2Value2";
final String fooVar3Name = "foo3";
final String fooVar3Value1 = "foo3Value1";
final Apple fooVar3Value2 = new Apple();
CoreEvent original = builder(this.<CoreEvent>newEvent()).addVariable(beforeVarName, beforeVarValue).addVariable(beforeVar2Name, beforeVar2Value).build();
RoutingPair pair1 = of(original, createChain(event -> builder(event).addVariable(beforeVar2Name, beforeVar2NewValue).addVariable(fooVarName, fooVarValue).addVariable(fooVar2Name, fooVar2Value1).addVariable(fooVar3Name, fooVar3Value1).build()));
RoutingPair pair2 = of(original, createChain(event -> builder(event).addVariable(fooVar2Name, fooVar2Value2).addVariable(fooVar3Name, fooVar3Value2).build()));
CoreEvent result = invokeStrategyBlocking(strategy, original, asList(pair1, pair2));
assertThat(result.getVariables().keySet(), hasSize(5));
assertThat(result.getVariables().keySet(), hasItems(beforeVarName, beforeVar2Name, fooVarName, fooVarName, fooVar2Name, fooVar3Name));
assertThat(result.getVariables().get(beforeVarName).getValue(), equalTo(beforeVarValue));
assertThat(result.getVariables().get(beforeVar2Name).getValue(), equalTo(beforeVar2NewValue));
assertThat(result.getVariables().get(fooVarName).getValue(), equalTo(fooVarValue));
TypedValue fooVar2 = result.getVariables().get(fooVar2Name);
assertThat(fooVar2.getDataType(), equalTo(DataType.builder().collectionType(List.class).itemType(String.class).build()));
assertThat(((List<String>) fooVar2.getValue()), hasItems(fooVar2Value1, fooVar2Value2));
TypedValue fooVar3 = result.getVariables().get(fooVar3Name);
assertThat(fooVar3.getDataType(), equalTo(DataType.builder().collectionType(List.class).itemType(Object.class).build()));
assertThat(((List<Object>) fooVar3.getValue()), hasItems(fooVar3Value1, fooVar3Value2));
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class CollectListForkJoinStrategyTestCase method collectList.
@Test
@Description("This strategy waits for all routes to return and then collects results into a list.")
public void collectList() throws Throwable {
CoreEvent original = testEvent();
Message route1Result = of(1);
Message route2Result = of(2);
Message route3Result = of(3);
RoutingPair pair1 = createRoutingPair(route1Result);
RoutingPair pair2 = createRoutingPair(route2Result);
RoutingPair pair3 = createRoutingPair(route3Result);
CoreEvent result = invokeStrategyBlocking(strategy, original, asList(pair1, pair2, pair3));
assertThat(result.getMessage().getPayload().getValue(), instanceOf(List.class));
List<Message> resultList = (List<Message>) result.getMessage().getPayload().getValue();
assertThat(resultList, hasSize(3));
assertThat(resultList, hasItems(route1Result, route2Result, route3Result));
}
Aggregations