diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java index 5c9a028479..a47ed3eb50 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java @@ -66,7 +66,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { public static final int DEFAULT_CACHE_LIMIT = 1024; /** Static evaluation context to reuse. */ - private static EvaluationContext messageEvalContext = + private static final EvaluationContext messageEvalContext = SimpleEvaluationContext.forPropertyAccessors(new SimpMessageHeaderPropertyAccessor()).build(); @@ -130,7 +130,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { * @since 4.2 */ public void setSelectorHeaderName(@Nullable String selectorHeaderName) { - this.selectorHeaderName = StringUtils.hasText(selectorHeaderName) ? selectorHeaderName : null; + this.selectorHeaderName = (StringUtils.hasText(selectorHeaderName) ? selectorHeaderName : null); } /** diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index ca4954d13b..bc7c28a16d 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -1017,9 +1017,10 @@ public class HttpHeaders implements MultiValueMap, Serializable } /** - * Return the value of the required {@code Host} header. - *

If the header value does not contain a port, the returned - * {@linkplain InetSocketAddress#getPort() port} will be {@code 0}. + * Return the value of the {@code Host} header, if available. + *

If the header value does not contain a port, the + * {@linkplain InetSocketAddress#getPort() port} in the returned address will + * be {@code 0}. * @since 5.0 */ @Nullable diff --git a/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java b/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java index c40ae6355f..ce135c1287 100644 --- a/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java +++ b/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java @@ -90,7 +90,7 @@ public interface ServerWebExchange { @SuppressWarnings("unchecked") default T getRequiredAttribute(String name) { T value = getAttribute(name); - Assert.notNull(value, () -> "Required attribute '" + name + "' is missing."); + Assert.notNull(value, () -> "Required attribute '" + name + "' is missing"); return value; } @@ -124,7 +124,6 @@ public interface ServerWebExchange { /** * Return the form data from the body of the request if the Content-Type is * {@code "application/x-www-form-urlencoded"} or an empty map otherwise. - * *

Note: calling this method causes the request body to * be read and parsed in full and the resulting {@code MultiValueMap} is * cached so that this method is safe to call more than once. @@ -134,7 +133,6 @@ public interface ServerWebExchange { /** * Return the parts of a multipart request if the Content-Type is * {@code "multipart/form-data"} or an empty map otherwise. - * *

Note: calling this method causes the request body to * be read and parsed in full and the resulting {@code MultiValueMap} is * cached so that this method is safe to call more than once. @@ -150,10 +148,9 @@ public interface ServerWebExchange { /** * Return the {@link ApplicationContext} associated with the web application, * if it was initialized with one via - * {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext - * WebHttpHandlerBuilder#applicationContext}. + * {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext}. * @since 5.0.3 - * @see org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext(ApplicationContext) + * @see org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext */ @Nullable ApplicationContext getApplicationContext(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java index 862857409b..2cdf4ab709 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java @@ -99,6 +99,8 @@ public abstract class BodyInserters { public static > BodyInserter fromPublisher( P publisher, Class elementClass) { + Assert.notNull(publisher, "Publisher must not be null"); + Assert.notNull(elementClass, "Element Class must not be null"); return (message, context) -> writeWithMessageWriters(message, context, publisher, ResolvableType.forClass(elementClass)); } @@ -109,16 +111,18 @@ public abstract class BodyInserters { * {@link org.springframework.web.reactive.function.client.WebClient WebClient} and * {@link org.springframework.web.reactive.function.server.ServerResponse ServerResponse}. * @param publisher the publisher to write with - * @param typeRef the type of elements contained in the publisher + * @param typeReference the type of elements contained in the publisher * @param the type of the elements contained in the publisher * @param

the {@code Publisher} type * @return the inserter to write a {@code Publisher} */ public static > BodyInserter fromPublisher( - P publisher, ParameterizedTypeReference typeRef) { + P publisher, ParameterizedTypeReference typeReference) { + Assert.notNull(publisher, "Publisher must not be null"); + Assert.notNull(typeReference, "ParameterizedTypeReference must not be null"); return (message, context) -> - writeWithMessageWriters(message, context, publisher, ResolvableType.forType(typeRef.getType())); + writeWithMessageWriters(message, context, publisher, ResolvableType.forType(typeReference.getType())); } /** @@ -130,6 +134,7 @@ public abstract class BodyInserters { * @return the inserter to write a {@code Publisher} */ public static BodyInserter fromResource(T resource) { + Assert.notNull(resource, "Resource must not be null"); return (outputMessage, context) -> { ResolvableType elementType = RESOURCE_TYPE; HttpMessageWriter writer = findWriter(context, elementType, null); @@ -151,6 +156,7 @@ public abstract class BodyInserters { public static >> BodyInserter fromServerSentEvents( S eventsPublisher) { + Assert.notNull(eventsPublisher, "Publisher must not be null"); return (serverResponse, context) -> { ResolvableType elmentType = SSE_TYPE; MediaType mediaType = MediaType.TEXT_EVENT_STREAM; @@ -163,13 +169,11 @@ public abstract class BodyInserters { * Return a {@link FormInserter} to write the given {@code MultiValueMap} * as URL-encoded form data. The returned inserter allows for additional * entries to be added via {@link FormInserter#with(String, Object)}. - * *

Note that you can also use the {@code syncBody(Object)} method in the * request builders of both the {@code WebClient} and {@code WebTestClient}. * In that case the setting of the request content type is also not required, * just be sure the map contains String values only or otherwise it would be * interpreted as a multipart request. - * * @param formData the form data to write to the output message * @return the inserter that allows adding more form data */ diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java index 7130039994..38b66ccb92 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java @@ -106,8 +106,7 @@ public interface ClientRequest { String logPrefix(); /** - * Writes this request to the given {@link ClientHttpRequest}. - * + * Write this request to the given {@link ClientHttpRequest}. * @param request the client http request to write to * @param strategies the strategies to use when writing * @return {@code Mono} to indicate when writing is complete diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java index 25a29e6a85..1f4bed42aa 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java @@ -64,13 +64,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder { private BodyInserter body = BodyInserters.empty(); - public DefaultClientRequestBuilder(HttpMethod method, URI url) { - Assert.notNull(method, "HttpMethod must not be null"); - Assert.notNull(url, "URI must not be null"); - this.method = method; - this.url = url; - } - public DefaultClientRequestBuilder(ClientRequest other) { Assert.notNull(other, "ClientRequest must not be null"); this.method = other.method(); @@ -81,17 +74,24 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder { body(other.body()); } + public DefaultClientRequestBuilder(HttpMethod method, URI url) { + Assert.notNull(method, "HttpMethod must not be null"); + Assert.notNull(url, "URI must not be null"); + this.method = method; + this.url = url; + } + @Override public ClientRequest.Builder method(HttpMethod method) { - Assert.notNull(method, "'method' must not be null"); + Assert.notNull(method, "HttpMethod must not be null"); this.method = method; return this; } @Override public ClientRequest.Builder url(URI url) { - Assert.notNull(url, "'url' must not be null"); + Assert.notNull(url, "URI must not be null"); this.url = url; return this; } @@ -126,9 +126,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder { @Override public > ClientRequest.Builder body(P publisher, Class elementClass) { - Assert.notNull(publisher, "'publisher' must not be null"); - Assert.notNull(elementClass, "'elementClass' must not be null"); - this.body = BodyInserters.fromPublisher(publisher, elementClass); return this; } @@ -137,9 +134,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder { public > ClientRequest.Builder body( P publisher, ParameterizedTypeReference typeReference) { - Assert.notNull(publisher, "'publisher' must not be null"); - Assert.notNull(typeReference, "'typeReference' must not be null"); - this.body = BodyInserters.fromPublisher(publisher, typeReference); return this; } @@ -184,7 +178,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder { private final String logPrefix; - public BodyInserterRequest(HttpMethod method, URI url, HttpHeaders headers, MultiValueMap cookies, BodyInserter body, Map attributes) { @@ -200,7 +193,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder { this.logPrefix = "[" + id + "] "; } - @Override public HttpMethod method() { return this.method; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java index b6d4056e3d..9ccc2687e0 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java @@ -116,9 +116,9 @@ public abstract class ExchangeFilterFunctions { @Deprecated public static ExchangeFilterFunction basicAuthentication() { return (request, next) -> { - Credentials cred = (Credentials) request - .attribute(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE).orElse(null); - if (cred != null) { + Object attr = request.attributes().get(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE); + if (attr instanceof Credentials) { + Credentials cred = (Credentials) attr; return next.exchange(ClientRequest.from(request) .headers(headers -> headers.setBasicAuth(cred.username, cred.password)) .build()); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java index ba86ac5caa..ecd462da75 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java @@ -140,7 +140,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder { @Override public ServerRequest.Builder body(Flux body) { - Assert.notNull(body, "'body' must not be null"); + Assert.notNull(body, "Body must not be null"); releaseBody(); this.body = body; return this; @@ -148,7 +148,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder { @Override public ServerRequest.Builder body(String body) { - Assert.notNull(body, "'body' must not be null"); + Assert.notNull(body, "Body must not be null"); releaseBody(); DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); this.body = Flux.just(body). @@ -165,7 +165,6 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder { @Override public ServerRequest.Builder attribute(String name, Object value) { - Assert.notNull(name, "'name' must not be null"); this.attributes.put(name, value); return this; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java index b7d73c26a7..b8b4f58288 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java @@ -39,6 +39,7 @@ import static org.mockito.Mockito.*; /** * Unit tests for {@link DefaultWebClient}. + * * @author Rossen Stoyanchev */ public class DefaultWebClientTests { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java index 9374353b98..f2df8d5198 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java @@ -38,6 +38,7 @@ import static org.mockito.Mockito.*; /** * Unit tests for {@link ExchangeFilterFunctions}. + * * @author Arjen Poutsma */ public class ExchangeFilterFunctionsTests { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java index 919b635219..70fe3ee5f5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java @@ -42,6 +42,7 @@ import static org.junit.Assert.*; /** * WebClient integration tests focusing on data buffer management. + * * @author Rossen Stoyanchev */ public class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTestCase { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java index 79100893a1..72c08b13c0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java @@ -75,13 +75,13 @@ public class WebClientIntegrationTests { @Parameterized.Parameters(name = "webClient [{0}]") public static Object[][] arguments() { - return new Object[][] { {new JettyClientHttpConnector()}, {new ReactorClientHttpConnector()} }; } + @Before public void setup() { this.server = new MockWebServer(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java index 16319115a0..3629ef88bd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java @@ -62,6 +62,7 @@ public class DefaultServerResponseBuilderTests { } }; + @Test public void from() { ServerResponse other = ServerResponse.ok().header("foo", "bar").build().block(); @@ -383,5 +384,4 @@ public class DefaultServerResponseBuilderTests { .verify(); } - } 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 7ef150614d..8a30da2bf6 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 @@ -43,9 +43,8 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import org.springframework.web.util.pattern.PathPattern; import static org.junit.Assert.*; -import static org.springframework.web.reactive.function.BodyInserters.fromPublisher; -import static org.springframework.web.reactive.function.server.RouterFunctions.nest; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.BodyInserters.*; +import static org.springframework.web.reactive.function.server.RouterFunctions.*; /** * Tests the use of {@link HandlerFunction} and {@link RouterFunction} in a @@ -134,7 +133,6 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return new AttributesHandler(); } - @Bean public RouterFunction> monoRouterFunction(PersonHandler personHandler) { return route(RequestPredicates.GET("/mono"), personHandler::mono); @@ -150,7 +148,6 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return nest(RequestPredicates.GET("/attributes"), route(RequestPredicates.GET("/{foo}"), attributesHandler::attributes)); } - } @@ -167,16 +164,15 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return ServerResponse.ok().body( fromPublisher(Flux.just(person1, person2), Person.class)); } - } + private static class AttributesHandler { @SuppressWarnings("unchecked") public Mono attributes(ServerRequest request) { assertTrue(request.attributes().containsKey(RouterFunctions.REQUEST_ATTRIBUTE)); - assertTrue(request.attributes() - .containsKey(HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE)); + assertTrue(request.attributes().containsKey(HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE)); Map pathVariables = (Map) request.attributes().get(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE); @@ -203,9 +199,9 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return ServerResponse.ok().build(); } - } + @Controller public static class PersonController { @@ -216,6 +212,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr } } + private static class Person { private String name; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java index 7381d1744d..07e73ecca5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -44,21 +44,6 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio private final WebClient webClient = WebClient.create(); - @Test - public void fixedLocale() { - Mono result = webClient - .get() - .uri("http://localhost:" + this.port + "/") - .exchange(); - - StepVerifier - .create(result) - .consumeNextWith(response -> { - assertEquals(HttpStatus.OK, response.statusCode()); - assertEquals(Locale.GERMANY, response.headers().asHttpHeaders().getContentLanguage()); - }) - .verifyComplete(); - } @Override protected RouterFunction routerFunction() { @@ -77,6 +62,24 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio .build(); } + + @Test + public void fixedLocale() { + Mono result = webClient + .get() + .uri("http://localhost:" + this.port + "/") + .exchange(); + + StepVerifier + .create(result) + .consumeNextWith(response -> { + assertEquals(HttpStatus.OK, response.statusCode()); + assertEquals(Locale.GERMANY, response.headers().asHttpHeaders().getContentLanguage()); + }) + .verifyComplete(); + } + + private static class DummyViewResolver implements ViewResolver { @Override @@ -85,6 +88,7 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio } } + private static class DummyView implements View { private final Locale locale; @@ -105,4 +109,5 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio return Mono.empty(); } } + } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java index 753af2eb4e..7d1dd7b337 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -69,9 +69,9 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt return HandlerStrategies.builder() .viewResolver(new DummyViewResolver()) .build(); - } + @Test public void normal() { ResponseEntity result = @@ -109,6 +109,7 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt return result; } + private static class RenderingResponseHandler { public Mono render(ServerRequest request) { @@ -116,7 +117,6 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt .modelAttribute("bar", "baz") .build(); } - } private static class DummyViewResolver implements ViewResolver { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java index 3f633a210c..360689930a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java index 3d2210916f..22b140ba2f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java @@ -209,7 +209,6 @@ public class RouterFunctionBuilderTests { StepVerifier.create(barResponseMono) .expectNext(500) .verifyComplete(); - } -} \ No newline at end of file +} diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java index e73bfe3081..6238a7ef53 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java @@ -35,8 +35,8 @@ import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import static org.junit.Assert.*; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.RequestPredicates.*; +import static org.springframework.web.reactive.function.server.RouterFunctions.*; /** * @author Arjen Poutsma @@ -45,6 +45,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr private final RestTemplate restTemplate = new RestTemplate(); + @Override protected HttpHandler createHttpHandler() { AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext(); @@ -54,6 +55,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(wac)).build(); } + @Test public void nested() { ResponseEntity result = this.restTemplate @@ -83,6 +85,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr } } + static class Handler { public Mono handle(ServerRequest request) { @@ -90,7 +93,4 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr } } - - - } \ No newline at end of file diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java index 303607b3c9..e538d4a584 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java @@ -21,7 +21,6 @@ import java.util.Collections; import java.util.Map; import java.util.Optional; -import org.junit.Before; import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -44,15 +43,10 @@ import static org.mockito.Mockito.*; */ public class ServerRequestWrapperTests { - private ServerRequest mockRequest; + private final ServerRequest mockRequest = mock(ServerRequest.class); - private ServerRequestWrapper wrapper; + private final ServerRequestWrapper wrapper = new ServerRequestWrapper(mockRequest); - @Before - public void createWrapper() { - mockRequest = mock(ServerRequest.class); - wrapper = new ServerRequestWrapper(mockRequest); - } @Test public void request() {