Package com.openshift.client.fakes

Examples of com.openshift.client.fakes.OpenShiftConfigurationFake


  @Before
  public void setUp() throws Exception {
    this.serverFake = startHttpServerFake(null);
    this.httpsServerFake = startHttpsServerFake(null);
    this.configuration = new OpenShiftConfigurationFake("10000","10000","10000",null);
    this.httpClient = new UrlConnectionHttpClientBuilder()
        .setAcceptMediaType(ACCEPT_APPLICATION_JSON)
        .setUserAgent("com.openshift.client.test")
        .setConfigTimeout(configuration.getTimeout())
        .client();
View Full Code Here


  @Test
  public void shouldRespectDefaultTimeout() throws Throwable {
    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 10000;
    IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,null,null,"5000");
    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

  @Test
  public void shouldRespectSystemConfigurationTimeoutOverridingDefaultTimeout() throws Throwable {
    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 15;
    IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,null,"2000","1000");
    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

  @Test
  public void shouldRespectUserConfigurationTimeoutOverridingSystemConfigurationTimeout() throws Throwable {
    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 15;
    IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,"3000","2000","1000");
    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

  @Test
  public void shouldRespectSystemPropertiesTimeoutOverridingUserConfigurationTimeout() throws Throwable {
    // pre-conditions
    final int timeout = 1000;
    final int serverDelay = timeout * 15;
    IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake("4000","3000","2000","1000");
    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

TOP

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

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.