Search in sources :

Example 11 with HttpServerOptions

use of io.vertx.core.http.HttpServerOptions in project java-chassis by ServiceComb.

the class TestVertxTLSBuilder method testbuildHttpServerOptionsRequest.

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

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

Example 12 with HttpServerOptions

use of io.vertx.core.http.HttpServerOptions in project java-chassis by ServiceComb.

the class TestVertxTLSBuilder method testbuildHttpServerOptions.

@Test
public void testbuildHttpServerOptions() {
    SSLOption option = SSLOption.buildFromYaml("rest.provider");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpServerOptions serverOptions = new HttpServerOptions();
    VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
Also used : HttpServerOptions(io.vertx.core.http.HttpServerOptions) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom) Test(org.junit.Test)

Example 13 with HttpServerOptions

use of io.vertx.core.http.HttpServerOptions in project java-chassis by ServiceComb.

the class RestServerVerticle method createDefaultHttpServerOptions.

private HttpServerOptions createDefaultHttpServerOptions() {
    HttpServerOptions serverOptions = new HttpServerOptions();
    serverOptions.setAcceptBacklog(ACCEPT_BACKLOG);
    serverOptions.setSendBufferSize(SEND_BUFFER_SIZE);
    serverOptions.setReceiveBufferSize(RECEIVE_BUFFER_SIZE);
    serverOptions.setUsePooledBuffers(true);
    if (endpointObject.isSslEnabled()) {
        SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
        SSLOption sslOption;
        if (factory == null) {
            sslOption = SSLOption.buildFromYaml(SSL_KEY);
        } else {
            sslOption = factory.createSSLOption();
        }
        SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
        VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions);
    }
    return serverOptions;
}
Also used : SSLOptionFactory(io.servicecomb.foundation.ssl.SSLOptionFactory) HttpServerOptions(io.vertx.core.http.HttpServerOptions) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom)

Example 14 with HttpServerOptions

use of io.vertx.core.http.HttpServerOptions in project vert.x by eclipse.

the class DummyMetricsTest method testDummyHttpServerMetrics.

@Test
public void testDummyHttpServerMetrics() {
    HttpServer server = vertx.createHttpServer(new HttpServerOptions());
    assertFalse(server.isMetricsEnabled());
}
Also used : HttpServer(io.vertx.core.http.HttpServer) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Test(org.junit.Test)

Example 15 with HttpServerOptions

use of io.vertx.core.http.HttpServerOptions in project vert.x by eclipse.

the class NettyCompatTest method testHttp2.

@Test
public void testHttp2() {
    vertx.createHttpServer(new HttpServerOptions().setUseAlpn(true).setSsl(true).setSslEngineOptions(new OpenSSLEngineOptions()).setKeyCertOptions(Cert.SERVER_JKS.get())).requestHandler(req -> req.response().end("OK")).listen(8443, "localhost", onSuccess(s -> {
        HttpClient client = vertx.createHttpClient(new HttpClientOptions().setSsl(true).setSslEngineOptions(new OpenSSLEngineOptions()).setTrustStoreOptions(Trust.SERVER_JKS.get()));
        client.getNow(8443, "localhost", "/somepath", resp -> {
            resp.bodyHandler(buff -> {
                assertEquals("OK", buff.toString());
                testComplete();
            });
        });
    }));
    await();
}
Also used : OpenSSLEngineOptions(io.vertx.core.net.OpenSSLEngineOptions) VertxInternal(io.vertx.core.impl.VertxInternal) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Test(org.junit.Test) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Cert(io.vertx.test.core.tls.Cert) VertxTestBase(io.vertx.test.core.VertxTestBase) HttpClient(io.vertx.core.http.HttpClient) Trust(io.vertx.test.core.tls.Trust) HttpClient(io.vertx.core.http.HttpClient) HttpServerOptions(io.vertx.core.http.HttpServerOptions) OpenSSLEngineOptions(io.vertx.core.net.OpenSSLEngineOptions) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Aggregations

HttpServerOptions (io.vertx.core.http.HttpServerOptions)27 Test (org.junit.Test)20 HttpClientOptions (io.vertx.core.http.HttpClientOptions)11 HttpServer (io.vertx.core.http.HttpServer)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 HttpClient (io.vertx.core.http.HttpClient)8 Buffer (io.vertx.core.buffer.Buffer)7 HttpClientRequest (io.vertx.core.http.HttpClientRequest)7 HttpMethod (io.vertx.core.http.HttpMethod)7 HttpServerResponse (io.vertx.core.http.HttpServerResponse)7 Context (io.vertx.core.Context)6 Vertx (io.vertx.core.Vertx)6 HttpVersion (io.vertx.core.http.HttpVersion)6 NetSocket (io.vertx.core.net.NetSocket)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 Handler (io.vertx.core.Handler)5 MultiMap (io.vertx.core.MultiMap)5 SSLHelper (io.vertx.core.net.impl.SSLHelper)5 AbstractVerticle (io.vertx.core.AbstractVerticle)4