Examples of IHttpClient


Examples of com.openshift.client.IHttpClient

  }

  @Test
  public void testUpdateAdditionalGearStorage() throws Exception {
    HttpClientMockDirector builder = new HttpClientMockDirector();
    IHttpClient httpClient = builder
        .mockGetDomains(GET_DOMAINS)
        .mockGetApplications(
            "foobarz", GET_DOMAINS_FOOBARZ_APPLICATIONS_3EMBEDDED)
        .client();
    IUser user = new TestConnectionBuilder().defaultCredentials().create(httpClient).getUser();
View Full Code Here

Examples of com.openshift.client.IHttpClient

  }

  @Test(expected = HttpClientException.class)
  public void shouldThrowIfNoAcceptedMediaType() throws SocketTimeoutException, HttpClientException,
      MalformedURLException {
    IHttpClient client = new UrlConnectionHttpClient(
        "username", "password", "useragent", null, "42.0");
    client.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
  }
View Full Code Here

Examples of com.openshift.client.IHttpClient

   *
   * @see HttpsServerFake
   */
  @Test
  public void shouldSucceedHttpsSelfsignedCertificate() throws Throwable {
    IHttpClient client = new UrlConnectionHttpClientBuilder()
    .setAcceptMediaType(ACCEPT_APPLICATION_JSON)
    .setUserAgent("com.openshift.client.test")
    .setSSLCertificateCallback(new ISSLCertificateCallback() {
     
      @Override
      public boolean allowHostname(String hostname, SSLSession session) {
        return true;
      }
     
      @Override
      public boolean allowCertificate(X509Certificate[] chain) {
        return true;
      }
    })
    .client();
    client.get(httpsServerFake.getUrl(), IHttpClient.NO_TIMEOUT);
  }
View Full Code Here

Examples of com.openshift.client.IHttpClient

  @Test
  public void shouldFailHttpsSelfsignedCertificate() throws Throwable {
    // pre-condition
    expectedException.expect(new ExceptionCauseMatcher(instanceOf(SSLHandshakeException.class)));

    IHttpClient client = new UrlConnectionHttpClientBuilder()
    .setAcceptMediaType(ACCEPT_APPLICATION_JSON)
    .setUserAgent("com.openshift.client.test")
    .setSSLCertificateCallback(new ISSLCertificateCallback() {

      @Override
      public boolean allowHostname(String hostname, SSLSession session) {
        return true;
      }

      @Override
      public boolean allowCertificate(X509Certificate[] chain) {
        return false;
      }
    })
    .client();

    // operation
    client.get(httpsServerFake.getUrl(), IHttpClient.NO_TIMEOUT);
  }
View Full Code Here

Examples of com.openshift.client.IHttpClient

 
  @Test
  public void canAddAuthorization() throws SocketTimeoutException, HttpClientException, MalformedURLException {
    String username = "andre.dietisheim@redhat.com";
    String password = "dummyPassword";
    IHttpClient httpClient = new UrlConnectionHttpClientBuilder()
        .setAcceptMediaType(ACCEPT_APPLICATION_JSON)
        .setUserAgent("com.openshift.client.test")
        .setCredentials(username, password)
        .client();

    String response = httpClient.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
    assertNotNull(response);
    Matcher matcher = AUTHORIZATION_PATTERN.matcher(response);
    assertTrue(matcher.find());
    assertEquals(1, matcher.groupCount());
    String credentials = matcher.group(1);
View Full Code Here

Examples of com.openshift.client.IHttpClient

  @Test
  public void shouldEncodeParametersCorrectly() throws HttpClientException, FileNotFoundException, IOException,
      OpenShiftException {
    // pre-conditions
    IHttpClient httpClient = new PayLoadReturningHttpClientFake(IHttpClient.MEDIATYPE_APPLICATION_JSON, "1.0");
    // operation
    String response = httpClient.post(serverFake.getUrl(),
        new FormUrlEncodedMediaType(),
        IHttpClient.NO_TIMEOUT,
        new StringParameter("adietish", "redhat"),
        new StringParameter("xcoulon", "redhat"));
View Full Code Here

Examples of com.openshift.client.IHttpClient

  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)
View Full Code Here

Examples of com.openshift.client.IHttpClient

  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)
View Full Code Here

Examples of com.openshift.client.IHttpClient

  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)
View Full Code Here

Examples of com.openshift.client.IHttpClient

  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)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.