* MuleSession is not copied when async intercepting processor is used
*/
@Test
public void asyncInterceptingProcessorSessionPropertyPropagation() throws Exception
{
AsyncInterceptingMessageProcessor async = new AsyncInterceptingMessageProcessor(
muleContext.getDefaultThreadingProfile(), "async", 0);
SensingNullMessageProcessor asyncListener = new SensingNullMessageProcessor();
async.setListener(asyncListener);
async.start();
MuleMessage message = new DefaultMuleMessage("data", muleContext);
MuleEvent event = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, getTestService());
event.getSession().setProperty("key", "value");
async.process(event);
asyncListener.latch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS);
MuleEvent asyncEvent = asyncListener.event;
// Event is copied, but session isn't
assertNotSame(asyncEvent, event);
assertNotSame(asyncEvent, event);
assertNotSame(asyncEvent.getSession(), event.getSession());
// Session properties available before async are available after too
assertEquals(1, asyncEvent.getSession().getPropertyNamesAsSet().size());
assertEquals("value", asyncEvent.getSession().getProperty("key"));
// Session properties set after async are available in message processor
// before async
asyncEvent.getSession().setProperty("newKey", "newValue");
assertEquals(2, asyncEvent.getSession().getPropertyNamesAsSet().size());
assertEquals("newValue", asyncEvent.getSession().getProperty("newKey"));
assertEquals(1, event.getSession().getPropertyNamesAsSet().size());
assertNull(event.getSession().getProperty("newKey"));
async.stop();
}