Package org.sonatype.nexus.component.source.api.http

Examples of org.sonatype.nexus.component.source.api.http.HttpClientConfig


    }
  }

  @Override
  public HttpClientConfig fromMap(final Map<String, Object> config) {
    HttpClientConfig clientConfig = new HttpClientConfig();
    clientConfig.withConnectionConfig(connectionFromMap(config));
    clientConfig.withAuthenticationConfig(authenticationFromMap(config, "http"));
    clientConfig.withProxyConfig(proxyFromMap(config));
    return clientConfig;
  }
View Full Code Here


  /**
   * Verify config marshalling to map.
   */
  @Test
  public void toMap() {
    Map<String, Object> map = new HttpClientConfigMarshallerImpl(authMarshallers).toMap(new HttpClientConfig()
        .withConnectionConfig(new ConnectionConfig()
            .withTimeout(1)
            .withRetries(2)
            .withUrlParameters("params")
            .withUserAgentCustomisation("ua")
View Full Code Here

    map.put("http.proxy.https.authentication.ntlmHost", "ntlmH");
    map.put("http.proxy.https.authentication.ntlmDomain", "ntlmD");

    map.put("http.proxy.nonProxyHosts", "h1,h2");

    HttpClientConfig config = new HttpClientConfigMarshallerImpl(authMarshallers).fromMap(map);

    assertThat(config.getConnectionConfig().getTimeout(), is(1));
    assertThat(config.getConnectionConfig().getRetries(), is(2));
    assertThat(config.getConnectionConfig().getUrlParameters(), is("params"));
    assertThat(config.getConnectionConfig().getUserAgentCustomisation(), is("ua"));
    assertThat(config.getConnectionConfig().getUseTrustStore(), is(true));

    UsernameAuthenticationConfig a1 = (UsernameAuthenticationConfig) config.getAuthenticationConfig();
    assertThat(a1.getUsername(), is("foo"));
    assertThat(a1.getPassword(), is("bar"));

    assertThat(config.getProxyConfig().getHttpProxyConfig().getHostname(), is("httpHost"));
    assertThat(config.getProxyConfig().getHttpProxyConfig().getPort(), is(3));
    UsernameAuthenticationConfig a2 = (UsernameAuthenticationConfig) config.getProxyConfig().getHttpProxyConfig()
        .getAuthenticationConfig();
    assertThat(a2.getUsername(), is("foo1"));
    assertThat(a2.getPassword(), is("bar1"));

    assertThat(config.getProxyConfig().getHttpsProxyConfig().getHostname(), is("httpsHost"));
    assertThat(config.getProxyConfig().getHttpsProxyConfig().getPort(), is(4));
    NtlmAuthenticationConfig a3 = (NtlmAuthenticationConfig) config.getProxyConfig().getHttpsProxyConfig()
        .getAuthenticationConfig();
    assertThat(a3.getUsername(), is("foo2"));
    assertThat(a3.getPassword(), is("bar2"));
    assertThat(a3.getNtlmHost(), is("ntlmH"));
    assertThat(a3.getNtlmDomain(), is("ntlmD"));

    assertThat(config.getProxyConfig().getNonProxyHosts(), is(new String[]{"h1", "h2"}));
  }
View Full Code Here

  public void contributeTo(final ComponentSourceConfigStore store) throws IOException {
    if (store.get(SOURCE_NAME) == null) {
      Map<String, Object> config = Maps.newHashMap();
      config.put(RawComponentSourceFactory.REMOTE_URL_PARAM, "http://search.maven.org/");
      config.putAll(httpClientConfigMarshaller.toMap(
          new HttpClientConfig().withConnectionConfig(new ConnectionConfig()
              .withTimeout(500)
              .withRetries(5)
              .withUserAgentCustomisation("NX3")
          )
      ));
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.component.source.api.http.HttpClientConfig

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.