mockserver-client-java/src/main/java/org/mockserver/client/MockServerClient.java
public boolean hasStarted(int attempts, long timeout, TimeUnit timeUnit) {
        try {
            HttpResponse httpResponse = sendRequest(request().withMethod("PUT").withPath(calculatePath("status")));
            if (httpResponse.getStatusCode() == HttpStatusCode.OK_200.code()) {
                return true;
            } else if (attempts <= 0) {
                return false;
            } else {
                try {
                    timeUnit.sleep(timeout);
                } catch (InterruptedException e) {
                    // ignore interrupted exception
                }
                return hasStarted(attempts - 1, timeout, timeUnit);
            }
        } catch (SocketConnectionException | IllegalStateException sce) {
            if (attempts <= 0) {
                MOCK_SERVER_LOGGER.logEvent(
                    new LogEntry()
                        .setLogLevel(DEBUG)
                        .setMessageFormat("exception while checking if MockServer has started - " + sce.getMessage())
                        .setThrowable(sce)
                );
                return false;
            } else {
                try {
                    timeUnit.sleep(timeout);
                } catch (InterruptedException e) {
                    // ignore interrupted exception
                }
                return hasStarted(attempts - 1, timeout, timeUnit);
            }
        }
    }
/**
     * Returns whether server MockServer has started, by polling the MockServer a configurable amount of times
     */
Returns whether server MockServer has started, by polling the MockServer a configurable amount of times
Returns whether server MockServer has started by polling the MockServer a configurable amount of times
public boolean hasStarted(int attempts, long timeout, TimeUnit timeUnit) {
        try {
            HttpResponse httpResponse = sendRequest(request().withMethod("PUT").withPath(calculatePath("status")));
            if (httpResponse.getStatusCode() == HttpStatusCode.OK_200.code()) {
                return true;
            } else if (attempts <= 0) {
                return false;
            } else {
                try {
                    timeUnit.sleep(timeout);
                } catch (InterruptedException e) {
                }
                return hasStarted(attempts - 1, timeout, timeUnit);
            }
        } catch (SocketConnectionException | IllegalStateException sce) {
            if (attempts <= 0) {
                MOCK_SERVER_LOGGER.logEvent(
                    new LogEntry()
                        .setLogLevel(DEBUG)
                        .setMessageFormat("exception while checking if MockServer has started - " + sce.getMessage())
                        .setThrowable(sce)
                );
                return false;
            } else {
                try {
                    timeUnit.sleep(timeout);
                } catch (InterruptedException e) {
                }
                return hasStarted(attempts - 1, timeout, timeUnit);
            }
        }
    }
public boolean hasStarted ( int attempts , long timeout , TimeUnit timeUnit ) { try { HttpResponse httpResponse = sendRequest ( request ( ) . withMethod ( "PUT" ) . withPath ( calculatePath ( "status" ) ) ) ; if ( httpResponse . getStatusCode ( ) == HttpStatusCode . OK_200 . code ( ) ) { return true ; } else if ( attempts <= 0 ) { return false ; } else { try { timeUnit . sleep ( timeout ) ; } catch ( InterruptedException e ) { } return hasStarted ( attempts - 1 , timeout , timeUnit ) ; } } catch ( SocketConnectionException | IllegalStateException sce ) { if ( attempts <= 0 ) { MOCK_SERVER_LOGGER . logEvent ( new LogEntry ( ) . setLogLevel ( DEBUG ) . setMessageFormat ( "exception while checking if MockServer has started - " + sce . getMessage ( ) ) . setThrowable ( sce ) ) ; return false ; } else { try { timeUnit . sleep ( timeout ) ; } catch ( InterruptedException e ) { } return hasStarted ( attempts - 1 , timeout , timeUnit ) ; } } }
Returns whether server MockServer has started, by polling the MockServer a configurable amount of times
Returns whether server MockServer has started by polling the MockServer a configurable amount of times
// ignore interrupted exception // ignore interrupted exception