Search in sources :

Example 91 with NettyContext

use of reactor.ipc.netty.NettyContext in project reactor-netty by reactor.

the class ChannelOperationsHandlerTest method doTestPublisherSenderOnCompleteFlushInProgress.

private void doTestPublisherSenderOnCompleteFlushInProgress(boolean useScheduler) {
    NettyContext server = HttpServer.create(0).newHandler((req, res) -> req.receive().asString().doOnNext(System.err::println).then(res.status(200).sendHeaders().then())).block(Duration.ofSeconds(30));
    Flux<String> flux = Flux.range(1, 257).map(count -> count + "");
    if (useScheduler) {
        flux.publishOn(Schedulers.single());
    }
    Mono<HttpClientResponse> client = HttpClient.create(server.address().getPort()).post("/", req -> req.sendString(flux));
    StepVerifier.create(client).expectNextMatches(res -> {
        res.dispose();
        return res.status().code() == 200;
    }).expectComplete().verify(Duration.ofSeconds(30));
    server.dispose();
}
Also used : StepVerifier(reactor.test.StepVerifier) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ByteBuffer(java.nio.ByteBuffer) Loggers(reactor.util.Loggers) SocketChannel(java.nio.channels.SocketChannel) Duration(java.time.Duration) Logger(reactor.util.Logger) HttpClient(reactor.ipc.netty.http.client.HttpClient) Schedulers(reactor.core.scheduler.Schedulers) SocketUtils(reactor.ipc.netty.SocketUtils) ExecutorService(java.util.concurrent.ExecutorService) HttpServer(reactor.ipc.netty.http.server.HttpServer) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) FutureMono(reactor.ipc.netty.FutureMono) IOException(java.io.IOException) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) PoolResources(reactor.ipc.netty.resources.PoolResources) InetSocketAddress(java.net.InetSocketAddress) HttpClientResponse(reactor.ipc.netty.http.client.HttpClientResponse) Executors(java.util.concurrent.Executors) ServerSocketChannel(java.nio.channels.ServerSocketChannel) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Flux(reactor.core.publisher.Flux) Ignore(org.junit.Ignore) NettyContext(reactor.ipc.netty.NettyContext) HttpClientResponse(reactor.ipc.netty.http.client.HttpClientResponse) NettyContext(reactor.ipc.netty.NettyContext)

Example 92 with NettyContext

use of reactor.ipc.netty.NettyContext in project spring-cloud-gateway by spring-cloud.

the class ReactorHttpServer method startInternal.

@Override
protected void startInternal() {
    NettyContext nettyContext = this.reactorServer.newHandler(this.reactorHandler).block();
    setPort(nettyContext.address().getPort());
    this.nettyContext.set(nettyContext);
}
Also used : NettyContext(reactor.ipc.netty.NettyContext)

Aggregations

NettyContext (reactor.ipc.netty.NettyContext)92 Test (org.junit.Test)87 Mono (reactor.core.publisher.Mono)86 Duration (java.time.Duration)83 Flux (reactor.core.publisher.Flux)78 InetSocketAddress (java.net.InetSocketAddress)65 HttpServer (reactor.ipc.netty.http.server.HttpServer)63 HttpClient (reactor.ipc.netty.http.client.HttpClient)61 CountDownLatch (java.util.concurrent.CountDownLatch)60 StepVerifier (reactor.test.StepVerifier)60 AtomicReference (java.util.concurrent.atomic.AtomicReference)56 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)53 Unpooled (io.netty.buffer.Unpooled)50 TimeUnit (java.util.concurrent.TimeUnit)44 StandardCharsets (java.nio.charset.StandardCharsets)43 Ignore (org.junit.Ignore)43 SslContext (io.netty.handler.ssl.SslContext)42 SslContextBuilder (io.netty.handler.ssl.SslContextBuilder)42 InsecureTrustManagerFactory (io.netty.handler.ssl.util.InsecureTrustManagerFactory)42 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)42