From d46c307f550e69e5bc3a7b96f059325803c6682a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 18 Mar 2017 16:58:03 +0100 Subject: [PATCH] Clean up warnings in spring-webflux module --- .../method/AbstractHandlerMethodMapping.java | 1 + .../RequestMappingInfoHandlerMapping.java | 1 + .../RequestBodyArgumentResolver.java | 1 - .../annotation/ResponseBodyResultHandler.java | 3 --- .../script/ScriptTemplateViewResolver.java | 1 - .../reactive/FlushingIntegrationTests.java | 12 ++++-------- .../reactive/function/BodyInsertersTests.java | 1 + .../DispatcherHandlerIntegrationTests.java | 16 ++++++---------- .../function/server/MockServerRequest.java | 1 + ...lisherHandlerFunctionIntegrationTests.java | 1 + .../SseHandlerFunctionIntegrationTests.java | 2 +- .../resource/PathResourceResolverTests.java | 13 +++++++------ .../VersionResourceResolverTests.java | 13 +++++++------ .../method/HandlerMethodMappingTests.java | 4 ++-- .../ErrorsArgumentResolverTests.java | 8 +++++--- .../JsonStreamingIntegrationTests.java | 2 +- .../MessageReaderArgumentResolverTests.java | 9 +++------ .../MessageWriterResultHandlerTests.java | 1 + ...lAttributeMethodArgumentResolverTests.java | 4 ++-- .../annotation/ModelInitializerTests.java | 5 +++-- ...thVariableMethodArgumentResolverTests.java | 2 +- ...tAttributeMethodArgumentResolverTests.java | 4 ++-- ...uestHeaderMethodArgumentResolverTests.java | 4 ---- ...estMappingDataBindingIntegrationTests.java | 1 + .../RequestMappingIntegrationTests.java | 16 +++++++--------- ...pingMessageConversionIntegrationTests.java | 3 +-- ...stParamMapMethodArgumentResolverTests.java | 15 +++------------ ...nAttributeMethodArgumentResolverTests.java | 4 ++-- .../annotation/SseIntegrationTests.java | 2 +- .../ViewResolutionResultHandlerTests.java | 4 +++- .../view/freemarker/FreeMarkerViewTests.java | 3 ++- .../view/script/JRubyScriptTemplateTests.java | 9 --------- .../script/JythonScriptTemplateTests.java | 12 +----------- .../script/KotlinScriptTemplateTests.java | 11 +---------- .../script/NashornScriptTemplateTests.java | 13 ++----------- .../ScriptTemplateViewResolverTests.java | 4 ++-- .../socket/WebSocketIntegrationTests.java | 19 ++++++++++--------- 37 files changed, 86 insertions(+), 139 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java index 325fd55acd..f48489c067 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java @@ -630,6 +630,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap private static class PreFlightAmbiguousMatchHandler { + @SuppressWarnings("unused") public void handle() { throw new UnsupportedOperationException("Not implemented"); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java index f445aeaa50..459708f668 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java @@ -438,6 +438,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe return result; } + @SuppressWarnings("unused") public HttpHeaders handle() { return this.headers; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolver.java index 9753b4a2f4..6084a88a0f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolver.java @@ -23,7 +23,6 @@ import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.http.codec.HttpMessageReader; -import org.springframework.validation.Validator; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandler.java index 452863321e..d0ccd3c65b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandler.java @@ -21,11 +21,8 @@ import java.util.List; import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; -import org.springframework.core.ReactiveAdapter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.http.HttpEntity; import org.springframework.http.codec.HttpMessageWriter; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.reactive.HandlerResult; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolver.java index df34ef2e81..6296498f4d 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolver.java @@ -20,7 +20,6 @@ import java.util.Locale; import reactor.core.publisher.Mono; -import org.springframework.web.reactive.result.view.AbstractUrlBasedView; import org.springframework.web.reactive.result.view.UrlBasedViewResolver; import org.springframework.web.reactive.result.view.View; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java index 3d0fa231cd..8dc6a581fa 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java @@ -19,7 +19,6 @@ package org.springframework.web.reactive; import java.nio.charset.StandardCharsets; import java.time.Duration; -import org.junit.Assume; import org.junit.Before; import org.junit.Test; import org.reactivestreams.Publisher; @@ -29,23 +28,20 @@ import reactor.test.StepVerifier; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.http.server.reactive.bootstrap.RxNettyHttpServer; import org.springframework.web.reactive.function.BodyExtractors; -import org.springframework.web.reactive.function.client.ExchangeFunction; -import org.springframework.web.reactive.function.client.ExchangeFunctions; import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.util.DefaultUriBuilderFactory; -import org.springframework.web.util.UriBuilderFactory; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeFalse; /** * @author Sebastien Deleuze + * @since 5.0 */ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -55,7 +51,7 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest @Before public void setup() throws Exception { // TODO: fix failing RxNetty tests - Assume.assumeFalse(this.server instanceof RxNettyHttpServer); + assumeFalse(this.server instanceof RxNettyHttpServer); super.setup(); this.webClient = WebClient.create("http://localhost:" + this.port); @@ -118,7 +114,7 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest String path = request.getURI().getPath(); if (path.endsWith("write-and-flush")) { Flux> responseBody = Flux - .intervalMillis(50) + .interval(Duration.ofMillis(50)) .map(l -> toDataBuffer("data" + l, response.bufferFactory())) .take(2) .map(Flux::just); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java index aac0ada406..8620dba03b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java @@ -258,6 +258,7 @@ public class BodyInsertersTests { interface SafeToSerialize {} + @SuppressWarnings("unused") private static class User { @JsonView(SafeToSerialize.class) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java index 21bcbe0ed0..61bbbe60b2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java @@ -77,7 +77,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return WebHttpHandlerBuilder.webHandler(webHandler).build(); } - + @Test public void mono() throws Exception { @@ -101,7 +101,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr assertEquals("John", body.get(0).getName()); assertEquals("Jane", body.get(1).getName()); } - + @Configuration static class TestConfiguration extends WebFluxConfigurationSupport { @@ -155,7 +155,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return new ServerResponseResultHandler(); } } - + private static class PersonHandler { @@ -171,10 +171,6 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr fromPublisher(Flux.just(person1, person2), Person.class)); } - public Mono view() { - return ServerResponse.ok().render("foo", "bar"); - } - } private static class Person { @@ -193,6 +189,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return this.name; } + @SuppressWarnings("unused") public void setName(String name) { this.name = name; } @@ -205,8 +202,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr if (o == null || getClass() != o.getClass()) { return false; } - Person - person = (Person) o; + Person person = (Person) o; return !(this.name != null ? !this.name.equals(person.name) : person.name != null); } @@ -220,5 +216,5 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return "Person{" + "name='" + this.name + '\'' + '}'; } } - + } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java index c699aa6965..eecd317310 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java @@ -105,6 +105,7 @@ public class MockServerRequest implements ServerRequest { } @Override + @SuppressWarnings("unchecked") public S body(BodyExtractor extractor, Map hints) { return (S) this.body; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java index 84f95d6698..6dba1d1e15 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java @@ -124,6 +124,7 @@ public class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunc return name; } + @SuppressWarnings("unused") public void setName(String name) { this.name = name; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java index 60bc3665c2..c5cccffe2e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java @@ -140,11 +140,11 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn } + @SuppressWarnings("unused") private static class Person { private String name; - @SuppressWarnings("unused") public Person() { } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java index d6cf346eb9..9a61b94f04 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java @@ -16,6 +16,7 @@ package org.springframework.web.reactive.resource; import java.io.IOException; +import java.time.Duration; import java.util.List; import org.junit.Test; @@ -45,7 +46,7 @@ public class PathResourceResolverTests { Resource location = new ClassPathResource("test/", PathResourceResolver.class); String path = "bar.css"; List locations = singletonList(location); - Resource actual = this.resolver.resolveResource(null, path, locations, null).blockMillis(5000); + Resource actual = this.resolver.resolveResource(null, path, locations, null).block(Duration.ofMillis(5000)); assertEquals(location.createRelative(path), actual); } @@ -54,7 +55,7 @@ public class PathResourceResolverTests { Resource location = new ClassPathResource("/"); String path = "org/springframework/web/reactive/resource/test/bar.css"; List locations = singletonList(location); - Resource actual = this.resolver.resolveResource(null, path, locations, null).blockMillis(5000); + Resource actual = this.resolver.resolveResource(null, path, locations, null).block(Duration.ofMillis(5000)); assertNotNull(actual); } @@ -79,7 +80,7 @@ public class PathResourceResolverTests { private void testCheckResource(Resource location, String requestPath) throws IOException { List locations = singletonList(location); - Resource actual = this.resolver.resolveResource(null, requestPath, locations, null).blockMillis(5000); + Resource actual = this.resolver.resolveResource(null, requestPath, locations, null).block(Duration.ofMillis(5000)); if (!location.createRelative(requestPath).exists() && !requestPath.contains(":")) { fail(requestPath + " doesn't actually exist as a relative path"); } @@ -95,7 +96,7 @@ public class PathResourceResolverTests { Resource location = new ClassPathResource("test/main.css", PathResourceResolver.class); String actual = this.resolver.resolveUrlPath("../testalternatepath/bar.css", - singletonList(location), null).blockMillis(5000); + singletonList(location), null).block(Duration.ofMillis(5000)); assertEquals("../testalternatepath/bar.css", actual); } @@ -105,7 +106,7 @@ public class PathResourceResolverTests { String locationUrl= new UrlResource(getClass().getResource("./test/")).getURL().toExternalForm(); Resource location = new UrlResource(locationUrl.replace("/springframework","/../org/springframework")); List locations = singletonList(location); - assertNotNull(this.resolver.resolveResource(null, "main.css", locations, null).blockMillis(5000)); + assertNotNull(this.resolver.resolveResource(null, "main.css", locations, null).block(Duration.ofMillis(5000))); } @Test // SPR-12747 @@ -118,7 +119,7 @@ public class PathResourceResolverTests { public void resolvePathRootResource() throws Exception { Resource webjarsLocation = new ClassPathResource("/META-INF/resources/webjars/", PathResourceResolver.class); String path = this.resolver.resolveUrlPathInternal( - "", singletonList(webjarsLocation), null).blockMillis(5000); + "", singletonList(webjarsLocation), null).block(Duration.ofMillis(5000)); assertNull(path); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java index 79564a0063..b2f47c9825 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java @@ -15,6 +15,7 @@ */ package org.springframework.web.reactive.resource; +import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -78,7 +79,7 @@ public class VersionResourceResolverTests { this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy)); Resource actual = this.resolver .resolveResourceInternal(null, file, this.locations, this.chain) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); assertEquals(expected, actual); verify(this.chain, times(1)).resolveResource(null, file, this.locations); @@ -93,7 +94,7 @@ public class VersionResourceResolverTests { this.resolver.setStrategyMap(Collections.emptyMap()); Resource actual = this.resolver .resolveResourceInternal(null, file, this.locations, this.chain) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); assertNull(actual); verify(this.chain, times(1)).resolveResource(null, file, this.locations); @@ -108,7 +109,7 @@ public class VersionResourceResolverTests { this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy)); Resource actual = this.resolver .resolveResourceInternal(null, file, this.locations, this.chain) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); assertNull(actual); verify(this.chain, times(1)).resolveResource(null, file, this.locations); @@ -128,7 +129,7 @@ public class VersionResourceResolverTests { this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy)); Resource actual = this.resolver .resolveResourceInternal(null, versionFile, this.locations, this.chain) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); assertNull(actual); verify(this.versionStrategy, times(1)).removeVersion(versionFile, version); @@ -149,7 +150,7 @@ public class VersionResourceResolverTests { this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy)); Resource actual = this.resolver .resolveResourceInternal(null, versionFile, this.locations, this.chain) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); assertNull(actual); verify(this.versionStrategy, times(1)).getResourceVersion(expected); @@ -171,7 +172,7 @@ public class VersionResourceResolverTests { this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy)); Resource actual = this.resolver .resolveResourceInternal(exchange, versionFile, this.locations, this.chain) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); assertEquals(expected.getFilename(), actual.getFilename()); verify(this.versionStrategy, times(1)).getResourceVersion(expected); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java index 67ed39341c..61e0748cc2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java @@ -104,7 +104,7 @@ public class HandlerMethodMappingTests { this.mapping.registerMapping(key1, this.handler, this.method1); this.mapping.registerMapping(key2, this.handler, this.method2); - List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1); + List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1); assertNotNull(directUrlMatches); assertEquals(1, directUrlMatches.size()); @@ -120,7 +120,7 @@ public class HandlerMethodMappingTests { this.mapping.registerMapping(key1, handler1, this.method1); this.mapping.registerMapping(key2, handler2, this.method1); - List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1); + List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1); assertNotNull(directUrlMatches); assertEquals(1, directUrlMatches.size()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsArgumentResolverTests.java index 1342e4bf43..dceb95ea50 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsArgumentResolverTests.java @@ -16,6 +16,8 @@ package org.springframework.web.reactive.result.method.annotation; +import java.time.Duration; + import org.junit.Before; import org.junit.Test; import reactor.core.publisher.Mono; @@ -107,7 +109,7 @@ public class ErrorsArgumentResolverTests { @Test(expected = IllegalArgumentException.class) public void resolveErrorsAfterMonoModelAttribute() throws Exception { MethodParameter parameter = this.testMethod.arg(BindingResult.class); - this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange).blockMillis(5000); + this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange).block(Duration.ofMillis(5000)); } @@ -119,12 +121,13 @@ public class ErrorsArgumentResolverTests { MethodParameter parameter = this.testMethod.arg(Errors.class); Object actual = this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); assertSame(this.bindingResult, actual); } + @SuppressWarnings("unused") private static class Foo { private String name; @@ -145,7 +148,6 @@ public class ErrorsArgumentResolverTests { } } - @SuppressWarnings("unused") void handle( @ModelAttribute Foo foo, Errors errors, diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JsonStreamingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JsonStreamingIntegrationTests.java index 3f559496e6..e379f571cf 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JsonStreamingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JsonStreamingIntegrationTests.java @@ -102,11 +102,11 @@ public class JsonStreamingIntegrationTests extends AbstractHttpHandlerIntegratio } } + @SuppressWarnings("unused") private static class Person { private String name; - @SuppressWarnings("unused") public Person() { } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java index 9ed507d979..e4aa494766 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java @@ -45,8 +45,6 @@ import org.springframework.http.MediaType; import org.springframework.http.codec.DecoderHttpMessageReader; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.validation.Errors; import org.springframework.validation.Validator; import org.springframework.validation.annotation.Validated; @@ -57,7 +55,6 @@ import org.springframework.web.method.ResolvableMethod; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; import org.springframework.web.server.UnsupportedMediaTypeStatusException; -import org.springframework.web.server.adapter.DefaultServerWebExchange; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -222,7 +219,7 @@ public class MessageReaderArgumentResolverTests { map.put("bar", "b1"); ResolvableType type = forClassWithGenerics(Map.class, String.class, String.class); MethodParameter param = this.testMethod.arg(type); - Map actual = resolveValue(param, body); + Map actual = resolveValue(param, body); assertEquals(map, actual); } @@ -335,13 +332,13 @@ public class MessageReaderArgumentResolverTests { @XmlRootElement + @SuppressWarnings("unused") private static class TestBean { private String foo; private String bar; - @SuppressWarnings("unused") public TestBean() { } @@ -426,7 +423,7 @@ public class MessageReaderArgumentResolverTests { } - @SuppressWarnings({"serial"}) + @SuppressWarnings({"serial", "unused"}) private static class SimpleBean implements Identifiable { private Long id; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java index 108953a724..25d226b4d3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java @@ -255,6 +255,7 @@ public class MessageWriterResultHandlerTests { return id; } + @SuppressWarnings("unused") public String getName() { return name; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java index 21a1f894f8..ab97efc882 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java @@ -245,7 +245,6 @@ public class ModelAttributeMethodArgumentResolverTests { } @Test - @SuppressWarnings("unchecked") public void validationErrorToSingle() throws Exception { MethodParameter parameter = this.testMethod @@ -256,7 +255,7 @@ public class ModelAttributeMethodArgumentResolverTests { Object value = resolvedArgumentMono.block(Duration.ofSeconds(5)); assertNotNull(value); assertTrue(value instanceof Single); - return Mono.from(RxReactiveStreams.toPublisher((Single) value)); + return Mono.from(RxReactiveStreams.toPublisher((Single) value)); }); } @@ -303,6 +302,7 @@ public class ModelAttributeMethodArgumentResolverTests { } + @SuppressWarnings("unused") private static class Foo { private String name; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java index a654844d91..4749ce0f74 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java @@ -17,6 +17,7 @@ package org.springframework.web.reactive.result.method.annotation; import java.lang.reflect.Method; +import java.time.Duration; import java.util.Collections; import java.util.List; import java.util.Map; @@ -73,7 +74,7 @@ public class ModelInitializerTests { WebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer(); BindingContext bindingContext = new InitBinderBindingContext(bindingInitializer, binderMethods); - this.modelInitializer.initModel(bindingContext, attributeMethods, this.exchange).blockMillis(5000); + this.modelInitializer.initModel(bindingContext, attributeMethods, this.exchange).block(Duration.ofMillis(5000)); WebExchangeDataBinder binder = bindingContext.createDataBinder(this.exchange, "name"); assertEquals(Collections.singletonList(validator), binder.getValidators()); @@ -85,7 +86,7 @@ public class ModelInitializerTests { assertEquals("Bean", ((TestBean) value).getName()); value = model.get("monoBean"); - assertEquals("Mono Bean", ((Mono) value).blockMillis(5000).getName()); + assertEquals("Mono Bean", ((Mono) value).block(Duration.ofMillis(5000)).getName()); value = model.get("singleBean"); assertEquals("Single Bean", ((Single) value).toBlocking().value().getName()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java index f0445824aa..ff331b5df7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java @@ -158,7 +158,7 @@ public class PathVariableMethodArgumentResolverTests { StepVerifier.create(mono) .consumeNextWith(value -> { assertTrue(value instanceof Optional); - assertFalse(((Optional) value).isPresent()); + assertFalse(((Optional) value).isPresent()); }) .expectComplete() .verify(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java index 2390d1e0e3..560910e6ae 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java @@ -129,7 +129,7 @@ public class RequestAttributeMethodArgumentResolverTests { assertNotNull(mono.block()); assertEquals(Optional.class, mono.block().getClass()); - assertFalse(((Optional) mono.block()).isPresent()); + assertFalse(((Optional) mono.block()).isPresent()); ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(new DefaultFormattingConversionService()); @@ -141,7 +141,7 @@ public class RequestAttributeMethodArgumentResolverTests { assertNotNull(mono.block()); assertEquals(Optional.class, mono.block().getClass()); - Optional optional = (Optional) mono.block(); + Optional optional = (Optional) mono.block(); assertTrue(optional.isPresent()); assertSame(foo, optional.get()); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java index fb76f81080..92ada731a3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java @@ -32,9 +32,7 @@ import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.SynthesizingMethodParameter; import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.mock.http.server.reactive.test.MockServerWebExchange; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.RequestHeader; @@ -42,7 +40,6 @@ import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.reactive.BindingContext; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebInputException; -import org.springframework.web.server.adapter.DefaultServerWebExchange; import static org.junit.Assert.*; @@ -237,7 +234,6 @@ public class RequestHeaderMethodArgumentResolverTests { } - @SuppressWarnings("unused") public void params( @RequestHeader(name = "name", defaultValue = "bar") String param1, @RequestHeader("name") String[] param2, diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java index f49ccd9c71..c9ad55f44d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java @@ -121,6 +121,7 @@ public class RequestMappingDataBindingIntegrationTests extends AbstractRequestMa } + @SuppressWarnings("unused") private static class Foo { private final Long id; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java index df9f75a9c6..ffb84790b2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java @@ -16,13 +16,14 @@ package org.springframework.web.reactive.result.method.annotation; +import java.time.Duration; + import org.junit.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -41,13 +42,14 @@ import static org.junit.Assert.*; * * @author Rossen Stoyanchev * @author Stephane Maldini + * @since 5.0 */ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTests { @Override protected ApplicationContext initApplicationContext() { AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext(); - wac.register(WebConfig.class); + wac.register(WebConfig.class, TestRestController.class); wac.refresh(); return wac; } @@ -80,14 +82,11 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr @Configuration @EnableWebFlux - @ComponentScan(resourcePattern = "**/RequestMappingIntegrationTests$*.class") - @SuppressWarnings({"unused", "WeakerAccess"}) static class WebConfig { } @RestController - @SuppressWarnings("unused") private static class TestRestController { @GetMapping("/param") @@ -97,7 +96,7 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr @GetMapping("/long-stream-result") public Publisher longStreamResponseBody() { - return Flux.intervalMillis(100).take(5); + return Flux.interval(Duration.ofMillis(100)).take(5); } @GetMapping("/object-stream-result") @@ -111,17 +110,16 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr private String name; - public Foo() { - } - public Foo(String name) { this.name = name; } + @SuppressWarnings("unused") public String getName() { return name; } + @SuppressWarnings("unused") public void setName(String name) { this.name = name; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java index d963f48dc4..f2c643cc9d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java @@ -601,12 +601,11 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq @XmlRootElement - @SuppressWarnings("WeakerAccess") + @SuppressWarnings("unused") private static class Person { private String name; - @SuppressWarnings("unused") public Person() { } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java index 18ec79d411..67af4ab530 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java @@ -16,18 +16,16 @@ package org.springframework.web.reactive.result.method.annotation; -import java.net.URISyntaxException; +import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.Map; -import org.junit.Before; import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RequestParam; @@ -48,17 +46,11 @@ import static org.springframework.web.method.MvcAnnotationPredicates.requestPara */ public class RequestParamMapMethodArgumentResolverTests { - private RequestParamMapMethodArgumentResolver resolver; + private RequestParamMapMethodArgumentResolver resolver = new RequestParamMapMethodArgumentResolver(new ReactiveAdapterRegistry()); private ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); - @Before - public void setup() throws Exception { - this.resolver = new RequestParamMapMethodArgumentResolver(new ReactiveAdapterRegistry()); - } - - @Test public void supportsParameter() { MethodParameter param = this.testMethod.annot(requestParam().name("")).arg(Map.class); @@ -114,11 +106,10 @@ public class RequestParamMapMethodArgumentResolverTests { private Object resolve(MethodParameter parameter, ServerWebExchange exchange) { - return this.resolver.resolveArgument(parameter, null, exchange).blockMillis(0); + return this.resolver.resolveArgument(parameter, null, exchange).block(Duration.ofMillis(0)); } - @SuppressWarnings("unused") public void handle( @RequestParam Map param1, @RequestParam MultiValueMap param2, diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java index e952d667ff..f817a55b70 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java @@ -132,7 +132,7 @@ public class SessionAttributeMethodArgumentResolverTests { Mono mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange); assertNotNull(mono.block()); assertEquals(Optional.class, mono.block().getClass()); - assertFalse(((Optional) mono.block()).isPresent()); + assertFalse(((Optional) mono.block()).isPresent()); ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(new DefaultFormattingConversionService()); @@ -144,7 +144,7 @@ public class SessionAttributeMethodArgumentResolverTests { assertNotNull(mono.block()); assertEquals(Optional.class, mono.block().getClass()); - Optional optional = (Optional) mono.block(); + Optional optional = (Optional) mono.block(); assertTrue(optional.isPresent()); assertSame(foo, optional.get()); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java index c49d03e439..4d8aa098ca 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java @@ -192,11 +192,11 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { } } + @SuppressWarnings("unused") private static class Person { private String name; - @SuppressWarnings("unused") public Person() { } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java index b683aa0a80..a9482ccf44 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java @@ -355,6 +355,7 @@ public class ViewResolutionResultHandlerTests { this.mediaTypes = Arrays.asList(mediaTypes); } + @SuppressWarnings("unused") public String getName() { return this.name; } @@ -387,6 +388,7 @@ public class ViewResolutionResultHandlerTests { this.name = name; } + @SuppressWarnings("unused") public String getName() { return this.name; } @@ -440,7 +442,7 @@ public class ViewResolutionResultHandlerTests { return null; } - Map map() { + Map map() { return null; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java index 2ff054b716..8eacb926d2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java @@ -18,6 +18,7 @@ package org.springframework.web.reactive.result.view.freemarker; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import java.time.Duration; import java.util.Locale; import freemarker.template.Configuration; @@ -106,7 +107,7 @@ public class FreeMarkerViewTests { ModelMap model = new ExtendedModelMap(); model.addAttribute("hello", "hi FreeMarker"); - view.render(model, null, this.exchange).blockMillis(5000); + view.render(model, null, this.exchange).block(Duration.ofMillis(5000)); StepVerifier.create(this.exchange.getResponse().getBody()) .consumeNextWith(buf -> assertEquals("hi FreeMarker", asString(buf))) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java index 645992f1e1..3bd14085ff 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java @@ -19,14 +19,12 @@ package org.springframework.web.reactive.result.view.script; import java.util.HashMap; import java.util.Map; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.StaticApplicationContext; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; @@ -42,13 +40,6 @@ import static org.junit.Assert.assertEquals; @Ignore("JRuby not compatible with JDK 9 yet") public class JRubyScriptTemplateTests { - private StaticApplicationContext context; - - @Before - public void setup() { - this.context = new StaticApplicationContext(); - } - @Test public void renderTemplate() throws Exception { Map model = new HashMap<>(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java index e52a737424..de445aea7d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,11 @@ package org.springframework.web.reactive.result.view.script; import java.util.HashMap; import java.util.Map; -import org.junit.Before; import org.junit.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.StaticApplicationContext; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; @@ -40,14 +38,6 @@ import static org.junit.Assert.assertEquals; */ public class JythonScriptTemplateTests { - private StaticApplicationContext context; - - - @Before - public void setup() { - this.context = new StaticApplicationContext(); - } - @Test public void renderTemplate() throws Exception { Map model = new HashMap<>(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java index 56d158a085..7844dcfec2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +20,12 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.junit.Before; import org.junit.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.context.support.StaticApplicationContext; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; @@ -42,13 +40,6 @@ import static org.junit.Assert.assertEquals; */ public class KotlinScriptTemplateTests { - private StaticApplicationContext context; - - @Before - public void setup() { - this.context = new StaticApplicationContext(); - } - @Test public void renderTemplateWithFrenchLocale() throws Exception { Map model = new HashMap<>(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java index 158370ebf3..46bc4e18af 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,11 @@ package org.springframework.web.reactive.result.view.script; import java.util.HashMap; import java.util.Map; -import org.junit.Before; import org.junit.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.StaticApplicationContext; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; @@ -34,19 +32,12 @@ import org.springframework.mock.http.server.reactive.test.MockServerWebExchange; import static org.junit.Assert.assertEquals; /** - * Unit tests for pure Javascript templates running on Nashorn engine. + * Unit tests for pure JavaScript templates running on Nashorn engine. * * @author Sebastien Deleuze */ public class NashornScriptTemplateTests { - private StaticApplicationContext context; - - @Before - public void setup() { - this.context = new StaticApplicationContext(); - } - @Test public void renderTemplate() throws Exception { Map model = new HashMap<>(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java index 81103731f2..9fa4b3fa07 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public class ScriptTemplateViewResolverTests { ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver(); Assert.assertEquals(ScriptTemplateView.class, resolver.requiredViewClass()); DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver); - Class viewClass = (Class) viewAccessor.getPropertyValue("viewClass"); + Class viewClass = (Class) viewAccessor.getPropertyValue("viewClass"); Assert.assertEquals(ScriptTemplateView.class, viewClass); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java index 93d6892556..f54bd213be 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,8 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.reactive.socket; +import java.time.Duration; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; @@ -40,7 +42,6 @@ import static org.junit.Assert.assertThat; * Integration tests with server-side {@link WebSocketHandler}s. * @author Rossen Stoyanchev */ -@SuppressWarnings({"unused", "WeakerAccess"}) public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { @@ -62,9 +63,9 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests .thenMany(session.receive().take(count).map(WebSocketMessage::getPayloadAsText)) .subscribeWith(output) .then()) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); - assertEquals(input.collectList().blockMillis(5000), output.collectList().blockMillis(5000)); + assertEquals(input.collectList().block(Duration.ofMillis(5000)), output.collectList().block(Duration.ofMillis(5000))); } @Test @@ -91,13 +92,13 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests .then(); } }) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); HandshakeInfo info = infoRef.get(); assertThat(info.getHeaders().getFirst("Upgrade"), Matchers.equalToIgnoringCase("websocket")); assertEquals(protocol, info.getHeaders().getFirst("Sec-WebSocket-Protocol")); assertEquals("Wrong protocol accepted", protocol, info.getSubProtocol().orElse("none")); - assertEquals("Wrong protocol detected on the server side", protocol, output.blockMillis(5000)); + assertEquals("Wrong protocol detected on the server side", protocol, output.block(Duration.ofMillis(5000))); } @Test @@ -111,9 +112,9 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests .map(WebSocketMessage::getPayloadAsText) .subscribeWith(output) .then()) - .blockMillis(5000); + .block(Duration.ofMillis(5000)); - assertEquals("my-header:my-value", output.blockMillis(5000)); + assertEquals("my-header:my-value", output.block(Duration.ofMillis(5000))); } @@ -174,7 +175,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests // https://github.com/ReactiveX/RxNetty/issues/560 private static Mono doSend(WebSocketSession session, Publisher output) { - return session.send(Mono.delayMillis(100).thenMany(output)); + return session.send(Mono.delay(Duration.ofMillis(100)).thenMany(output)); } }