message1.setCorrelationId(correlationId);
message2.setCorrelationId(correlationId);
message3.setCorrelationId(correlationId);
InboundEndpoint endpoint = MuleTestUtils.getTestInboundEndpoint(MessageExchangePattern.ONE_WAY, muleContext);
MuleEvent event1 = new DefaultMuleEvent(message1, endpoint, session);
MuleEvent event2 = new DefaultMuleEvent(message2, endpoint, session);
MuleEvent event3 = new DefaultMuleEvent(message3, endpoint, session);
assertNull(router.process(event2));
assertNull(router.process(event3));
MuleEvent resultEvent = router.process(event1);
assertNotNull(resultEvent);
MuleMessage resultMessage = resultEvent.getMessage();
assertNotNull(resultMessage);
assertEquals("test event A", resultMessage.getPayloadAsString());
// set a resequencing comparator. We need to reset the router since it will not process the same event group
//twice
router = new TestEventResequencer(3);
router.setMuleContext(muleContext);
router.setEventComparator(new EventPayloadComparator());
router.setFlowConstruct(testService);
router.initialise();
assertNull(router.process(event2));
assertNull(router.process(event3));
resultEvent = router.process(event1);
assertNotNull(resultEvent);
resultMessage = resultEvent.getMessage();
assertNotNull(resultMessage);
assertEquals("test event C", resultMessage.getPayloadAsString());
}