Search in sources :

Example 86 with HttpClientOptions

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

the class TestVertxTLSBuilder method testbuildClientOptionsBaseSTORE_PKCS12.

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

        @Mock
        public String getTrustStoreType() {
            return "PKCS12";
        }
    };
    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 87 with HttpClientOptions

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

the class TestServiceRegistryClientImpl method testPrivateMethodCreateHttpClientOptions.

@Test
public void testPrivateMethodCreateHttpClientOptions() {
    MicroserviceFactory microserviceFactory = new MicroserviceFactory();
    Microservice microservice = microserviceFactory.create("app", "ms");
    oClient.registerMicroservice(microservice);
    oClient.registerMicroserviceInstance(microservice.getInstance());
    new MockUp<ServiceRegistryConfig>() {

        @Mock
        public HttpVersion getHttpVersion() {
            return HttpVersion.HTTP_2;
        }

        @Mock
        public boolean isSsl() {
            return true;
        }
    };
    try {
        oClient.init();
        HttpClientOptions httpClientOptions = Deencapsulation.invoke(oClient, "createHttpClientOptions");
        Assert.assertNotNull(httpClientOptions);
        Assert.assertEquals(80, httpClientOptions.getDefaultPort());
    } catch (Exception e) {
        Assert.assertNotNull(e);
    }
}
Also used : Microservice(org.apache.servicecomb.serviceregistry.api.registry.Microservice) MockUp(mockit.MockUp) MicroserviceFactory(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceFactory) HttpClientOptions(io.vertx.core.http.HttpClientOptions) ClientException(org.apache.servicecomb.serviceregistry.client.ClientException) Test(org.junit.Test)

Example 88 with HttpClientOptions

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

the class TestRestTransportClient method testCreateHttpClientOptions.

@Test
public void testCreateHttpClientOptions() {
    HttpClientOptions obj = (HttpClientOptions) Deencapsulation.invoke(instance, "createHttpClientOptions");
    Assert.assertNotNull(obj);
}
Also used : HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 89 with HttpClientOptions

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

the class RestTransportClient method createHttpClientOptions.

private static HttpClientOptions createHttpClientOptions() {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    httpClientOptions.setMaxPoolSize(TransportClientConfig.getConnectionMaxPoolSize());
    httpClientOptions.setIdleTimeout(TransportClientConfig.getConnectionIdleTimeoutInSeconds());
    httpClientOptions.setKeepAlive(TransportClientConfig.getConnectionKeepAlive());
    httpClientOptions.setTryUseCompression(TransportClientConfig.getConnectionCompression());
    VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
    return httpClientOptions;
}
Also used : HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 90 with HttpClientOptions

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

the class ConfigCenterClient method deployConfigClient.

private void deployConfigClient() throws InterruptedException {
    VertxOptions vertxOptions = new VertxOptions();
    vertxOptions.setAddressResolverOptions(AddressResolverConfig.getAddressResover(SSL_KEY, ConfigCenterConfig.INSTANCE.getConcurrentCompositeConfiguration()));
    Vertx vertx = VertxUtils.getOrCreateVertxByName("config-center", vertxOptions);
    HttpClientOptions httpClientOptions = createHttpClientOptions();
    clientMgr = new ClientPoolManager<>(vertx, new HttpClientPoolFactory(httpClientOptions));
    DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr, 1);
    VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions);
}
Also used : HttpClientPoolFactory(org.apache.servicecomb.foundation.vertx.client.http.HttpClientPoolFactory) DeploymentOptions(io.vertx.core.DeploymentOptions) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) 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