Search in sources :

Example 1 with IOperationListener

use of org.eclipse.wst.server.core.IServer.IOperationListener in project sling by apache.

the class SlingWstServer method waitForServerToStart.

public void waitForServerToStart(long duration, TimeUnit timeUnit) throws InterruptedException {
    final CountDownLatch startLatch = new CountDownLatch(1);
    final IStatus[] statusHolder = new IStatus[1];
    server.start(ILaunchManager.RUN_MODE, new IOperationListener() {

        @Override
        public void done(IStatus result) {
            statusHolder[0] = result;
            startLatch.countDown();
        }
    });
    boolean success = startLatch.await(duration, timeUnit);
    assertThat("Server did not start in " + duration + " " + timeUnit, success, equalTo(true));
    assertThat("Unexpected IStatus when starting server", statusHolder[0], IStatusIsOk.isOk());
}
Also used : IOperationListener(org.eclipse.wst.server.core.IServer.IOperationListener) IStatus(org.eclipse.core.runtime.IStatus) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 IStatus (org.eclipse.core.runtime.IStatus)1 IOperationListener (org.eclipse.wst.server.core.IServer.IOperationListener)1