private void verifyAppProcessMessageWithAppClassLoader(FakeMuleServer fakeMuleServer, String appName, String requestUrl) throws MuleException
{
MuleContext applicationContext = fakeMuleServer.findApplication(appName).getMuleContext();
final AtomicReference<ClassLoader> executionClassLoader = new AtomicReference<ClassLoader>();
FlowExecutionListener flowExecutionListener = new FlowExecutionListener(applicationContext);
flowExecutionListener.addListener(new Callback<MuleEvent>()
{
@Override
public void execute(MuleEvent source)
{
executionClassLoader.set(Thread.currentThread().getContextClassLoader());
}
});
applicationContext.getClient().send(String.format(requestUrl, dynamicPort.getNumber()), "test-data", null);
flowExecutionListener.waitUntilFlowIsComplete();
assertThat(executionClassLoader.get(), Is.is(applicationContext.getExecutionClassLoader()));
}