@Override public boolean waitForReady(int timeoutMs) { return CommonUtils.waitFor(this + " to start", input -> { if (mWebServer == null || !mWebServer.getServer().isRunning()) { return false; } HttpClient client = HttpClientBuilder.create().build(); HttpPost method = new HttpPost(String .format("http://%s:%d%s/%s///%s", mWebServer.getBindHost(), mWebServer.getLocalPort(), Constants.REST_API_PREFIX, PathsRestServiceHandler.SERVICE_PREFIX, PathsRestServiceHandler.EXISTS)); try { HttpResponse response = client.execute(method); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { return true; } LOG.debug(IOUtils.toString(response.getEntity().getContent())); return false; } catch (IOException e) { LOG.debug("Exception: ", e); return false; } }, WaitForOptions.defaults().setTimeoutMs(timeoutMs).setThrowOnTimeout(false)); }
/** * @return the default instance of {@link WaitForOptions} */ public static WaitForOptions defaults() { return new WaitForOptions().setInterval(DEFAULT_INTERVAL).setTimeoutMs(NEVER) .setThrowOnTimeout(true); }
@Override public boolean waitForReady(int timeoutMs) { return CommonUtils.waitFor(this + " to start", input -> mStopped == false, WaitForOptions.defaults().setTimeoutMs(timeoutMs).setThrowOnTimeout(false)); } }
@Override public boolean waitForReady(int timeoutMs) { return CommonUtils.waitFor(this + " to start", input -> (mServingThread == null || isServing()), WaitForOptions.defaults().setTimeoutMs(timeoutMs).setThrowOnTimeout(false)); } }
@Override public boolean waitForReady(int timeoutMs) { return CommonUtils.waitFor(this + " to start", input -> mThriftServer != null && mThriftServer.isServing() && mWebServer != null && mWebServer.getServer().isRunning(), WaitForOptions.defaults().setTimeoutMs(timeoutMs).setThrowOnTimeout(false)); }