From d48cc1502b92527fdbbcac196b94280a41212fe5 Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Mon, 13 May 2024 14:08:42 +0300 Subject: [PATCH] Always use block/blockLast/verify with timeout (#3238) --- .../reactor/netty/ContextPropagationTest.java | 4 +- .../java/reactor/netty/NettyOutboundTest.java | 6 +- .../netty/channel/MonoSendManyTest.java | 5 +- .../reactor/netty/tcp/TcpClientTests.java | 2 +- .../reactor/netty/tcp/TcpResourcesTest.java | 8 +- .../ClientTransportResolverHooksTest.java | 8 +- .../transport/TransportConnectorTest.java | 7 +- .../reactor/netty/udp/UdpResourcesTest.java | 6 +- .../client/HttpClientNoMicrometerTest.java | 4 +- .../channel/ChannelOperationsHandlerTest.java | 4 +- .../java/reactor/netty/http/Http2Tests.java | 6 +- .../reactor/netty/http/HttpErrorTests.java | 5 +- .../netty/http/HttpProtocolsTests.java | 5 +- .../reactor/netty/http/HttpResourcesTest.java | 6 +- .../HttpResponseStatusCodesHandlingTests.java | 5 +- .../java/reactor/netty/http/HttpTests.java | 22 +++-- .../netty/http/client/Http2PoolTest.java | 96 +++++++++---------- .../netty/http/client/HttpClientTest.java | 36 +++---- .../http/client/HttpClientWithTomcatTest.java | 4 +- .../netty/http/client/HttpRedirectTest.java | 2 +- .../client/WebsocketClientOperationsTest.java | 4 +- .../netty/http/client/WebsocketTest.java | 14 +-- .../netty/http/server/HttpSendFileTests.java | 4 +- .../netty/http/server/HttpServerTests.java | 55 ++++++----- .../netty/incubator/quic/QuicServerTests.java | 4 +- 25 files changed, 175 insertions(+), 147 deletions(-) diff --git a/reactor-netty-core/src/contextPropagationTest/java/reactor/netty/ContextPropagationTest.java b/reactor-netty-core/src/contextPropagationTest/java/reactor/netty/ContextPropagationTest.java index b1a7f51e58..8891ff4df3 100644 --- a/reactor-netty-core/src/contextPropagationTest/java/reactor/netty/ContextPropagationTest.java +++ b/reactor-netty-core/src/contextPropagationTest/java/reactor/netty/ContextPropagationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2022-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ void testContextPropagation(TcpClient client) { .wiretap(true) .connect() .contextWrite(ctx -> ctx.putAllMap((HashMap) ContextSnapshot.captureAll(registry))) - .block(); + .block(Duration.ofSeconds(5)); assertThat(connection).isNotNull(); diff --git a/reactor-netty-core/src/test/java/reactor/netty/NettyOutboundTest.java b/reactor-netty-core/src/test/java/reactor/netty/NettyOutboundTest.java index 3926d5717e..c976f230f2 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/NettyOutboundTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/NettyOutboundTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2017-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ public NettyOutbound withConnection(Consumer withConnection) ChannelFuture f = channel.writeOneOutbound(1); outbound.sendFile(Paths.get(getClass().getResource("/largeFile.txt").toURI())) - .then().block(); + .then().block(Duration.ofSeconds(5)); assertThat(channel.inboundMessages()).isEmpty(); assertThat(channel.outboundMessages()).hasSize(2); @@ -313,7 +313,7 @@ public NettyOutbound withConnection(Consumer withConnection) ChannelFuture f = channel.writeOneOutbound(1); outbound.sendFileChunked(path, 0, Files.size(path)) - .then().block(); + .then().block(Duration.ofSeconds(5)); assertThat(channel.inboundMessages()).isEmpty(); assertThat(messageWritten).containsExactly(Integer.class, ChunkedNioFile.class); diff --git a/reactor-netty-core/src/test/java/reactor/netty/channel/MonoSendManyTest.java b/reactor-netty-core/src/test/java/reactor/netty/channel/MonoSendManyTest.java index e59da7519f..c95acb9d6f 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/channel/MonoSendManyTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/channel/MonoSendManyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2019-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package reactor.netty.channel; import java.lang.ref.WeakReference; +import java.time.Duration; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.IdentityHashMap; @@ -156,7 +157,7 @@ void cleanupCancelCloseFuture(boolean flushOnEach) { .consumeSubscriptionWith(s -> _w.add(new WeakReference<>(s))) .then(channel::runPendingTasks) .thenCancel() - .verify(); + .verify(Duration.ofSeconds(5)); System.gc(); wait(_w.get(0)); diff --git a/reactor-netty-core/src/test/java/reactor/netty/tcp/TcpClientTests.java b/reactor-netty-core/src/test/java/reactor/netty/tcp/TcpClientTests.java index bd2d910d1a..753283768f 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/tcp/TcpClientTests.java +++ b/reactor-netty-core/src/test/java/reactor/netty/tcp/TcpClientTests.java @@ -1419,7 +1419,7 @@ private void doTestSharedNameResolver(TcpClient client, boolean sharedClient) th finally { disposableServer.disposeNow(); loop.disposeLater() - .block(); + .block(Duration.ofSeconds(5)); } } diff --git a/reactor-netty-core/src/test/java/reactor/netty/tcp/TcpResourcesTest.java b/reactor-netty-core/src/test/java/reactor/netty/tcp/TcpResourcesTest.java index e25d159134..be2e64bd27 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/tcp/TcpResourcesTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/tcp/TcpResourcesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2017-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ void shutdownLaterDefers() { TcpResources.disposeLoopsAndConnectionsLater(); assertThat(newTcpResources.isDisposed()).isFalse(); - TcpResources.disposeLoopsAndConnectionsLater().block(); + TcpResources.disposeLoopsAndConnectionsLater().block(Duration.ofSeconds(5)); assertThat(newTcpResources.isDisposed()).as("disposeLoopsAndConnectionsLater completion").isTrue(); assertThat(TcpResources.tcpResources.get()).isNull(); @@ -140,7 +140,7 @@ void blockShouldFail() throws InterruptedException { try { out.sendString(Flux.just("Hello World!")) .then() - .block(); + .block(Duration.ofSeconds(5)); } catch (RuntimeException e) { latch.countDown(); @@ -170,7 +170,7 @@ void testIssue1227() { TcpResources current = TcpResources.tcpResources.get(); TcpResources.disposeLoopsAndConnectionsLater() - .block(); + .block(Duration.ofSeconds(5)); assertThat(current.isDisposed()).isTrue(); } } \ No newline at end of file diff --git a/reactor-netty-core/src/test/java/reactor/netty/transport/ClientTransportResolverHooksTest.java b/reactor-netty-core/src/test/java/reactor/netty/transport/ClientTransportResolverHooksTest.java index 2d49fa0ffd..94139b0af2 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/transport/ClientTransportResolverHooksTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/transport/ClientTransportResolverHooksTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2020-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import reactor.test.StepVerifier; import java.net.UnknownHostException; +import java.time.Duration; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -51,7 +52,7 @@ void shouldCallHooksInSuccessScenario() { .doAfterResolve((conn, socketAddress) -> doAfterResolve.set(conn.channel().attr(TRACE_ID_KEY).get())) .doOnResolveError((conn, th) -> doOnResolveError.set(conn.channel().attr(TRACE_ID_KEY).get())) .connect() - .block(); + .block(Duration.ofSeconds(5)); assertThat(doOnResolve).hasValue(TRACE_ID_VALUE); assertThat(doAfterResolve).hasValue(TRACE_ID_VALUE); @@ -81,7 +82,8 @@ void shouldCallHooksInErrorScenario() { }) .connect() .as(StepVerifier::create) - .verifyError(UnknownHostException.class); + .expectError(UnknownHostException.class) + .verify(Duration.ofSeconds(5)); assertThat(doOnResolve).hasValue(TRACE_ID_VALUE); assertThat(doAfterResolve).hasValue(0); diff --git a/reactor-netty-core/src/test/java/reactor/netty/transport/TransportConnectorTest.java b/reactor-netty-core/src/test/java/reactor/netty/transport/TransportConnectorTest.java index 2185e2e508..6de0ac0c53 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/transport/TransportConnectorTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/transport/TransportConnectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2023-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import reactor.netty.tcp.TcpClientConfig; import java.net.InetSocketAddress; +import java.time.Duration; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,13 +37,13 @@ void bind_whenBindException_thenChannelIsUnregistered() { transportConfig, new RecordingChannelInitializer(), new InetSocketAddress("localhost", 0), - false).block(); + false).block(Duration.ofSeconds(5)); final RecordingChannelInitializer channelInitializer = new RecordingChannelInitializer(); assertThatThrownBy(() -> TransportConnector.bind( transportConfig, channelInitializer, new InetSocketAddress("localhost", ((InetSocketAddress) channel1.localAddress()).getPort()), - false).block()); + false).block(Duration.ofSeconds(5))); final Channel channel2 = channelInitializer.channel; assertThat(channel1.isRegistered()).isTrue(); assertThat(channel2.isRegistered()).isFalse(); diff --git a/reactor-netty-core/src/test/java/reactor/netty/udp/UdpResourcesTest.java b/reactor-netty-core/src/test/java/reactor/netty/udp/UdpResourcesTest.java index 70c5a0fc7d..fc454f1a36 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/udp/UdpResourcesTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/udp/UdpResourcesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2020-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ import org.junit.jupiter.api.Test; import reactor.netty.resources.LoopResources; +import java.time.Duration; + import static org.assertj.core.api.Assertions.assertThat; /** @@ -39,7 +41,7 @@ void testIssue1227() { UdpResources current = UdpResources.udpResources.get(); UdpResources.shutdownLater() - .block(); + .block(Duration.ofSeconds(5)); assertThat(current.isDisposed()).isTrue(); } } diff --git a/reactor-netty-http/src/noMicrometerTest/java/reactor/netty/http/client/HttpClientNoMicrometerTest.java b/reactor-netty-http/src/noMicrometerTest/java/reactor/netty/http/client/HttpClientNoMicrometerTest.java index dd8b7b0f6b..1f4e0035f0 100644 --- a/reactor-netty-http/src/noMicrometerTest/java/reactor/netty/http/client/HttpClientNoMicrometerTest.java +++ b/reactor-netty-http/src/noMicrometerTest/java/reactor/netty/http/client/HttpClientNoMicrometerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2021-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,7 +115,7 @@ private void doTestClientCreatedWithMetricsDoesntLoadGauge(HttpServer server, Ht .responseContent() .aggregate() .asString() - .block() + .block(Duration.ofSeconds(5)) ).doesNotThrowAnyException(); //we still assert that the custom recorder did receive events, since it is not based on micrometer diff --git a/reactor-netty-http/src/test/java/reactor/netty/channel/ChannelOperationsHandlerTest.java b/reactor-netty-http/src/test/java/reactor/netty/channel/ChannelOperationsHandlerTest.java index 85f44f6ad4..f2e620be32 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/channel/ChannelOperationsHandlerTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/channel/ChannelOperationsHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2017-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,7 +153,7 @@ void testChannelInactiveThrowsIOException() throws Exception { StepVerifier.create(response.log()) .expectError(IOException.class) - .verify(); + .verify(Duration.ofSeconds(5)); abortServer.close(); diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/Http2Tests.java b/reactor-netty-http/src/test/java/reactor/netty/http/Http2Tests.java index dbac3bcd2f..dc69721f21 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/Http2Tests.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/Http2Tests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2020-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -200,7 +200,7 @@ void doTestMaxActiveStreams_1_CustomPool(@Nullable BiFunction content = client.get() @@ -233,7 +234,8 @@ void httpErrorWithRequestsFromClients() throws Exception { StepVerifier.create(code) .expectNext(500) - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } /* @@ -326,7 +328,7 @@ void streamAndPoolExplicitCompression() { .aggregate() .asString() .log() - .block(); + .block(Duration.ofSeconds(5)); Flux f = createClient(disposableServer.port()) .compress(true) @@ -345,7 +347,8 @@ void streamAndPoolExplicitCompression() { .expectNext("test2") .thenAwait(Duration.ofMillis(30)) .then(() -> ep.tryEmitComplete().orThrow()) - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); @@ -358,7 +361,7 @@ void streamAndPoolExplicitCompression() { .aggregate() .asString() .log() - .block(); + .block(Duration.ofSeconds(5)); } @@ -391,7 +394,7 @@ void streamAndPoolDefaultCompression() { .aggregate() .asString() .log() - .block(); + .block(Duration.ofSeconds(5)); Flux f = createClient(disposableServer.port()) .compress(true) @@ -410,7 +413,8 @@ void streamAndPoolDefaultCompression() { .expectNext("test2") .thenAwait(Duration.ofMillis(30)) .then(() -> ep.tryEmitComplete().orThrow()) - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); @@ -423,7 +427,7 @@ void streamAndPoolDefaultCompression() { .aggregate() .asString() .log() - .block(); + .block(Duration.ofSeconds(5)); } @Test diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/client/Http2PoolTest.java b/reactor-netty-http/src/test/java/reactor/netty/http/client/Http2PoolTest.java index 4dbda691db..df5a11b0ea 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/client/Http2PoolTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/client/Http2PoolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2021-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,7 +153,7 @@ void evictClosedConnection() throws Exception { Connection connection = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -173,13 +173,13 @@ void evictClosedConnection() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(0); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -191,7 +191,7 @@ void evictClosedConnection() throws Exception { assertThat(id1).isNotEqualTo(id2); - acquired2.invalidate().block(); + acquired2.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(1); @@ -231,7 +231,7 @@ private void evictClosedConnectionMaxConnectionsNotReached(boolean closeSecond) Connection connection = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -251,7 +251,7 @@ private void evictClosedConnectionMaxConnectionsNotReached(boolean closeSecond) assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(Integer.MAX_VALUE); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); AtomicReference> acquired3 = new AtomicReference<>(); @@ -276,14 +276,14 @@ private void evictClosedConnectionMaxConnectionsNotReached(boolean closeSecond) ChannelId id2 = connection.channel().id(); assertThat(id1).isNotEqualTo(id2); - acquired1.invalidate().block(); - acquired2.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); + acquired2.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(1); assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(Integer.MAX_VALUE); - acquired3.get().invalidate().block(); + acquired3.get().invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); if (closeSecond) { @@ -319,7 +319,7 @@ void evictClosedConnectionMaxConnectionsReached() throws Exception { Connection connection = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -347,7 +347,7 @@ void evictClosedConnectionMaxConnectionsReached() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(0); @@ -378,7 +378,7 @@ void evictInBackgroundClosedConnection() throws Exception { Connection connection = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -398,7 +398,7 @@ void evictInBackgroundClosedConnection() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); http2Pool.evictInBackground(); @@ -406,7 +406,7 @@ void evictInBackgroundClosedConnection() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(0); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -418,7 +418,7 @@ void evictInBackgroundClosedConnection() throws Exception { assertThat(id1).isNotEqualTo(id2); - acquired2.invalidate().block(); + acquired2.invalidate().block(Duration.ofSeconds(1)); http2Pool.evictInBackground(); @@ -453,7 +453,7 @@ void evictInBackgroundMaxIdleTime() throws Exception { Connection connection1 = null; Connection connection2 = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -463,7 +463,7 @@ void evictInBackgroundMaxIdleTime() throws Exception { connection1 = acquired1.poolable(); ChannelId id1 = connection1.channel().id(); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); Thread.sleep(15); @@ -473,7 +473,7 @@ void evictInBackgroundMaxIdleTime() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(0); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -485,7 +485,7 @@ void evictInBackgroundMaxIdleTime() throws Exception { assertThat(id1).isNotEqualTo(id2); - acquired2.invalidate().block(); + acquired2.invalidate().block(Duration.ofSeconds(1)); Thread.sleep(15); @@ -526,7 +526,7 @@ void evictInBackgroundMaxLifeTime() throws Exception { Connection connection1 = null; Connection connection2 = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -542,7 +542,7 @@ void evictInBackgroundMaxLifeTime() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); http2Pool.evictInBackground(); @@ -550,7 +550,7 @@ void evictInBackgroundMaxLifeTime() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(0); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -562,7 +562,7 @@ void evictInBackgroundMaxLifeTime() throws Exception { assertThat(id1).isNotEqualTo(id2); - acquired2.invalidate().block(); + acquired2.invalidate().block(Duration.ofSeconds(1)); Thread.sleep(10); @@ -604,7 +604,7 @@ void evictInBackgroundEvictionPredicate() { Connection connection1 = null; Connection connection2 = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -620,7 +620,7 @@ void evictInBackgroundEvictionPredicate() { assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); http2Pool.evictInBackground(); @@ -630,7 +630,7 @@ void evictInBackgroundEvictionPredicate() { shouldEvict.set(false); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -642,7 +642,7 @@ void evictInBackgroundEvictionPredicate() { assertThat(id1).isNotEqualTo(id2); - acquired2.invalidate().block(); + acquired2.invalidate().block(Duration.ofSeconds(1)); shouldEvict.set(true); @@ -682,7 +682,7 @@ void maxIdleTime() throws Exception { Connection connection1 = null; Connection connection2 = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -692,11 +692,11 @@ void maxIdleTime() throws Exception { connection1 = acquired1.poolable(); ChannelId id1 = connection1.channel().id(); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); Thread.sleep(15); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -708,7 +708,7 @@ void maxIdleTime() throws Exception { assertThat(id1).isNotEqualTo(id2); - acquired2.invalidate().block(); + acquired2.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(1); @@ -755,7 +755,7 @@ void maxIdleTimeActiveStreams() throws Exception { connection1 = acquired.get(0).poolable(); ChannelId id1 = connection1.channel().id(); - acquired.get(0).invalidate().block(); + acquired.get(0).invalidate().block(Duration.ofSeconds(1)); Thread.sleep(15); @@ -768,7 +768,7 @@ void maxIdleTimeActiveStreams() throws Exception { assertThat(id1).isEqualTo(id2); - acquired.get(1).invalidate().block(); + acquired.get(1).invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(1); @@ -804,7 +804,7 @@ void maxLifeTime() throws Exception { Connection connection1 = null; Connection connection2 = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -820,13 +820,13 @@ void maxLifeTime() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(0); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -838,7 +838,7 @@ void maxLifeTime() throws Exception { assertThat(id1).isNotEqualTo(id2); - acquired2.invalidate().block(); + acquired2.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(1); @@ -875,7 +875,7 @@ void evictionPredicate() { Connection connection1 = null; Connection connection2 = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -891,7 +891,7 @@ void evictionPredicate() { assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - acquired1.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(0); @@ -899,7 +899,7 @@ void evictionPredicate() { shouldEvict.set(false); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -911,7 +911,7 @@ void evictionPredicate() { assertThat(id1).isNotEqualTo(id2); - acquired2.invalidate().block(); + acquired2.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(1); @@ -947,7 +947,7 @@ void maxLifeTimeMaxConnectionsNotReached() throws Exception { Connection connection1 = null; Connection connection2 = null; try { - PooledRef acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -963,7 +963,7 @@ void maxLifeTimeMaxConnectionsNotReached() throws Exception { assertThat(http2Pool.connections.size()).isEqualTo(1); assertThat(http2Pool.totalMaxConcurrentStreams).isEqualTo(0); - PooledRef acquired2 = http2Pool.acquire().block(); + PooledRef acquired2 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired2).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(2); @@ -975,8 +975,8 @@ void maxLifeTimeMaxConnectionsNotReached() throws Exception { assertThat(id1).isNotEqualTo(id2); - acquired1.invalidate().block(); - acquired2.invalidate().block(); + acquired1.invalidate().block(Duration.ofSeconds(1)); + acquired2.invalidate().block(Duration.ofSeconds(1)); assertThat(http2Pool.activeStreams()).isEqualTo(0); assertThat(http2Pool.connections.size()).isEqualTo(1); @@ -1033,7 +1033,7 @@ private void doMaxLifeTimeMaxConnectionsReached(@Nullable BiFunction acquired1 = http2Pool.acquire().block(); + PooledRef acquired1 = http2Pool.acquire().block(Duration.ofSeconds(1)); assertThat(acquired1).isNotNull(); assertThat(http2Pool.activeStreams()).isEqualTo(1); @@ -1057,7 +1057,7 @@ private void doMaxLifeTimeMaxConnectionsReached(@Nullable BiFunction Mono.just(r.status().code()))) .expectNextMatches(status -> status >= 200 && status < 400) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); StepVerifier.create(HttpClient.create() .wiretap(true) @@ -389,7 +389,7 @@ void simpleTestHttps() { .response((r, buf) -> Mono.just(r.status().code()))) .expectNextMatches(status -> status >= 200 && status < 400) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); } @Test @@ -416,7 +416,8 @@ void prematureCancel() { .uri("/") .responseContent() .timeout(signal.asFlux())) - .verifyError(TimeoutException.class); + .expectError(TimeoutException.class) + .verify(Duration.ofSeconds(5)); } @Test @@ -528,7 +529,7 @@ void testUserAgent() { .get() .uri("/") .responseContent() - .blockLast(); + .blockLast(Duration.ofSeconds(5)); } @Test @@ -586,7 +587,7 @@ void sslExchangeAbsoluteGet() throws SSLException { .get() .uri("/foo") .responseSingle((res, buf) -> buf.asString(CharsetUtil.UTF_8)) - .block(); + .block(Duration.ofSeconds(5)); assertThat(responseString).isEqualTo("hello /foo"); } @@ -696,7 +697,7 @@ void test() throws Exception { .put() .uri("/201") .responseContent() - .blockLast(); + .blockLast(Duration.ofSeconds(5)); createHttpClientForContextWithAddress() .doOnRequest((r, c) -> onReq.getAndIncrement()) @@ -752,7 +753,7 @@ void testDeferredUri() { })) .responseContent() .repeat(4) - .blockLast(); + .blockLast(Duration.ofSeconds(5)); } @Test @@ -772,7 +773,7 @@ void testDeferredHeader() { .uri("/201") .responseContent() .repeat(4) - .blockLast(); + .blockLast(Duration.ofSeconds(30)); } @Test @@ -799,7 +800,7 @@ void testCookie() { .get() .uri("/201") .responseContent() - .blockLast(); + .blockLast(Duration.ofSeconds(5)); } @Test @@ -831,7 +832,7 @@ void closePool() { .log())) .expectNextSequence(expected) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); pr.dispose(); } @@ -1148,7 +1149,8 @@ private void doOnError(HttpClient client) { .asString(); StepVerifier.create(content) - .verifyError(PrematureCloseException.class); + .expectError(PrematureCloseException.class) + .verify(Duration.ofSeconds(5)); assertThat(requestError1.get()).isEqualTo("success"); assertThat(responseError1.get()).isNull(); @@ -1171,7 +1173,8 @@ private void doOnError(HttpClient client) { .asString(); StepVerifier.create(content) - .verifyError(PrematureCloseException.class); + .expectError(PrematureCloseException.class) + .verify(Duration.ofSeconds(5)); assertThat(requestError2.get()).isNull(); assertThat(responseError2.get()).isEqualTo("success"); @@ -1202,7 +1205,8 @@ void withConnector_1() { StepVerifier.create(content) .expectNext("success") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } @ParameterizedTest @@ -3266,7 +3270,7 @@ private void doTestSharedNameResolver(HttpClient client, boolean sharedClient) t } finally { loop.disposeLater() - .block(); + .block(Duration.ofSeconds(5)); } } diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpClientWithTomcatTest.java b/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpClientWithTomcatTest.java index 8d524e9684..ccafcf3cb2 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpClientWithTomcatTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpClientWithTomcatTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2019-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -182,7 +182,7 @@ private void doSimpleTest404(HttpClient client) { .uri("/status/404") .responseSingle((r, buf) -> Mono.just(r.status().code())) .log() - .block(); + .block(Duration.ofSeconds(5)); assertThat(res).isNotNull(); if (res != 404) { diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpRedirectTest.java b/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpRedirectTest.java index 8af8d336b7..ec5e9df829 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpRedirectTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpRedirectTest.java @@ -393,7 +393,7 @@ void testIssue606() { .get() .uri("/") .responseContent() - .blockLast(); + .blockLast(Duration.ofSeconds(5)); assertThat(followRedirects.get()).isEqualTo(4); } diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/client/WebsocketClientOperationsTest.java b/reactor-netty-http/src/test/java/reactor/netty/http/client/WebsocketClientOperationsTest.java index afeb4f931e..851753333c 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/client/WebsocketClientOperationsTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/client/WebsocketClientOperationsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2017-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ private void failOnClientServerError( StepVerifier.create(response) .expectError(WebSocketHandshakeException.class) - .verify(); + .verify(Duration.ofSeconds(5)); } private Mono login(int port) { diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/client/WebsocketTest.java b/reactor-netty-http/src/test/java/reactor/netty/http/client/WebsocketTest.java index 6c9ad6f944..f7b050e202 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/client/WebsocketTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/client/WebsocketTest.java @@ -126,7 +126,7 @@ void simpleTest() { .handle((i, o) -> i.receive().asString()) .log("client") .collectList() - .block(); + .block(Duration.ofSeconds(5)); assertThat(res).isNotNull(); assertThat(res.get(0)).isEqualTo("test"); @@ -187,7 +187,7 @@ void unidirectional() { .log()) .expectNextSequence(expected) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); } @Test @@ -240,7 +240,7 @@ void webSocketRespondsToRequestsFromClients() { StepVerifier.create(response) .expectNextMatches(list -> "1000 World!".equals(list.get(999))) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); log.debug("FINISHED: server[" + serverRes.get() + "] / client[" + clientRes + "]"); } @@ -274,7 +274,7 @@ void unidirectionalBinary() { .log()) .expectNextSequence(expected) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); } @Test @@ -587,7 +587,7 @@ void closePool() { .log())) .expectNextSequence(expected) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); pr.dispose(); } @@ -953,7 +953,7 @@ void firefoxConnectionTest() { .get() .uri("/ws") .response() - .block(); + .block(Duration.ofSeconds(5)); assertThat(res).isNotNull(); assertThat(res.status()).isEqualTo(HttpResponseStatus.SWITCHING_PROTOCOLS); } @@ -986,7 +986,7 @@ void testIssue821() throws Exception { .uri("/ws") .receive() .asString() - .blockLast(); + .blockLast(Duration.ofSeconds(5)); assertThat(res).isNotNull() .isEqualTo("test"); diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/server/HttpSendFileTests.java b/reactor-netty-http/src/test/java/reactor/netty/http/server/HttpSendFileTests.java index abfbee85ab..a885940ee3 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/server/HttpSendFileTests.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/server/HttpSendFileTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2018-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -346,7 +346,7 @@ private void doTestSendFileAsync(BiFunction Mono.just(res.status().code()))) .collectList() - .block(); + .block(Duration.ofSeconds(5)); } //from https://github.com/reactor/reactor-netty/issues/90 @@ -354,7 +354,7 @@ private void doTestRestart(HttpServer server, HttpClient client) { .responseContent() .aggregate() .asString() - .block(); + .block(Duration.ofSeconds(5)); // checking the response status, OK assertThat(response).isEqualTo("200"); @@ -376,7 +376,7 @@ private void doTestRestart(HttpServer server, HttpClient client) { .responseContent() .aggregate() .asString() - .block(); + .block(Duration.ofSeconds(5)); assertThat(response).isEqualTo("201"); } @@ -399,7 +399,7 @@ void errorResponseAndReturn() { .get() .uri("/return") .responseSingle((res, buf) -> Mono.just(res.status().code())) - .block(); + .block(Duration.ofSeconds(5)); assertThat(code).isEqualTo(500); } @@ -592,14 +592,14 @@ void startRouter() { .get() .uri("/hello") .responseSingle((res, buf) -> Mono.just(res.status().code())) - .block(); + .block(Duration.ofSeconds(5)); assertThat(code).isEqualTo(200); code = createClient(disposableServer.port()) .get() .uri("/helloMan") .responseSingle((res, buf) -> Mono.just(res.status().code())) - .block(); + .block(Duration.ofSeconds(5)); assertThat(code).isEqualTo(404); } @@ -943,7 +943,7 @@ private void doTestIssue309(String path, HttpServer httpServer) { StepVerifier.create(status) .expectNextMatches(HttpResponseStatus.REQUEST_URI_TOO_LONG::equals) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); } @Test @@ -965,7 +965,7 @@ void httpServerRequestHeadersTooLong() { StepVerifier.create(status) .expectNextMatches(HttpResponseStatus.REQUEST_HEADER_FIELDS_TOO_LARGE::equals) .expectComplete() - .verify(); + .verify(Duration.ofSeconds(5)); } @Test @@ -1002,7 +1002,7 @@ void httpServerRequestConfigInjectAttributes() { .responseContent() .aggregate() .asString() - .block(); + .block(Duration.ofSeconds(5)); assertThat(channelRef.get()).isNotNull(); assertThat(chunkSize).as("line length").hasValue(789); @@ -1264,7 +1264,8 @@ void testExpectErrorWhenConnectionClosed() throws Exception { .get() .uri("/") .responseContent()) - .verifyError(PrematureCloseException.class); + .expectError(PrematureCloseException.class) + .verify(Duration.ofSeconds(5)); assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue(); assertThat(error.get()).isInstanceOf(AbortedException.class); @@ -1314,7 +1315,7 @@ void testNormalConnectionCloseForWebSocketClient() throws Exception { .doFinally(sig -> latch.countDown()) .then(Mono.delay(Duration.ofMillis(500))); }) - .blockLast(); + .blockLast(Duration.ofSeconds(5)); assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue(); assertThat(receiver.get()).containsAll(test); @@ -1353,7 +1354,7 @@ void testNormalConnectionCloseForWebSocketServer() throws Exception { statusClient.set(o); latch.countDown(); }))) - .blockLast(); + .blockLast(Duration.ofSeconds(5)); assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue(); assertThat(statusClient.get()).isNotNull() @@ -2827,7 +2828,8 @@ void testMatchRouteInConfiguredOrder() { StepVerifier.create(createClient(disposableServer.port()).get().uri("/yes/value") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/yes/{value}") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } @Test @@ -2841,7 +2843,8 @@ void testUseComparatorOrderRoutes() { StepVerifier.create(createClient(disposableServer.port()).get().uri("/yes/value") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/yes/value") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } @Test @@ -2856,7 +2859,8 @@ void testOverrideRouteOrder() { StepVerifier.create(createClient(disposableServer.port()).get().uri("/yes/value") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/yes/value") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } finally { if (disposableServer != null) { @@ -2870,7 +2874,8 @@ void testOverrideRouteOrder() { StepVerifier.create(createClient(disposableServer.port()).get().uri("/yes/value") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/yes/{value}") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } @Test @@ -2885,7 +2890,8 @@ void testUseRoutesConfiguredOrder() { StepVerifier.create(createClient(disposableServer.port()).get().uri("/yes/value") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/yes/value") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } finally { if (disposableServer != null) { @@ -2899,7 +2905,8 @@ void testUseRoutesConfiguredOrder() { StepVerifier.create(createClient(disposableServer.port()).get().uri("/yes/value") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/yes/{value}") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } private static final Comparator comparator = (o1, o2) -> { @@ -2962,12 +2969,14 @@ void testRemoveRoutes() { StepVerifier.create(createClient(disposableServer.port()).get().uri("/route1") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/route1") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); StepVerifier.create(createClient(disposableServer.port()).get().uri("/route2") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/route2") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } finally { if (disposableServer != null) { @@ -2984,12 +2993,14 @@ void testRemoveRoutes() { StepVerifier.create(createClient(disposableServer.port()).get().uri("/route1") .response()) .expectNextMatches(response -> response.status().equals(HttpResponseStatus.NOT_FOUND)) - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); StepVerifier.create(createClient(disposableServer.port()).get().uri("/route2") .responseSingle((response, byteBufMono) -> byteBufMono.asString())) .expectNext("/route2") - .verifyComplete(); + .expectComplete() + .verify(Duration.ofSeconds(5)); } @ParameterizedTest(name = "{displayName}({arguments})") diff --git a/reactor-netty-incubator-quic/src/test/java/reactor/netty/incubator/quic/QuicServerTests.java b/reactor-netty-incubator-quic/src/test/java/reactor/netty/incubator/quic/QuicServerTests.java index d4bb629950..fa6beb3779 100644 --- a/reactor-netty-incubator-quic/src/test/java/reactor/netty/incubator/quic/QuicServerTests.java +++ b/reactor-netty-incubator-quic/src/test/java/reactor/netty/incubator/quic/QuicServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2021-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -337,7 +337,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { latch.countDown(); }) .then())) - .block(); + .block(Duration.ofSeconds(5)); assertThat(latch.await(5, TimeUnit.SECONDS)).as("latch wait").isTrue();