Search in sources :

Example 1 with Http2ServerConnection

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

the class Http2Test method testDiscardConnectionWhenChannelBecomesInactive.

@Test
public void testDiscardConnectionWhenChannelBecomesInactive() throws Exception {
    AtomicInteger count = new AtomicInteger();
    server.requestHandler(req -> {
        if (count.getAndIncrement() == 0) {
            Http2ServerConnection a = (Http2ServerConnection) req.connection();
            DuplexChannel channel = (DuplexChannel) a.channel();
            channel.shutdown();
        } else {
            req.response().end();
        }
    });
    startServer(testAddress);
    AtomicInteger closed = new AtomicInteger();
    client.connectionHandler(conn -> conn.closeHandler(v -> closed.incrementAndGet()));
    client.request(requestOptions).onComplete(onSuccess(req -> {
        req.send(onFailure(err -> {
        }));
    }));
    AsyncTestBase.assertWaitUntil(() -> closed.get() == 1);
    client.request(requestOptions).compose(HttpClientRequest::send).onComplete(onSuccess(resp -> {
        testComplete();
    }));
    await();
}
Also used : java.util(java.util) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) ConnectionBase(io.vertx.core.net.impl.ConnectionBase) Context(io.vertx.core.Context) PfxOptions(io.vertx.core.net.PfxOptions) BooleanSupplier(java.util.function.BooleanSupplier) OpenSSLEngineOptions(io.vertx.core.net.OpenSSLEngineOptions) ChannelPromise(io.netty.channel.ChannelPromise) TestUtils(io.vertx.test.core.TestUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DuplexChannel(io.netty.channel.socket.DuplexChannel) Http2ServerConnection(io.vertx.core.http.impl.Http2ServerConnection) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) Promise(io.vertx.core.Promise) TooLongFrameException(io.netty.handler.codec.TooLongFrameException) Test(org.junit.Test) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) Channel(io.netty.channel.Channel) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Repeat(io.vertx.test.core.Repeat) Stream(java.util.stream.Stream) Buffer(io.vertx.core.buffer.Buffer) Ignore(org.junit.Ignore) AsyncTestBase(io.vertx.test.core.AsyncTestBase) Cert(io.vertx.test.tls.Cert) Http2CodecUtil(io.netty.handler.codec.http2.Http2CodecUtil) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DuplexChannel(io.netty.channel.socket.DuplexChannel) Http2ServerConnection(io.vertx.core.http.impl.Http2ServerConnection) Test(org.junit.Test)

Aggregations

Channel (io.netty.channel.Channel)1 ChannelPromise (io.netty.channel.ChannelPromise)1 DuplexChannel (io.netty.channel.socket.DuplexChannel)1 TooLongFrameException (io.netty.handler.codec.TooLongFrameException)1 Http2CodecUtil (io.netty.handler.codec.http2.Http2CodecUtil)1 Context (io.vertx.core.Context)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 Buffer (io.vertx.core.buffer.Buffer)1 Http2ServerConnection (io.vertx.core.http.impl.Http2ServerConnection)1 OpenSSLEngineOptions (io.vertx.core.net.OpenSSLEngineOptions)1 PfxOptions (io.vertx.core.net.PfxOptions)1 ConnectionBase (io.vertx.core.net.impl.ConnectionBase)1 AsyncTestBase (io.vertx.test.core.AsyncTestBase)1 Repeat (io.vertx.test.core.Repeat)1 TestUtils (io.vertx.test.core.TestUtils)1 Cert (io.vertx.test.tls.Cert)1 java.util (java.util)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CountDownLatch (java.util.concurrent.CountDownLatch)1