}
private void doTest(String wfClassname, int expectedResult) throws CopperException, InterruptedException {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"transient-engine-application-context.xml", "SimpleTransientEngineTest-application-context.xml"});
TransientScottyEngine engine = context.getBean("transientEngine", TransientScottyEngine.class);
context.getBeanFactory().registerSingleton("OutputChannel4711",new TestResponseReceiver<String, Integer>() {
@Override
public void setResponse(Workflow<String> wf, Integer r) {
synchronized (response) {
response[0] = r.intValue();
response.notifyAll();
}
}
});
assertEquals(EngineState.STARTED,engine.getEngineState());
try {
BlockingResponseReceiver<Integer> brr = new BlockingResponseReceiver<Integer>();
engine.run(wfClassname, brr);
synchronized (response) {
if (response[0] == -1) {
response.wait(30000);
}
}
assertEquals(expectedResult, response[0]);
}
finally {
context.close();
}
assertEquals(EngineState.STOPPED,engine.getEngineState());
}