Search in sources :

Example 26 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project incubator-servicecomb-java-chassis by apache.

the class TestVertxTLSBuilder method testbuildClientOptionsBaseAuthPeerFalse.

@Test
public void testbuildClientOptionsBaseAuthPeerFalse() {
    SSLOption option = SSLOption.buildFromYaml("rest.consumer");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpClientOptions serverOptions = new HttpClientOptions();
    new MockUp<SSLOption>() {

        @Mock
        public boolean isAuthPeer() {
            return false;
        }
    };
    VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.isTrustAll(), true);
}
Also used : MockUp(mockit.MockUp) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 27 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project incubator-servicecomb-java-chassis by apache.

the class TestVertxTLSBuilder method testbuildClientOptionsBaseSTORE_JKS.

@Test
public void testbuildClientOptionsBaseSTORE_JKS() {
    SSLOption option = SSLOption.buildFromYaml("rest.consumer");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpClientOptions serverOptions = new HttpClientOptions();
    new MockUp<SSLOption>() {

        @Mock
        public String getKeyStoreType() {
            return "JKS";
        }
    };
    VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.isTrustAll(), true);
}
Also used : MockUp(mockit.MockUp) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 28 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project incubator-servicecomb-java-chassis by apache.

the class RestTransportClient method init.

public void init(Vertx vertx) throws Exception {
    HttpClientOptions httpClientOptions = createHttpClientOptions();
    clientMgr = new ClientPoolManager<>(vertx, new HttpClientPoolFactory(httpClientOptions));
    DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr, TransportClientConfig.getThreadCount());
    VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions);
}
Also used : HttpClientPoolFactory(org.apache.servicecomb.foundation.vertx.client.http.HttpClientPoolFactory) DeploymentOptions(io.vertx.core.DeploymentOptions) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 29 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project incubator-servicecomb-java-chassis by apache.

the class ConfigCenterClient method createHttpClientOptions.

private HttpClientOptions createHttpClientOptions() {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    if (ConfigCenterConfig.INSTANCE.isProxyEnable()) {
        ProxyOptions proxy = new ProxyOptions().setHost(ConfigCenterConfig.INSTANCE.getProxyHost()).setPort(ConfigCenterConfig.INSTANCE.getProxyPort()).setUsername(ConfigCenterConfig.INSTANCE.getProxyUsername()).setPassword(ConfigCenterConfig.INSTANCE.getProxyPasswd());
        httpClientOptions.setProxyOptions(proxy);
    }
    httpClientOptions.setConnectTimeout(CONFIG_CENTER_CONFIG.getConnectionTimeout());
    if (this.memberDiscovery.getConfigServer().toLowerCase().startsWith("https")) {
        LOGGER.debug("config center client performs requests over TLS");
        SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, ConfigCenterConfig.INSTANCE.getConcurrentCompositeConfiguration());
        SSLOption sslOption;
        if (factory == null) {
            sslOption = SSLOption.buildFromYaml(SSL_KEY, ConfigCenterConfig.INSTANCE.getConcurrentCompositeConfiguration());
        } else {
            sslOption = factory.createSSLOption();
        }
        SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
        VertxTLSBuilder.buildHttpClientOptions(sslOption, sslCustom, httpClientOptions);
    }
    return httpClientOptions;
}
Also used : ProxyOptions(io.vertx.core.net.ProxyOptions) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 30 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project vertx-web by vert-x3.

the class OpenAPI3RouterFactoryTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    // Have to stop default server of WebTestBase
    stopServer();
    client = vertx.createHttpClient(new HttpClientOptions().setDefaultPort(8080));
}
Also used : HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Aggregations

HttpClientOptions (io.vertx.core.http.HttpClientOptions)101 Test (org.junit.Test)51 HttpClient (io.vertx.core.http.HttpClient)27 HttpClientRequest (io.vertx.core.http.HttpClientRequest)23 HttpServerOptions (io.vertx.core.http.HttpServerOptions)19 CountDownLatch (java.util.concurrent.CountDownLatch)15 HttpMethod (io.vertx.core.http.HttpMethod)14 SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)14 SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)14 HttpVersion (io.vertx.core.http.HttpVersion)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 Vertx (io.vertx.core.Vertx)11 MockUp (mockit.MockUp)11 DeploymentOptions (io.vertx.core.DeploymentOptions)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 Buffer (io.vertx.core.buffer.Buffer)9 HttpServer (io.vertx.core.http.HttpServer)8 HttpServerResponse (io.vertx.core.http.HttpServerResponse)8 VertxOptions (io.vertx.core.VertxOptions)7 VertxInternal (io.vertx.core.impl.VertxInternal)7