IOSServerConfiguration config = new IOSServerConfiguration();
config.setPort(4444);
config.setHost("localhost");
Configuration.SIMULATORS_ENABLED = true;
final IOSServerManager mgr = new IOSServerManager(config);
addSafari(mgr, new StringBuilder());
IOSCapabilities saf = IOSCapabilities.iphone("Safari");
ServerSideSession session = mgr.createSession(saf);
Assert.assertEquals(mgr.getSessions().size(), 1);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
mgr.stopGracefully();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
t.start();
mgr.waitForState(IOSServerManager.State.stopping);
ServerSideSession session2 = mgr.createSession(saf);
Assert.assertNull(session2);
mgr.registerSessionHasStop(session);
Assert.assertEquals(mgr.getSessions().size(), 0);
while (mgr.isRunning()) {
Thread.sleep(250);
}
t.join();
}