Suppress warnings in tests
This commit is contained in:
parent
e2fd398bad
commit
9f321e8d56
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<Person> 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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.springframework.http.HttpMethod;
|
|||
|
||||
public class BufferedSimpleAsyncHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected AsyncClientHttpRequestFactory createRequestFactory() {
|
||||
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||
|
|
|
@ -32,6 +32,7 @@ import static org.junit.Assert.*;
|
|||
* @author Arjen Poutsma
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HttpComponentsAsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,6 +42,7 @@ public class Netty4AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpR
|
|||
eventLoopGroup.shutdownGracefully().sync();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected AsyncClientHttpRequestFactory createRequestFactory() {
|
||||
return new Netty4ClientHttpRequestFactory(eventLoopGroup);
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.springframework.http.HttpMethod;
|
|||
*/
|
||||
public class OkHttp3AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected AsyncClientHttpRequestFactory createRequestFactory() {
|
||||
return new OkHttp3ClientHttpRequestFactory();
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -71,6 +71,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
|||
@Parameter
|
||||
public ClientHttpRequestFactory clientHttpRequestFactory;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Parameters
|
||||
public static Iterable<? extends ClientHttpRequestFactory> data() {
|
||||
return Arrays.asList(
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 <reified T : Any, S : Publisher<T>> WebClient.RequestBodySpec.body(publisher: S):
|
||||
Mono<ClientResponse> = body(publisher, T::class.java)
|
||||
inline fun <reified T : Any, S : Publisher<T>> WebClient.RequestBodySpec.body(publisher: S): WebClient.RequestHeadersSpec<*>
|
||||
= body(publisher, T::class.java)
|
||||
|
|
Loading…
Reference in New Issue