Package com.openshift.client.fakes

Examples of com.openshift.client.fakes.WaitingHttpServerFake


  public void shouldRespectGivenTimeoutPOST() throws Throwable {
    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 4;
    assertThat(timeout).isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.post(serverFake.getUrl(), new FormUrlEncodedMediaType(), timeout);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime).isGreaterThan(timeout)
          .isLessThan(serverDelay)
          .isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    } finally {
      serverFake.stop();
    }
  }
View Full Code Here


  public void shouldRespectGivenTimeoutDELETE() throws Throwable {
    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 4;
    assertThat(timeout).isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.delete(serverFake.getUrl(), timeout);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime).isGreaterThan(timeout)
          .isLessThan(serverDelay)
          .isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    } finally {
      serverFake.stop();
    }
  }
View Full Code Here

  public void shouldRespectGivenTimeoutPUT() throws Throwable {
    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 4;
    assertThat(timeout).isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.put(serverFake.getUrl(), new FormUrlEncodedMediaType(), timeout);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime).isGreaterThan(timeout)
          .isLessThan(serverDelay)
          .isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    } finally {
      serverFake.stop();
    }
  }
View Full Code Here

  public void shouldRespectGivenTimeoutGET() throws Throwable {
    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 4;
    assertThat(timeout).isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    WaitingHttpServerFake serverFake = this.startWaitingHttpServerFake(serverDelay);

    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.get(serverFake.getUrl(), timeout);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime).isGreaterThan(timeout)
          .isLessThan(serverDelay)
          .isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    } finally {
      serverFake.stop();
    }
  }
View Full Code Here

    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 15;
    assertThat(timeout).isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    System.setProperty(IHttpClient.SYSPROP_OPENSHIFT_READ_TIMEOUT, String.valueOf(timeout));
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime).isGreaterThan(timeout)
          .isLessThan(serverDelay)
          .isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    } finally {
      serverFake.stop();
      System.clearProperty(IHttpClient.SYSPROP_OPENSHIFT_READ_TIMEOUT);
    }
  }
View Full Code Here

    IHttpClient httpClient = new UrlConnectionHttpClientBuilder()
        .setAcceptMediaType(ACCEPT_APPLICATION_JSON)
        .setUserAgent("com.openshift.client.test")
        .setConfigTimeout(configuration.getTimeout())
        .client();
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime)
          .isGreaterThan(configuration.getTimeout() - 20)
          .isLessThan(configuration.getTimeout() + 20);
    } finally {
      serverFake.stop();
    }
  }
View Full Code Here

    IHttpClient httpClient = new UrlConnectionHttpClientBuilder()
        .setAcceptMediaType(ACCEPT_APPLICATION_JSON)
        .setUserAgent("com.openshift.client.test")
        .setConfigTimeout(configuration.getTimeout())
        .client();
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime)
          .isGreaterThan(configuration.getTimeout() - 20)
          .isLessThan(configuration.getTimeout() + 20);
    } finally {
      serverFake.stop();
    }
  }
View Full Code Here

    IHttpClient httpClient = new UrlConnectionHttpClientBuilder()
        .setAcceptMediaType(ACCEPT_APPLICATION_JSON)
        .setUserAgent("com.openshift.client.test")
        .setConfigTimeout(configuration.getTimeout())
        .client();
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime)
          .isGreaterThan(configuration.getTimeout() - 20)
          .isLessThan(configuration.getTimeout() + 20);
    } finally {
      serverFake.stop();
    }
  }
View Full Code Here

    IHttpClient httpClient = new UrlConnectionHttpClientBuilder()
        .setAcceptMediaType(ACCEPT_APPLICATION_JSON)
        .setUserAgent("com.openshift.client.test")
        .setConfigTimeout(configuration.getTimeout())
        .client();
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime)
          .isGreaterThan(configuration.getTimeout() - 20)
          .isLessThan(configuration.getTimeout() + 20);
    } finally {
      serverFake.stop();
    }
  }
View Full Code Here

    final int timeout = 1000;
    final int serverDelay = timeout * 15;
    System.clearProperty(IHttpClient.SYSPROP_OPENSHIFT_READ_TIMEOUT);
    String timeoutBackup = System.getProperty(IHttpClient.SYSPROP_DEFAULT_READ_TIMEOUT);
    System.setProperty(IHttpClient.SYSPROP_DEFAULT_READ_TIMEOUT, String.valueOf(timeout));
    WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
    long startTime = System.currentTimeMillis();
    // operations
    try {
      httpClient.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
      fail("Timeout expected.");
    } catch (SocketTimeoutException e) {
      // assert
      assertThat(System.currentTimeMillis() - startTime).isGreaterThan(timeout)
          .isLessThan(serverDelay)
          .isLessThan(IHttpClient.DEFAULT_READ_TIMEOUT);
    } finally {
      serverFake.stop();
      restoreSystemProperty(IHttpClient.SYSPROP_DEFAULT_READ_TIMEOUT, timeoutBackup);
    }
  }
View Full Code Here

TOP

Related Classes of com.openshift.client.fakes.WaitingHttpServerFake

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.