diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleAsyncTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleAsyncTests.java index 091b64d575..18843a0f5c 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleAsyncTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleAsyncTests.java @@ -42,6 +42,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * @author Rossen Stoyanchev * @since 4.1 */ +@SuppressWarnings("deprecation") public class SampleAsyncTests { private final AsyncRestTemplate restTemplate = new AsyncRestTemplate(); diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/WebTestClientConnectorTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/WebTestClientConnectorTests.java index 3a3d88854c..81ef71ec3b 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/WebTestClientConnectorTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/WebTestClientConnectorTests.java @@ -32,6 +32,7 @@ import org.springframework.web.reactive.function.client.ClientRequest; import org.springframework.web.reactive.function.client.ExchangeFunction; import org.springframework.web.reactive.function.client.ExchangeFunctions; +import static java.time.Duration.*; import static org.junit.Assert.*; /** @@ -53,7 +54,7 @@ public class WebTestClientConnectorTests { WiretapConnector wiretapConnector = new WiretapConnector(connector); ExchangeFunction function = ExchangeFunctions.create(wiretapConnector); - function.exchange(clientRequest).blockMillis(0); + function.exchange(clientRequest).block(ofMillis(0)); ExchangeResult actual = wiretapConnector.claimRequest("1"); assertNotNull(actual); diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java index e0255eb9dc..e65fe48618 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java @@ -17,6 +17,7 @@ package org.springframework.test.web.reactive.server.samples; import java.net.URI; +import java.time.Duration; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; @@ -40,6 +41,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import static java.time.Duration.*; import static org.hamcrest.CoreMatchers.endsWith; import static org.junit.Assert.*; import static org.springframework.http.MediaType.TEXT_EVENT_STREAM; @@ -148,7 +150,7 @@ public class ResponseEntityTests { @GetMapping(produces = "text/event-stream") Flux getPersonStream() { - return Flux.intervalMillis(100).onBackpressureBuffer(10).map(index -> new Person("N" + index)); + return Flux.interval(ofMillis(100)).onBackpressureBuffer(10).map(index -> new Person("N" + index)); } @PostMapping diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java index 14f17f27ad..d848361a42 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java @@ -39,6 +39,7 @@ import org.springframework.util.StreamUtils; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFutureCallback; +@SuppressWarnings("deprecation") public abstract class AbstractAsyncHttpRequestFactoryTestCase extends AbstractMockWebServerTestCase { protected AsyncClientHttpRequestFactory factory; diff --git a/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleAsyncHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleAsyncHttpRequestFactoryTests.java index 1b7d420ddf..d9ada34576 100644 --- a/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleAsyncHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleAsyncHttpRequestFactoryTests.java @@ -26,6 +26,7 @@ import org.springframework.http.HttpMethod; public class BufferedSimpleAsyncHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase { + @SuppressWarnings("deprecation") @Override protected AsyncClientHttpRequestFactory createRequestFactory() { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); diff --git a/spring-web/src/test/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactoryTests.java index d928f0649a..ec84914b93 100644 --- a/spring-web/src/test/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactoryTests.java @@ -32,6 +32,7 @@ import static org.junit.Assert.*; * @author Arjen Poutsma * @author Stephane Nicoll */ +@SuppressWarnings("deprecation") public class HttpComponentsAsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase { @Override diff --git a/spring-web/src/test/java/org/springframework/http/client/Netty4AsyncClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/Netty4AsyncClientHttpRequestFactoryTests.java index a97f7b3837..32b7b880bf 100644 --- a/spring-web/src/test/java/org/springframework/http/client/Netty4AsyncClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/Netty4AsyncClientHttpRequestFactoryTests.java @@ -42,6 +42,7 @@ public class Netty4AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpR eventLoopGroup.shutdownGracefully().sync(); } + @SuppressWarnings("deprecation") @Override protected AsyncClientHttpRequestFactory createRequestFactory() { return new Netty4ClientHttpRequestFactory(eventLoopGroup); diff --git a/spring-web/src/test/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequestFactoryTests.java index 12e857e679..507e8a3439 100644 --- a/spring-web/src/test/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequestFactoryTests.java @@ -25,6 +25,7 @@ import org.springframework.http.HttpMethod; */ public class OkHttp3AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase { + @SuppressWarnings("deprecation") @Override protected AsyncClientHttpRequestFactory createRequestFactory() { return new OkHttp3ClientHttpRequestFactory(); diff --git a/spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java index c508c7690e..158a36e777 100644 --- a/spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java @@ -61,6 +61,7 @@ import static org.junit.Assert.fail; * @author Arjen Poutsma * @author Sebastien Deleuze */ +@SuppressWarnings("deprecation") public class AsyncRestTemplateIntegrationTests extends AbstractMockWebServerTestCase { private final AsyncRestTemplate template = new AsyncRestTemplate( diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java index 11f4d0ea09..d7954299c2 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java @@ -71,6 +71,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase @Parameter public ClientHttpRequestFactory clientHttpRequestFactory; + @SuppressWarnings("deprecation") @Parameters public static Iterable data() { return Arrays.asList( diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java index 68efd6e8ae..5ef26eb4fb 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java @@ -36,6 +36,7 @@ import org.springframework.web.server.WebExceptionHandler; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebHandler; +import static java.time.Duration.*; import static org.junit.Assert.*; /** @@ -55,9 +56,9 @@ public class WebHttpHandlerBuilderTests { MockServerHttpRequest request = MockServerHttpRequest.get("/").build(); MockServerHttpResponse response = new MockServerHttpResponse(); - httpHandler.handle(request, response).blockMillis(5000); + httpHandler.handle(request, response).block(ofMillis(5000)); - assertEquals("FilterB::FilterA", response.getBodyAsString().blockMillis(5000)); + assertEquals("FilterB::FilterA", response.getBodyAsString().block(ofMillis(5000))); } @Test // SPR-15074 @@ -70,9 +71,9 @@ public class WebHttpHandlerBuilderTests { MockServerHttpRequest request = MockServerHttpRequest.get("/").build(); MockServerHttpResponse response = new MockServerHttpResponse(); - httpHandler.handle(request, response).blockMillis(5000); + httpHandler.handle(request, response).block(ofMillis(5000)); - assertEquals("ExceptionHandlerB", response.getBodyAsString().blockMillis(5000)); + assertEquals("ExceptionHandlerB", response.getBodyAsString().block(ofMillis(5000))); } @Test @@ -85,9 +86,9 @@ public class WebHttpHandlerBuilderTests { MockServerHttpRequest request = MockServerHttpRequest.get("/").build(); MockServerHttpResponse response = new MockServerHttpResponse(); - httpHandler.handle(request, response).blockMillis(5000); + httpHandler.handle(request, response).block(ofMillis(5000)); - assertEquals("handled", response.getBodyAsString().blockMillis(5000)); + assertEquals("handled", response.getBodyAsString().block(ofMillis(5000))); } diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt index 7c0c0a8571..90595810f5 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt @@ -17,14 +17,13 @@ package org.springframework.web.reactive.function.client import org.reactivestreams.Publisher -import reactor.core.publisher.Mono /** - * Extension for [WebClient.RequestHeadersSpec.exchangePublisher] providing a variant without explicit class + * Extension for [WebClient.RequestBodySpec.body] providing a variant without explicit class * parameter thanks to Kotlin reified type parameters. * * @author Sebastien Deleuze * @since 5.0 */ -inline fun > WebClient.RequestBodySpec.body(publisher: S): - Mono = body(publisher, T::class.java) +inline fun > WebClient.RequestBodySpec.body(publisher: S): WebClient.RequestHeadersSpec<*> + = body(publisher, T::class.java)