I often have a requirement to wait some async process is finished in my devKit connector (which then causes isConnected to return true )
@ValidateConnection
public boolean isConnected() {
return isConnected;
}
How can I get my functional unit test to wait until this is completed. I would have thought the unit test would have waited until all the connectors in my flow were "connected".
Atm I am using a sleep in the unit test to get round this in my FunctionalTestCase
Thread.sleep(5000);
assertEquals(1, targetEngineApplication.getNumberOfMessagesReveived());
Edit_____________________
the connect code:
@Connect
public void connectMethod(final String configFileLocation) throws ConnectionException {
System.out.println("Connect called with config:" + configFileLocation);
try {
Engine.doInitialise(configFileLocation);
Engine.doStart();
} catch (InitialisationException e) {
throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, "0", e.getCause().getMessage(), e);
} catch (StartingException e) {
throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, "0", e.getCause().getMessage(), e);
}
// this will also tell the unit tests to start
isConnected = true;
}