diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/BindingContextTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/BindingContextTests.java index d7662d790e..f244d9e681 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/BindingContextTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/BindingContextTests.java @@ -37,7 +37,7 @@ import static org.mockito.BDDMockito.when; /** * Tests for {@link BindingContext}. */ -public class BindingContextTests { +class BindingContextTests { @Test void jakartaValidatorExcludedWhenMethodValidationApplicable() { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java index 800c22e5bf..c936604a3f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -78,7 +78,7 @@ public class DispatcherHandlerErrorTests { @BeforeEach - public void setup() { + void setup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(TestConfig.class); context.refresh(); @@ -88,7 +88,7 @@ public class DispatcherHandlerErrorTests { @Test - public void noHandler() { + void noHandler() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/does-not-exist")); Mono mono = this.dispatcherHandler.handle(exchange); @@ -106,7 +106,7 @@ public class DispatcherHandlerErrorTests { } @Test - public void noStaticResource() { + void noStaticResource() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(StaticResourceConfig.class); context.refresh(); @@ -128,7 +128,7 @@ public class DispatcherHandlerErrorTests { } @Test - public void controllerReturnsMonoError() { + void controllerReturnsMonoError() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/error-signal")); Mono publisher = this.dispatcherHandler.handle(exchange); @@ -138,7 +138,7 @@ public class DispatcherHandlerErrorTests { } @Test - public void controllerThrowsException() { + void controllerThrowsException() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/raise-exception")); Mono publisher = this.dispatcherHandler.handle(exchange); @@ -148,7 +148,7 @@ public class DispatcherHandlerErrorTests { } @Test - public void unknownReturnType() { + void unknownReturnType() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/unknown-return-type")); Mono publisher = this.dispatcherHandler.handle(exchange); @@ -161,7 +161,7 @@ public class DispatcherHandlerErrorTests { } @Test - public void responseBodyMessageConversionError() { + void responseBodyMessageConversionError() { ServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.post("/request-body").accept(APPLICATION_JSON).body("body")); @@ -173,7 +173,7 @@ public class DispatcherHandlerErrorTests { } @Test - public void requestBodyError() { + void requestBodyError() { ServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.post("/request-body").body(Mono.error(EXCEPTION))); @@ -185,7 +185,7 @@ public class DispatcherHandlerErrorTests { } @Test - public void webExceptionHandler() { + void webExceptionHandler() { ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/unknown-argument-type")); List handlers = Collections.singletonList(new ServerError500ExceptionHandler()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java index 44b8dd9f2e..45e908759e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java @@ -48,7 +48,7 @@ import static org.mockito.Mockito.withSettings; * * @author Rossen Stoyanchev */ -public class DispatcherHandlerTests { +class DispatcherHandlerTests { private static final MethodParameter RETURN_TYPE = ResolvableMethod.on(DispatcherHandler.class).named("handle").resolveReturnType(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java index 20adf4054b..44c65a5251 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java @@ -33,13 +33,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * * @author Rossen Stoyanchev */ -public class HeaderContentTypeResolverTests { +class HeaderContentTypeResolverTests { private final HeaderContentTypeResolver resolver = new HeaderContentTypeResolver(); @Test - public void resolveMediaTypes() throws Exception { + void resolveMediaTypes() { String header = "text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c"; List mediaTypes = this.resolver.resolveMediaTypes( MockServerWebExchange.from(MockServerHttpRequest.get("/").header("accept", header))); @@ -52,7 +52,7 @@ public class HeaderContentTypeResolverTests { } @Test - public void resolveMediaTypesParseError() throws Exception { + void resolveMediaTypesParseError() { String header = "textplain; q=0.5"; assertThatExceptionOfType(NotAcceptableStatusException.class).isThrownBy(() -> this.resolver.resolveMediaTypes( diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java index e7c0cd8c74..6370f1df00 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java @@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * * @author Rossen Stoyanchev */ -public class ParameterContentTypeResolverTests { +class ParameterContentTypeResolverTests { @Test - public void noKey() { + void noKey() { ParameterContentTypeResolver resolver = new ParameterContentTypeResolver(Collections.emptyMap()); ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); List mediaTypes = resolver.resolveMediaTypes(exchange); @@ -48,14 +48,14 @@ public class ParameterContentTypeResolverTests { } @Test - public void noMatchForKey() { + void noMatchForKey() { ParameterContentTypeResolver resolver = new ParameterContentTypeResolver(Collections.emptyMap()); assertThatExceptionOfType(NotAcceptableStatusException.class).isThrownBy(() -> resolver.resolveMediaTypes(createExchange("blah"))); } @Test - public void resolveKeyFromRegistrations() { + void resolveKeyFromRegistrations() { ServerWebExchange exchange = createExchange("html"); Map mapping = Collections.emptyMap(); @@ -70,7 +70,7 @@ public class ParameterContentTypeResolverTests { } @Test - public void resolveKeyThroughMediaTypeFactory() { + void resolveKeyThroughMediaTypeFactory() { ServerWebExchange exchange = createExchange("xls"); RequestedContentTypeResolver resolver = new ParameterContentTypeResolver(Collections.emptyMap()); List mediaTypes = resolver.resolveMediaTypes(exchange); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java index e317c6f7af..74a3489c98 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class RequestedContentTypeResolverBuilderTests { +class RequestedContentTypeResolverBuilderTests { @Test void defaultSettings() { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java index bb6001be23..f668871adb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -31,25 +31,25 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Sebastien Deleuze */ -public class CorsRegistryTests { +class CorsRegistryTests { private final CorsRegistry registry = new CorsRegistry(); @Test - public void noMapping() { + void noMapping() { assertThat(this.registry.getCorsConfigurations()).isEmpty(); } @Test - public void multipleMappings() { + void multipleMappings() { this.registry.addMapping("/foo"); this.registry.addMapping("/bar"); assertThat(this.registry.getCorsConfigurations()).hasSize(2); } @Test - public void customizedMapping() { + void customizedMapping() { this.registry.addMapping("/foo").allowedOrigins("https://domain2.com", "https://domain2.com") .allowedMethods("DELETE").allowCredentials(true).allowPrivateNetwork(true) .allowedHeaders("header1", "header2").exposedHeaders("header3", "header4").maxAge(3600); @@ -66,7 +66,7 @@ public class CorsRegistryTests { } @Test - public void allowCredentials() { + void allowCredentials() { this.registry.addMapping("/foo").allowCredentials(true); CorsConfiguration config = this.registry.getCorsConfigurations().get("/foo"); assertThat(config.getAllowedOrigins()) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationIntegrationTests.java index 97c99e520f..d146f91640 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -40,12 +40,12 @@ import static org.mockito.Mockito.mock; * * @author Stephane Nicoll */ -public class DelegatingWebFluxConfigurationIntegrationTests { +class DelegatingWebFluxConfigurationIntegrationTests { private AnnotationConfigApplicationContext context; @AfterEach - public void closeContext() { + void closeContext() { if (this.context != null) { this.context.close(); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java index 2b14bfb72d..2a068aaa2a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -71,7 +71,7 @@ public class DelegatingWebFluxConfigurationTests { @BeforeEach - public void setup() { + void setup() { delegatingConfig = new DelegatingWebFluxConfiguration(); delegatingConfig.setApplicationContext(new StaticApplicationContext()); given(webFluxConfigurer.getValidator()).willReturn(null); @@ -81,7 +81,7 @@ public class DelegatingWebFluxConfigurationTests { @Test - public void requestMappingHandlerMapping() { + void requestMappingHandlerMapping() { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); delegatingConfig.requestMappingHandlerMapping(delegatingConfig.webFluxContentTypeResolver()); @@ -91,7 +91,7 @@ public class DelegatingWebFluxConfigurationTests { } @Test - public void requestMappingHandlerAdapter() { + void requestMappingHandlerAdapter() { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); ReactiveAdapterRegistry reactiveAdapterRegistry = delegatingConfig.webFluxAdapterRegistry(); ServerCodecConfigurer serverCodecConfigurer = delegatingConfig.serverCodecConfigurer(); @@ -116,7 +116,7 @@ public class DelegatingWebFluxConfigurationTests { } @Test - public void resourceHandlerMapping() { + void resourceHandlerMapping() { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); willAnswer(invocation -> { ResourceHandlerRegistry registry = invocation.getArgument(0); @@ -142,7 +142,7 @@ public class DelegatingWebFluxConfigurationTests { } @Test - public void responseBodyResultHandler() { + void responseBodyResultHandler() { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); delegatingConfig.responseBodyResultHandler( delegatingConfig.webFluxAdapterRegistry(), @@ -154,7 +154,7 @@ public class DelegatingWebFluxConfigurationTests { } @Test - public void viewResolutionResultHandler() { + void viewResolutionResultHandler() { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); delegatingConfig.viewResolutionResultHandler(delegatingConfig.webFluxAdapterRegistry(), delegatingConfig.webFluxContentTypeResolver()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java index 8d64b26a36..c2cd439cb3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java @@ -149,8 +149,8 @@ class ResourceHandlerRegistryTests { List transformers = handler.getResourceTransformers(); assertThat(transformers).hasSize(2); - assertThat(transformers).element(0).isInstanceOf(CachingResourceTransformer.class); - assertThat(transformers).element(1).isEqualTo(mockTransformer); + assertThat(transformers.get(0)).isInstanceOf(CachingResourceTransformer.class); + assertThat(transformers.get(1)).isEqualTo(mockTransformer); Mockito.verify(mockTransformer).setResourceUrlProvider(resourceUrlProvider); } @@ -191,7 +191,6 @@ class ResourceHandlerRegistryTests { } @Test - @SuppressWarnings("deprecation") void resourceChainWithOverrides() { CachingResourceResolver cachingResolver = mock(); VersionResourceResolver versionResolver = mock(); @@ -211,16 +210,11 @@ class ResourceHandlerRegistryTests { ResourceWebHandler handler = getHandler("/resources/**"); List resolvers = handler.getResourceResolvers(); - assertThat(resolvers).hasSize(4); - assertThat(resolvers).element(0).isSameAs(cachingResolver); - assertThat(resolvers).element(1).isSameAs(versionResolver); - assertThat(resolvers).element(2).isSameAs(webjarsResolver); - assertThat(resolvers).element(3).isSameAs(pathResourceResolver); + assertThat(resolvers).containsExactly( + cachingResolver, versionResolver, webjarsResolver, pathResourceResolver); List transformers = handler.getResourceTransformers(); - assertThat(transformers).hasSize(2); - assertThat(transformers).element(0).isSameAs(cachingTransformer); - assertThat(transformers).element(1).isSameAs(cssLinkTransformer); + assertThat(transformers).containsExactly(cachingTransformer, cssLinkTransformer); } @Test diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java index 725101487b..5e89f09fcd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java @@ -41,13 +41,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rossen Stoyanchev * @author Sebastien Deleuze */ -public class ViewResolverRegistryTests { +class ViewResolverRegistryTests { private ViewResolverRegistry registry; @BeforeEach - public void setup() { + void setup() { StaticWebApplicationContext context = new StaticWebApplicationContext(); context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class); context.registerSingleton("scriptTemplateConfigurer", ScriptTemplateConfigurer.class); @@ -56,12 +56,12 @@ public class ViewResolverRegistryTests { @Test - public void order() { + void order() { assertThat(this.registry.getOrder()).isEqualTo(Ordered.LOWEST_PRECEDENCE); } @Test - public void hasRegistrations() { + void hasRegistrations() { assertThat(this.registry.hasRegistrations()).isFalse(); this.registry.freeMarker(); @@ -69,23 +69,22 @@ public class ViewResolverRegistryTests { } @Test - public void noResolvers() { + void noResolvers() { assertThat(this.registry.getViewResolvers()).isNotNull(); assertThat(this.registry.getViewResolvers()).isEmpty(); assertThat(this.registry.hasRegistrations()).isFalse(); } @Test - public void customViewResolver() { + void customViewResolver() { UrlBasedViewResolver viewResolver = new UrlBasedViewResolver(); this.registry.viewResolver(viewResolver); - assertThat(this.registry.getViewResolvers()).element(0).isSameAs(viewResolver); - assertThat(this.registry.getViewResolvers()).hasSize(1); + assertThat(this.registry.getViewResolvers()).containsExactly(viewResolver); } @Test - public void defaultViews() throws Exception { + void defaultViews() { View view = new HttpMessageWriterView(new Jackson2JsonEncoder()); this.registry.defaultViews(view); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java index a9237ab746..9d8073765c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java @@ -44,6 +44,7 @@ import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.codec.xml.Jaxb2XmlDecoder; import org.springframework.http.codec.xml.Jaxb2XmlEncoder; +import org.springframework.lang.Nullable; import org.springframework.util.MimeType; import org.springframework.util.MimeTypeUtils; import org.springframework.util.MultiValueMap; @@ -94,12 +95,13 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * * @author Rossen Stoyanchev */ -public class WebFluxConfigurationSupportTests { +class WebFluxConfigurationSupportTests { @Test - public void requestMappingHandlerMapping() { + void requestMappingHandlerMapping() { ApplicationContext context = loadConfig(WebFluxConfig.class); - final Field field = ReflectionUtils.findField(PathPatternParser.class, "matchOptionalTrailingSeparator"); + Field field = ReflectionUtils.findField(PathPatternParser.class, "matchOptionalTrailingSeparator"); + assertThat(field).isNotNull(); ReflectionUtils.makeAccessible(field); String name = "requestMappingHandlerMapping"; @@ -109,9 +111,7 @@ public class WebFluxConfigurationSupportTests { assertThat(mapping.getOrder()).isEqualTo(0); PathPatternParser patternParser = mapping.getPathPatternParser(); - assertThat(patternParser).isNotNull(); - boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser); - assertThat(matchOptionalTrailingSlash).isFalse(); + assertThat(patternParser).hasFieldOrPropertyWithValue("matchOptionalTrailingSeparator", false); name = "webFluxContentTypeResolver"; RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class); @@ -123,7 +123,7 @@ public class WebFluxConfigurationSupportTests { } @Test - public void customPathMatchConfig() { + void customPathMatchConfig() { ApplicationContext context = loadConfig(CustomPatchMatchConfig.class); String name = "requestMappingHandlerMapping"; @@ -137,7 +137,7 @@ public class WebFluxConfigurationSupportTests { } @Test - public void requestMappingHandlerAdapter() { + void requestMappingHandlerAdapter() { ApplicationContext context = loadConfig(WebFluxConfig.class); String name = "requestMappingHandlerAdapter"; @@ -175,7 +175,7 @@ public class WebFluxConfigurationSupportTests { } @Test - public void customMessageConverterConfig() { + void customMessageConverterConfig() { ApplicationContext context = loadConfig(CustomMessageConverterConfig.class); String name = "requestMappingHandlerAdapter"; @@ -190,7 +190,7 @@ public class WebFluxConfigurationSupportTests { } @Test - public void responseEntityResultHandler() { + void responseEntityResultHandler() { ApplicationContext context = loadConfig(WebFluxConfig.class); String name = "responseEntityResultHandler"; @@ -218,7 +218,7 @@ public class WebFluxConfigurationSupportTests { } @Test - public void responseBodyResultHandler() { + void responseBodyResultHandler() { ApplicationContext context = loadConfig(WebFluxConfig.class); String name = "responseBodyResultHandler"; @@ -246,7 +246,7 @@ public class WebFluxConfigurationSupportTests { } @Test - public void viewResolutionResultHandler() { + void viewResolutionResultHandler() { ApplicationContext context = loadConfig(CustomViewResolverConfig.class); String name = "viewResolutionResultHandler"; @@ -267,7 +267,7 @@ public class WebFluxConfigurationSupportTests { } @Test - public void resourceHandler() { + void resourceHandler() { ApplicationContext context = loadConfig(CustomResourceHandlingConfig.class); String name = "resourceHandlerMapping"; @@ -282,7 +282,7 @@ public class WebFluxConfigurationSupportTests { } @Test - public void resourceUrlProvider() throws Exception { + void resourceUrlProvider() { ApplicationContext context = loadConfig(WebFluxConfig.class); String name = "resourceUrlProvider"; @@ -291,11 +291,11 @@ public class WebFluxConfigurationSupportTests { } - private void assertHasMessageReader(List> readers, ResolvableType type, MediaType mediaType) { + private void assertHasMessageReader(List> readers, ResolvableType type, @Nullable MediaType mediaType) { assertThat(readers.stream().anyMatch(c -> mediaType == null || c.canRead(type, mediaType))).isTrue(); } - private void assertHasMessageWriter(List> writers, ResolvableType type, MediaType mediaType) { + private void assertHasMessageWriter(List> writers, ResolvableType type, @Nullable MediaType mediaType) { assertThat(writers.stream().anyMatch(c -> mediaType == null || c.canWrite(type, mediaType))).isTrue(); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java index f4eae10984..b8c0fb4ff1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -325,9 +325,7 @@ class BodyExtractorsTests { assertThat(form).as("Invalid result").hasSize(3); assertThat(form.getFirst("name 1")).as("Invalid result").isEqualTo("value 1"); List values = form.get("name 2"); - assertThat(values).as("Invalid result").hasSize(2); - assertThat(values).element(0).as("Invalid result").isEqualTo("value 2+1"); - assertThat(values).element(1).as("Invalid result").isEqualTo("value 2+2"); + assertThat(values).as("Invalid result").containsExactly("value 2+1", "value 2+2"); assertThat(form.getFirst("name 3")).as("Invalid result").isNull(); }) .expectComplete() 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 3ef308247a..7bafc13681 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -75,7 +75,7 @@ import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW * @author Arjen Poutsma * @author Sebastien Deleuze */ -public class BodyInsertersTests { +class BodyInsertersTests { private BodyInserter.Context context; @@ -83,7 +83,7 @@ public class BodyInsertersTests { @BeforeEach - public void createContext() { + void createContext() { final List> messageWriters = new ArrayList<>(); messageWriters.add(new EncoderHttpMessageWriter<>(new ByteBufferEncoder())); messageWriters.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly())); @@ -115,7 +115,7 @@ public class BodyInsertersTests { @Test - public void ofString() { + void ofString() { String body = "foo"; BodyInserter inserter = BodyInserters.fromValue(body); @@ -132,7 +132,7 @@ public class BodyInsertersTests { } @Test - public void ofObject() { + void ofObject() { User body = new User("foo", "bar"); BodyInserter inserter = BodyInserters.fromValue(body); MockServerHttpResponse response = new MockServerHttpResponse(); @@ -146,7 +146,7 @@ public class BodyInsertersTests { } @Test - public void ofObjectWithHints() { + void ofObjectWithHints() { User body = new User("foo", "bar"); BodyInserter inserter = BodyInserters.fromValue(body); this.hints.put(JSON_VIEW_HINT, SafeToSerialize.class); @@ -161,7 +161,7 @@ public class BodyInsertersTests { } @Test - public void ofProducerWithMono() { + void ofProducerWithMono() { Mono body = Mono.just(new User("foo", "bar")); BodyInserter inserter = BodyInserters.fromProducer(body, User.class); @@ -175,7 +175,7 @@ public class BodyInsertersTests { } @Test - public void ofProducerWithFlux() { + void ofProducerWithFlux() { Flux body = Flux.just("foo"); BodyInserter inserter = BodyInserters.fromProducer(body, String.class); @@ -192,7 +192,7 @@ public class BodyInsertersTests { } @Test - public void ofProducerWithSingle() { + void ofProducerWithSingle() { Single body = Single.just(new User("foo", "bar")); BodyInserter inserter = BodyInserters.fromProducer(body, User.class); @@ -206,7 +206,7 @@ public class BodyInsertersTests { } @Test - public void ofPublisher() { + void ofPublisher() { Flux body = Flux.just("foo"); BodyInserter, ReactiveHttpOutputMessage> inserter = BodyInserters.fromPublisher(body, String.class); @@ -223,7 +223,7 @@ public class BodyInsertersTests { } @Test - public void ofResource() throws IOException { + void ofResource() throws IOException { Resource resource = new ClassPathResource("response.txt", getClass()); MockServerHttpResponse response = new MockServerHttpResponse(); @@ -267,7 +267,7 @@ public class BodyInsertersTests { } @Test - public void ofResourceRange() throws IOException { + void ofResourceRange() throws IOException { final int rangeStart = 10; Resource body = new ClassPathResource("response.txt", getClass()); BodyInserter inserter = BodyInserters.fromResource(body); @@ -310,7 +310,7 @@ public class BodyInsertersTests { } @Test - public void ofServerSentEventFlux() { + void ofServerSentEventFlux() { ServerSentEvent event = ServerSentEvent.builder("foo").build(); Flux> body = Flux.just(event); BodyInserter>, ServerHttpResponse> inserter = @@ -322,7 +322,7 @@ public class BodyInsertersTests { } @Test - public void fromFormDataMap() { + void fromFormDataMap() { MultiValueMap body = new LinkedMultiValueMap<>(); body.set("name 1", "value 1"); body.add("name 2", "value 2+1"); @@ -349,7 +349,7 @@ public class BodyInsertersTests { } @Test - public void fromFormDataWith() { + void fromFormDataWith() { BodyInserter, ClientHttpRequest> inserter = BodyInserters.fromFormData("name 1", "value 1") .with("name 2", "value 2+1") @@ -373,7 +373,7 @@ public class BodyInsertersTests { } @Test - public void fromMultipartData() { + void fromMultipartData() { MultiValueMap map = new LinkedMultiValueMap<>(); map.set("name 3", "value 3"); @@ -422,7 +422,7 @@ public class BodyInsertersTests { } @Test - public void ofDataBuffers() { + void ofDataBuffers() { byte[] bytes = "foo".getBytes(UTF_8); DefaultDataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(ByteBuffer.wrap(bytes)); Flux body = Flux.just(dataBuffer); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java index 571321fafc..63d193b8ce 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -101,7 +101,6 @@ class DefaultClientResponseBuilderTests { } @Test - @SuppressWarnings("deprecation") void mutateWithCustomStatus() { ClientResponse other = ClientResponse.create(499, ExchangeStrategies.withDefaults()).build(); ClientResponse result = other.mutate().build(); 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 189f0a2330..2434d9a3f8 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 @@ -73,7 +73,7 @@ public class DefaultWebClientTests { @BeforeEach - public void setup() { + void setup() { ClientResponse mockResponse = mock(); when(mockResponse.statusCode()).thenReturn(HttpStatus.OK); when(mockResponse.bodyToMono(Void.class)).thenReturn(Mono.empty()); @@ -83,7 +83,7 @@ public class DefaultWebClientTests { @Test - public void basic() { + void basic() { this.builder.build().get().uri("/path") .retrieve().bodyToMono(Void.class).block(Duration.ofSeconds(10)); @@ -94,7 +94,7 @@ public class DefaultWebClientTests { } @Test - public void uriBuilder() { + void uriBuilder() { this.builder.build().get() .uri(builder -> builder.path("/path").queryParam("q", "12").build()) .retrieve().bodyToMono(Void.class).block(Duration.ofSeconds(10)); @@ -115,7 +115,7 @@ public class DefaultWebClientTests { } @Test - public void uriBuilderWithPathOverride() { + void uriBuilderWithPathOverride() { this.builder.build().get() .uri(builder -> builder.replacePath("/path").build()) .retrieve().bodyToMono(Void.class).block(Duration.ofSeconds(10)); @@ -125,7 +125,7 @@ public class DefaultWebClientTests { } @Test - public void requestHeaderAndCookie() { + void requestHeaderAndCookie() { this.builder.build().get().uri("/path").accept(MediaType.APPLICATION_JSON) .cookies(cookies -> cookies.add("id", "123")) // SPR-16178 .retrieve().bodyToMono(Void.class).block(Duration.ofSeconds(10)); @@ -165,7 +165,7 @@ public class DefaultWebClientTests { } @Test - public void httpRequest() { + void httpRequest() { this.builder.build().get().uri("/path") .httpRequest(httpRequest -> {}) .retrieve().bodyToMono(Void.class).block(Duration.ofSeconds(10)); @@ -175,7 +175,7 @@ public class DefaultWebClientTests { } @Test - public void defaultHeaderAndCookie() { + void defaultHeaderAndCookie() { WebClient client = this.builder .defaultHeader("Accept", "application/json") .defaultCookie("id", "123") @@ -190,7 +190,7 @@ public class DefaultWebClientTests { } @Test - public void defaultHeaderAndCookieOverrides() { + void defaultHeaderAndCookieOverrides() { WebClient client = this.builder .defaultHeader("Accept", "application/json") .defaultCookie("id", "123") @@ -207,7 +207,7 @@ public class DefaultWebClientTests { } @Test - public void defaultHeaderAndCookieCopies() { + void defaultHeaderAndCookieCopies() { WebClient client1 = this.builder .defaultHeader("Accept", "application/json") .defaultCookie("id", "123") @@ -234,7 +234,7 @@ public class DefaultWebClientTests { } @Test - public void defaultRequest() { + void defaultRequest() { ThreadLocal context = new NamedThreadLocal<>("foo"); Map actual = new HashMap<>(); @@ -261,7 +261,7 @@ public class DefaultWebClientTests { } @Test - public void bodyObjectPublisher() { + void bodyObjectPublisher() { Mono mono = Mono.empty(); WebClient client = this.builder.build(); @@ -270,7 +270,7 @@ public class DefaultWebClientTests { } @Test - public void mutateDoesCopy() { + void mutateDoesCopy() { // First, build the clients WebClient.Builder builder = WebClient.builder() @@ -327,7 +327,7 @@ public class DefaultWebClientTests { } @Test - public void withStringAttribute() { + void withStringAttribute() { Map actual = new HashMap<>(); ExchangeFilterFunction filter = (request, next) -> { actual.putAll(request.attributes()); @@ -346,7 +346,7 @@ public class DefaultWebClientTests { } @Test - public void withNullAttribute() { + void withNullAttribute() { Map actual = new HashMap<>(); ExchangeFilterFunction filter = (request, next) -> { actual.putAll(request.attributes()); @@ -365,7 +365,7 @@ public class DefaultWebClientTests { } @Test - public void uriTemplateAttribute() { + void uriTemplateAttribute() { testUriTemplateAttribute(client -> client.get().uri("/{id}", 1), "/base/{id}"); testUriTemplateAttribute(client -> client.get().uri("/{id}", Map.of("id", 1)), "/base/{id}"); testUriTemplateAttribute(client -> client.get().uri("/{id}", builder -> builder.build(1)), "/base/{id}"); @@ -389,7 +389,7 @@ public class DefaultWebClientTests { } @Test - public void apply() { + void apply() { WebClient client = this.builder .apply(builder -> builder .defaultHeader("Accept", "application/json") @@ -404,7 +404,7 @@ public class DefaultWebClientTests { } @Test - public void switchToErrorOnEmptyClientResponseMono() { + void switchToErrorOnEmptyClientResponseMono() { ExchangeFunction exchangeFunction = mock(); given(exchangeFunction.exchange(any())).willReturn(Mono.empty()); WebClient client = WebClient.builder().baseUrl("/base").exchangeFunction(exchangeFunction).build(); @@ -414,7 +414,7 @@ public class DefaultWebClientTests { } @Test - public void shouldApplyFiltersAtSubscription() { + void shouldApplyFiltersAtSubscription() { WebClient client = this.builder .filter((request, next) -> next.exchange(ClientRequest @@ -449,7 +449,7 @@ public class DefaultWebClientTests { } @Test - public void onStatusHandlerRegisteredGlobally() { + void onStatusHandlerRegisteredGlobally() { ClientResponse response = ClientResponse.create(HttpStatus.BAD_REQUEST).build(); given(exchangeFunction.exchange(any())).willReturn(Mono.just(response)); @@ -466,7 +466,7 @@ public class DefaultWebClientTests { } @Test - public void onStatusHandlerRegisteredGloballyHaveLowerPrecedence() { + void onStatusHandlerRegisteredGloballyHaveLowerPrecedence() { ClientResponse response = ClientResponse.create(HttpStatus.BAD_REQUEST).build(); given(exchangeFunction.exchange(any())).willReturn(Mono.just(response)); @@ -483,7 +483,6 @@ public class DefaultWebClientTests { } @Test // gh-23880 - @SuppressWarnings("unchecked") public void onStatusHandlersDefaultHandlerIsLast() { ClientResponse response = ClientResponse.create(HttpStatus.BAD_REQUEST).build(); 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 084545b44d..8a7c0ab0ef 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 @@ -44,13 +44,13 @@ import static org.mockito.Mockito.mock; * * @author Arjen Poutsma */ -public class ExchangeFilterFunctionsTests { +class ExchangeFilterFunctionsTests { private static final URI DEFAULT_URL = URI.create("https://example.com"); @Test - public void andThen() { + void andThen() { ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build(); ClientResponse response = mock(); ExchangeFunction exchange = r -> Mono.just(response); @@ -60,7 +60,6 @@ public class ExchangeFilterFunctionsTests { assertThat(filtersInvoked[0]).isFalse(); assertThat(filtersInvoked[1]).isFalse(); filtersInvoked[0] = true; - assertThat(filtersInvoked[1]).isFalse(); return n.exchange(r); }; ExchangeFilterFunction filter2 = (r, n) -> { @@ -80,7 +79,7 @@ public class ExchangeFilterFunctionsTests { } @Test - public void apply() { + void apply() { ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build(); ClientResponse response = mock(); ExchangeFunction exchange = r -> Mono.just(response); @@ -99,7 +98,7 @@ public class ExchangeFilterFunctionsTests { } @Test - public void basicAuthenticationUsernamePassword() { + void basicAuthenticationUsernamePassword() { ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build(); ClientResponse response = mock(); @@ -116,7 +115,7 @@ public class ExchangeFilterFunctionsTests { } @Test - public void basicAuthenticationInvalidCharacters() { + void basicAuthenticationInvalidCharacters() { ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build(); ExchangeFunction exchange = r -> Mono.just(mock()); @@ -163,7 +162,7 @@ public class ExchangeFilterFunctionsTests { } @Test - public void statusHandlerMatch() { + void statusHandlerMatch() { ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build(); ClientResponse response = mock(); given(response.statusCode()).willReturn(HttpStatus.NOT_FOUND); @@ -181,7 +180,7 @@ public class ExchangeFilterFunctionsTests { } @Test - public void statusHandlerNoMatch() { + void statusHandlerNoMatch() { ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build(); ClientResponse response = mock(); given(response.statusCode()).willReturn(HttpStatus.NOT_FOUND); @@ -197,7 +196,7 @@ public class ExchangeFilterFunctionsTests { } @Test - public void limitResponseSize() { + void limitResponseSize() { DataBuffer b1 = dataBuffer("foo"); DataBuffer b2 = dataBuffer("bar"); DataBuffer b3 = dataBuffer("baz"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java index 94f9a01ff3..8e4d10d197 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -23,17 +23,17 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class ExchangeStrategiesTests { +class ExchangeStrategiesTests { @Test - public void empty() { + void empty() { ExchangeStrategies strategies = ExchangeStrategies.empty().build(); assertThat(strategies.messageReaders()).isEmpty(); assertThat(strategies.messageWriters()).isEmpty(); } @Test - public void withDefaults() { + void withDefaults() { ExchangeStrategies strategies = ExchangeStrategies.withDefaults(); assertThat(strategies.messageReaders()).isNotEmpty(); assertThat(strategies.messageWriters()).isNotEmpty(); 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 2daa116461..c5e2c219b6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -737,7 +737,7 @@ class WebClientIntegrationTests { } @ParameterizedWebClientTest // SPR-16246 - void postLargeTextFile(ClientHttpConnector connector) throws Exception { + void postLargeTextFile(ClientHttpConnector connector) { startServer(connector); prepareResponse(response -> {}); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientObservationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientObservationTests.java index 5fdad3b5aa..f18f077291 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientObservationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientObservationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -135,17 +135,12 @@ class WebClientObservationTests { @Test void setsCurrentObservationInReactorContext() { - ExchangeFilterFunction assertionFilter = new ExchangeFilterFunction() { - @Override - public Mono filter(ClientRequest request, ExchangeFunction chain) { - return chain.exchange(request).contextWrite(context -> { - Observation currentObservation = context.get(ObservationThreadLocalAccessor.KEY); - assertThat(currentObservation).isNotNull(); - assertThat(currentObservation.getContext()).isInstanceOf(ClientRequestObservationContext.class); - return context; - }); - } - }; + ExchangeFilterFunction assertionFilter = (request, chain) -> chain.exchange(request).contextWrite(context -> { + Observation currentObservation = context.get(ObservationThreadLocalAccessor.KEY); + assertThat(currentObservation).isNotNull(); + assertThat(currentObservation.getContext()).isInstanceOf(ClientRequestObservationContext.class); + return context; + }); this.builder.filter(assertionFilter).build().get().uri("/resource/{id}", 42) .retrieve().bodyToMono(Void.class) .block(Duration.ofSeconds(10)); @@ -154,17 +149,14 @@ class WebClientObservationTests { @Test void setsCurrentObservationContextAsRequestAttribute() { - ExchangeFilterFunction assertionFilter = new ExchangeFilterFunction() { - @Override - public Mono filter(ClientRequest request, ExchangeFunction chain) { - Optional observationContext = ClientRequestObservationContext.findCurrent(request); - assertThat(observationContext).isPresent(); - return chain.exchange(request).contextWrite(context -> { - Observation currentObservation = context.get(ObservationThreadLocalAccessor.KEY); - assertThat(currentObservation.getContext()).isEqualTo(observationContext.get()); - return context; - }); - } + ExchangeFilterFunction assertionFilter = (request, chain) -> { + Optional observationContext = ClientRequestObservationContext.findCurrent(request); + assertThat(observationContext).isPresent(); + return chain.exchange(request).contextWrite(context -> { + Observation currentObservation = context.get(ObservationThreadLocalAccessor.KEY); + assertThat(currentObservation.getContext()).isEqualTo(observationContext.get()); + return context; + }); }; this.builder.filter(assertionFilter).build().get().uri("/resource/{id}", 42) .retrieve().bodyToMono(Void.class) @@ -211,7 +203,7 @@ class WebClientObservationTests { static class MockClientHeaders implements ClientResponse.Headers { - private HttpHeaders headers = new HttpHeaders(); + private final HttpHeaders headers = new HttpHeaders(); @Override public OptionalLong contentLength() { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java index 6d1bf61e3b..9ae4619a52 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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,7 +69,6 @@ class ClientResponseWrapperTests { } @Test - @SuppressWarnings("unchecked") void cookies() { MultiValueMap cookies = mock(); given(mockResponse.cookies()).willReturn(cookies); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientAdapterTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientAdapterTests.java index db58ab3546..13144f11cc 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientAdapterTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -60,7 +60,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rossen Stoyanchev * @author Olga Maciaszek-Sharma */ -public class WebClientAdapterTests { +class WebClientAdapterTests { private static final String ANOTHER_SERVER_RESPONSE_BODY = "Hello Spring 2!"; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/AttributesTestVisitor.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/AttributesTestVisitor.java index 8d8a495717..fad717537a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/AttributesTestVisitor.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/AttributesTestVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -23,7 +23,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; import reactor.core.publisher.Mono; @@ -68,7 +67,7 @@ class AttributesTestVisitor implements RouterFunctions.Visitor { public void route(RequestPredicate predicate, HandlerFunction handlerFunction) { Stream> current = Optional.ofNullable(attributes).stream(); Stream> nested = nestedAttributes.stream().filter(Objects::nonNull); - routerFunctionsAttributes.add(Stream.concat(current, nested).collect(Collectors.toUnmodifiableList())); + routerFunctionsAttributes.add(Stream.concat(current, nested).toList()); attributes = null; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/BindingFunctionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/BindingFunctionIntegrationTests.java index febeadef19..524b4d6a3f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/BindingFunctionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/BindingFunctionIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -190,7 +190,7 @@ class BindingFunctionIntegrationTests extends AbstractRouterFunctionIntegrationT @Override public String toString() { - return String.valueOf(this.foo) + ":" + String.valueOf(this.bar); + return this.foo + ":" + this.bar; } } @@ -221,7 +221,7 @@ class BindingFunctionIntegrationTests extends AbstractRouterFunctionIntegrationT @Override public String toString() { - return this.foo + ":" + String.valueOf(this.bar); + return this.foo + ":" + this.bar; } } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java index 9766b38eaf..12caa854fb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -18,7 +18,6 @@ package org.springframework.web.reactive.function.server; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; import java.util.Collections; import java.util.List; import java.util.Set; @@ -254,7 +253,7 @@ class DefaultEntityResponseBuilderTests { @Test void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); - ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); + ZonedDateTime oneMinuteBeforeNow = now.minusMinutes(1); EntityResponse responseMono = EntityResponse.fromObject("bar") .lastModified(oneMinuteBeforeNow) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java index b79ec64f63..5f2adf82b8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -57,10 +57,10 @@ import static org.mockito.Mockito.verify; /** * @author Arjen Poutsma */ -public class DefaultRenderingResponseTests { +class DefaultRenderingResponseTests { @Test - public void create() { + void create() { String name = "foo"; Mono result = RenderingResponse.create(name).build(); StepVerifier.create(result) @@ -70,7 +70,7 @@ public class DefaultRenderingResponseTests { } @Test - public void headers() { + void headers() { HttpHeaders headers = new HttpHeaders(); Mono result = RenderingResponse.create("foo").headers(headers).build(); StepVerifier.create(result) @@ -81,7 +81,7 @@ public class DefaultRenderingResponseTests { } @Test - public void modelAttribute() { + void modelAttribute() { Mono result = RenderingResponse.create("foo") .modelAttribute("foo", "bar").build(); StepVerifier.create(result) @@ -91,7 +91,7 @@ public class DefaultRenderingResponseTests { } @Test - public void modelAttributeConventions() { + void modelAttributeConventions() { Mono result = RenderingResponse.create("foo") .modelAttribute("bar").build(); StepVerifier.create(result) @@ -101,7 +101,7 @@ public class DefaultRenderingResponseTests { } @Test - public void modelAttributes() { + void modelAttributes() { Map model = Collections.singletonMap("foo", "bar"); Mono result = RenderingResponse.create("foo") .modelAttributes(model).build(); @@ -112,7 +112,7 @@ public class DefaultRenderingResponseTests { } @Test - public void modelAttributesConventions() { + void modelAttributesConventions() { Set model = Collections.singleton("bar"); Mono result = RenderingResponse.create("foo") .modelAttributes(model).build(); @@ -123,7 +123,7 @@ public class DefaultRenderingResponseTests { } @Test - public void cookies() { + void cookies() { MultiValueMap newCookies = new LinkedMultiValueMap<>(); newCookies.add("name", ResponseCookie.from("name", "value").build()); Mono result = @@ -136,7 +136,7 @@ public class DefaultRenderingResponseTests { @Test - public void render() { + void render() { Map model = Collections.singletonMap("foo", "bar"); Mono result = RenderingResponse.create("view").modelAttributes(model).build(); @@ -160,7 +160,7 @@ public class DefaultRenderingResponseTests { } @Test - public void writeTo() { + void writeTo() { Map model = Collections.singletonMap("foo", "bar"); RenderingResponse renderingResponse = RenderingResponse.create("view") .status(HttpStatus.FOUND) @@ -195,7 +195,7 @@ public class DefaultRenderingResponseTests { } @Test - public void defaultContentType() { + void defaultContentType() { Mono result = RenderingResponse.create("view").build(); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("http://localhost")); @@ -228,7 +228,7 @@ public class DefaultRenderingResponseTests { } @Test - public void notModifiedEtag() { + void notModifiedEtag() { String etag = "\"foo\""; RenderingResponse responseMono = RenderingResponse.create("bar") .header(HttpHeaders.ETAG, etag) @@ -250,9 +250,9 @@ public class DefaultRenderingResponseTests { } @Test - public void notModifiedLastModified() { + void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); - ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); + ZonedDateTime oneMinuteBeforeNow = now.minusMinutes(1); RenderingResponse responseMono = RenderingResponse.create("bar") .header(HttpHeaders.LAST_MODIFIED, DateTimeFormatter.RFC_1123_DATE_TIME.format(oneMinuteBeforeNow)) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java index 24c6c21cb1..ff21883457 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java @@ -40,10 +40,10 @@ import static org.assertj.core.api.Assertions.entry; * @author Arjen Poutsma * @author Sam Brannen */ -public class DefaultServerRequestBuilderTests { +class DefaultServerRequestBuilderTests { @Test - public void from() { + void from() { MockServerHttpRequest request = MockServerHttpRequest.post("https://example.com") .header("foo", "bar") .build(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java index 6f3b723c93..1282a1cd97 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -78,7 +78,7 @@ import static org.springframework.web.reactive.function.BodyExtractors.toMono; * @author Arjen Poutsma * @author Brian Clozel */ -public class DefaultServerRequestTests { +class DefaultServerRequestTests { private final List> messageReaders = Arrays.asList( new DecoderHttpMessageReader<>(new Jackson2JsonDecoder()), @@ -86,7 +86,7 @@ public class DefaultServerRequestTests { @Test - public void method() { + void method() { HttpMethod method = HttpMethod.HEAD; DefaultServerRequest request = new DefaultServerRequest( MockServerWebExchange.from(MockServerHttpRequest.method(method, "https://example.com")), @@ -96,7 +96,7 @@ public class DefaultServerRequestTests { } @Test - public void uri() { + void uri() { URI uri = URI.create("https://example.com"); DefaultServerRequest request = new DefaultServerRequest( @@ -107,7 +107,7 @@ public class DefaultServerRequestTests { } @Test - public void uriBuilder() throws URISyntaxException { + void uriBuilder() throws URISyntaxException { URI uri = new URI("http", "localhost", "/path", "a=1", null); DefaultServerRequest request = new DefaultServerRequest( MockServerWebExchange.from(MockServerHttpRequest.method(HttpMethod.GET, uri)), @@ -123,7 +123,7 @@ public class DefaultServerRequestTests { } @Test - public void attribute() { + void attribute() { MockServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.method(HttpMethod.GET, "https://example.com")); exchange.getAttributes().put("foo", "bar"); @@ -134,7 +134,7 @@ public class DefaultServerRequestTests { } @Test - public void queryParams() { + void queryParams() { DefaultServerRequest request = new DefaultServerRequest( MockServerWebExchange.from(MockServerHttpRequest.method(HttpMethod.GET, "https://example.com?foo=bar")), this.messageReaders); @@ -143,7 +143,7 @@ public class DefaultServerRequestTests { } @Test - public void emptyQueryParam() { + void emptyQueryParam() { DefaultServerRequest request = new DefaultServerRequest( MockServerWebExchange.from(MockServerHttpRequest.method(HttpMethod.GET, "https://example.com?foo")), this.messageReaders); @@ -152,7 +152,7 @@ public class DefaultServerRequestTests { } @Test - public void absentQueryParam() { + void absentQueryParam() { DefaultServerRequest request = new DefaultServerRequest( MockServerWebExchange.from(MockServerHttpRequest.method(HttpMethod.GET, "https://example.com?foo")), this.messageReaders); @@ -161,7 +161,7 @@ public class DefaultServerRequestTests { } @Test - public void pathVariable() { + void pathVariable() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("https://example.com")); Map pathVariables = Collections.singletonMap("foo", "bar"); exchange.getAttributes().put(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE, pathVariables); @@ -173,7 +173,7 @@ public class DefaultServerRequestTests { @Test - public void pathVariableNotFound() { + void pathVariableNotFound() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("https://example.com")); Map pathVariables = Collections.singletonMap("foo", "bar"); exchange.getAttributes().put(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE, pathVariables); @@ -185,7 +185,7 @@ public class DefaultServerRequestTests { } @Test - public void pathVariables() { + void pathVariables() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("https://example.com")); Map pathVariables = Collections.singletonMap("foo", "bar"); exchange.getAttributes().put(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE, pathVariables); @@ -196,7 +196,7 @@ public class DefaultServerRequestTests { } @Test - public void header() { + void header() { HttpHeaders httpHeaders = new HttpHeaders(); List accept = Collections.singletonList(MediaType.APPLICATION_JSON); @@ -229,7 +229,7 @@ public class DefaultServerRequestTests { } @Test - public void cookies() { + void cookies() { HttpCookie cookie = new HttpCookie("foo", "bar"); MockServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.method(HttpMethod.GET, "https://example.com").cookie(cookie)); @@ -386,7 +386,7 @@ public class DefaultServerRequestTests { @Test - public void formData() { + void formData() { byte[] bytes = "foo=bar&baz=qux".getBytes(StandardCharsets.UTF_8); DefaultDataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(ByteBuffer.wrap(bytes)); Flux body = Flux.just(dataBuffer); @@ -410,7 +410,7 @@ public class DefaultServerRequestTests { } @Test - public void multipartData() { + void multipartData() { String data = """ --12345 Content-Disposition: form-data; name="foo" 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 625a70e3dd..86d62e3be7 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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,7 +19,6 @@ package org.springframework.web.reactive.function.server; import java.net.URI; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; import java.util.Collections; import java.util.List; import java.util.Set; @@ -392,7 +391,7 @@ class DefaultServerResponseBuilderTests { @Test void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); - ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); + ZonedDateTime oneMinuteBeforeNow = now.minusMinutes(1); ServerResponse responseMono = ServerResponse.ok() .lastModified(oneMinuteBeforeNow) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java index 21f130a3a1..33420b738c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -23,10 +23,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class HandlerStrategiesTests { +class HandlerStrategiesTests { @Test - public void empty() { + void empty() { HandlerStrategies strategies = HandlerStrategies.empty().build(); assertThat(strategies.messageReaders()).isEmpty(); assertThat(strategies.messageWriters()).isEmpty(); @@ -34,7 +34,7 @@ public class HandlerStrategiesTests { } @Test - public void withDefaults() { + void withDefaults() { HandlerStrategies strategies = HandlerStrategies.withDefaults(); assertThat(strategies.messageReaders()).isNotEmpty(); assertThat(strategies.messageWriters()).isNotEmpty(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java index 5b5cf24e0f..b28db67d28 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 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,10 +33,10 @@ import org.springframework.web.testfixture.server.MockServerWebExchange; /** * @author Arjen Poutsma */ -public class PathResourceLookupFunctionTests { +class PathResourceLookupFunctionTests { @Test - public void normal() throws Exception { + void normal() throws Exception { ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/"); PathResourceLookupFunction @@ -60,7 +60,7 @@ public class PathResourceLookupFunctionTests { } @Test - public void subPath() throws Exception { + void subPath() throws Exception { ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/"); PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); @@ -83,7 +83,7 @@ public class PathResourceLookupFunctionTests { } @Test - public void notFound() throws Exception { + void notFound() { ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/"); PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); @@ -96,7 +96,7 @@ public class PathResourceLookupFunctionTests { } @Test - public void composeResourceLookupFunction() throws Exception { + void composeResourceLookupFunction() { ClassPathResource defaultResource = new ClassPathResource("response.txt", getClass()); Function> lookupFunction = diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java index b48ca03af7..2af5a8e4c2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -31,12 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class RequestPredicateAttributesTests { +class RequestPredicateAttributesTests { private DefaultServerRequest request; @BeforeEach - public void createRequest() { + void createRequest() { MockServerHttpRequest request = MockServerHttpRequest.get("https://example.com/path").build(); MockServerWebExchange webExchange = MockServerWebExchange.from(request); webExchange.getAttributes().put("exchange", "bar"); @@ -48,7 +48,7 @@ public class RequestPredicateAttributesTests { @Test - public void negateSucceed() { + void negateSucceed() { RequestPredicate predicate = new AddAttributePredicate(false, "predicate", "baz").negate(); boolean result = predicate.test(this.request); @@ -59,7 +59,7 @@ public class RequestPredicateAttributesTests { } @Test - public void negateFail() { + void negateFail() { RequestPredicate predicate = new AddAttributePredicate(true, "predicate", "baz").negate(); boolean result = predicate.test(this.request); @@ -70,7 +70,7 @@ public class RequestPredicateAttributesTests { } @Test - public void andBothSucceed() { + void andBothSucceed() { RequestPredicate left = new AddAttributePredicate(true, "left", "baz"); RequestPredicate right = new AddAttributePredicate(true, "right", "qux"); RequestPredicate predicate = new RequestPredicates.AndRequestPredicate(left, right); @@ -84,7 +84,7 @@ public class RequestPredicateAttributesTests { } @Test - public void andLeftSucceed() { + void andLeftSucceed() { RequestPredicate left = new AddAttributePredicate(true, "left", "bar"); RequestPredicate right = new AddAttributePredicate(false, "right", "qux"); RequestPredicate predicate = new RequestPredicates.AndRequestPredicate(left, right); @@ -98,7 +98,7 @@ public class RequestPredicateAttributesTests { } @Test - public void andRightSucceed() { + void andRightSucceed() { RequestPredicate left = new AddAttributePredicate(false, "left", "bar"); RequestPredicate right = new AddAttributePredicate(true, "right", "qux"); RequestPredicate predicate = new RequestPredicates.AndRequestPredicate(left, right); @@ -112,7 +112,7 @@ public class RequestPredicateAttributesTests { } @Test - public void andBothFail() { + void andBothFail() { RequestPredicate left = new AddAttributePredicate(false, "left", "bar"); RequestPredicate right = new AddAttributePredicate(false, "right", "qux"); RequestPredicate predicate = new RequestPredicates.AndRequestPredicate(left, right); @@ -126,7 +126,7 @@ public class RequestPredicateAttributesTests { } @Test - public void orBothSucceed() { + void orBothSucceed() { RequestPredicate left = new AddAttributePredicate(true, "left", "baz"); RequestPredicate right = new AddAttributePredicate(true, "right", "qux"); RequestPredicate predicate = new RequestPredicates.OrRequestPredicate(left, right); @@ -140,7 +140,7 @@ public class RequestPredicateAttributesTests { } @Test - public void orLeftSucceed() { + void orLeftSucceed() { RequestPredicate left = new AddAttributePredicate(true, "left", "baz"); RequestPredicate right = new AddAttributePredicate(false, "right", "qux"); RequestPredicate predicate = new RequestPredicates.OrRequestPredicate(left, right); @@ -154,7 +154,7 @@ public class RequestPredicateAttributesTests { } @Test - public void orRightSucceed() { + void orRightSucceed() { RequestPredicate left = new AddAttributePredicate(false, "left", "baz"); RequestPredicate right = new AddAttributePredicate(true, "right", "qux"); RequestPredicate predicate = new RequestPredicates.OrRequestPredicate(left, right); @@ -168,7 +168,7 @@ public class RequestPredicateAttributesTests { } @Test - public void orBothFail() { + void orBothFail() { RequestPredicate left = new AddAttributePredicate(false, "left", "baz"); RequestPredicate right = new AddAttributePredicate(false, "right", "qux"); RequestPredicate predicate = new RequestPredicates.OrRequestPredicate(left, right); 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 479d367ac2..b55594bbd0 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-2020 the original author or authors. + * Copyright 2002-2024 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. @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class RequestPredicateTests { +class RequestPredicateTests { @Test - public void and() { + void and() { RequestPredicate predicate1 = request -> true; RequestPredicate predicate2 = request -> true; RequestPredicate predicate3 = request -> false; @@ -44,7 +44,7 @@ public class RequestPredicateTests { } @Test - public void negate() { + void negate() { RequestPredicate predicate = request -> false; RequestPredicate negated = predicate.negate(); @@ -59,7 +59,7 @@ public class RequestPredicateTests { } @Test - public void or() { + void or() { RequestPredicate predicate1 = request -> true; RequestPredicate predicate2 = request -> false; RequestPredicate predicate3 = request -> false; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java index 1c65981b60..2f855513da 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 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. @@ -34,11 +34,11 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class RequestPredicatesTests { +class RequestPredicatesTests { @Test - public void all() { + void all() { MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://example.com").build(); MockServerWebExchange mockExchange = MockServerWebExchange.from(mockRequest); RequestPredicate predicate = RequestPredicates.all(); @@ -47,7 +47,7 @@ public class RequestPredicatesTests { } @Test - public void method() { + void method() { MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://example.com").build(); HttpMethod httpMethod = HttpMethod.GET; @@ -61,7 +61,7 @@ public class RequestPredicatesTests { } @Test - public void methodCorsPreFlight() { + void methodCorsPreFlight() { RequestPredicate predicate = RequestPredicates.method(HttpMethod.PUT); MockServerHttpRequest mockRequest = MockServerHttpRequest.options("https://example.com") @@ -82,7 +82,7 @@ public class RequestPredicatesTests { @Test - public void methods() { + void methods() { RequestPredicate predicate = RequestPredicates.methods(HttpMethod.GET, HttpMethod.HEAD); MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://example.com").build(); ServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), Collections.emptyList()); @@ -98,7 +98,7 @@ public class RequestPredicatesTests { } @Test - public void allMethods() { + void allMethods() { RequestPredicate predicate = RequestPredicates.GET("/p*"); MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://example.com/path").build(); ServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), Collections.emptyList()); @@ -136,7 +136,7 @@ public class RequestPredicatesTests { } @Test - public void path() { + void path() { URI uri = URI.create("https://localhost/path"); RequestPredicate predicate = RequestPredicates.path("/p*"); MockServerHttpRequest mockRequest = MockServerHttpRequest.get(uri.toString()).build(); @@ -149,7 +149,7 @@ public class RequestPredicatesTests { } @Test - public void pathNoLeadingSlash() { + void pathNoLeadingSlash() { RequestPredicate predicate = RequestPredicates.path("p*"); MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://example.com/path").build(); ServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), Collections.emptyList()); @@ -157,7 +157,7 @@ public class RequestPredicatesTests { } @Test - public void pathEncoded() { + void pathEncoded() { URI uri = URI.create("https://localhost/foo%20bar"); RequestPredicate predicate = RequestPredicates.path("/foo bar"); MockServerHttpRequest mockRequest = MockServerHttpRequest.method(HttpMethod.GET, uri).build(); @@ -166,7 +166,7 @@ public class RequestPredicatesTests { } @Test - public void pathPredicates() { + void pathPredicates() { PathPatternParser parser = new PathPatternParser(); parser.setCaseSensitive(false); Function pathPredicates = RequestPredicates.pathPredicates(parser); @@ -178,7 +178,7 @@ public class RequestPredicatesTests { } @Test - public void pathWithContext() { + void pathWithContext() { RequestPredicate predicate = RequestPredicates.path("/p*"); MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://localhost/context/path") .contextPath("/context").build(); @@ -187,7 +187,7 @@ public class RequestPredicatesTests { } @Test - public void headers() { + void headers() { String name = "MyHeader"; String value = "MyValue"; RequestPredicate predicate = @@ -207,7 +207,7 @@ public class RequestPredicatesTests { } @Test - public void headersCors() { + void headersCors() { RequestPredicate predicate = RequestPredicates.headers(headers -> false); MockServerHttpRequest mockRequest = MockServerHttpRequest.options("https://example.com") .header("Origin", "https://example.com") @@ -219,7 +219,7 @@ public class RequestPredicatesTests { @Test - public void contentType() { + void contentType() { MediaType json = MediaType.APPLICATION_JSON; RequestPredicate predicate = RequestPredicates.contentType(json); MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://example.com") @@ -236,7 +236,7 @@ public class RequestPredicatesTests { } @Test - public void accept() { + void accept() { MediaType json = MediaType.APPLICATION_JSON; RequestPredicate predicate = RequestPredicates.accept(json); MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://example.com") @@ -253,7 +253,7 @@ public class RequestPredicatesTests { } @Test - public void pathExtension() { + void pathExtension() { RequestPredicate predicate = RequestPredicates.pathExtension("txt"); URI uri = URI.create("https://localhost/file.txt"); @@ -276,7 +276,7 @@ public class RequestPredicatesTests { } @Test - public void queryParam() { + void queryParam() { MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://example.com") .queryParam("foo", "bar").build(); ServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), Collections.emptyList()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java index 376fe409bc..8d270c98a3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Arjen Poutsma * @since 5.0 */ -public class ResourceHandlerFunctionTests { +class ResourceHandlerFunctionTests { private final Resource resource = new ClassPathResource("response.txt", getClass()); @@ -53,7 +53,7 @@ public class ResourceHandlerFunctionTests { @BeforeEach - public void createContext() { + void createContext() { HandlerStrategies strategies = HandlerStrategies.withDefaults(); context = new ServerResponse.Context() { @Override @@ -69,7 +69,7 @@ public class ResourceHandlerFunctionTests { @Test - public void get() throws IOException { + void get() throws IOException { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("http://localhost")); MockServerHttpResponse mockResponse = exchange.getResponse(); @@ -106,7 +106,7 @@ public class ResourceHandlerFunctionTests { } @Test - public void head() throws IOException { + void head() throws IOException { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.head("http://localhost")); MockServerHttpResponse mockResponse = exchange.getResponse(); @@ -132,7 +132,7 @@ public class ResourceHandlerFunctionTests { } @Test - public void options() { + void options() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.options("http://localhost")); MockServerHttpResponse mockResponse = exchange.getResponse(); 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 053add50fe..26edb5fc05 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -43,10 +43,10 @@ import static org.springframework.web.reactive.function.server.RequestPredicates /** * @author Arjen Poutsma */ -public class RouterFunctionBuilderTests { +class RouterFunctionBuilderTests { @Test - public void route() { + void route() { RouterFunction route = RouterFunctions.route() .GET("/foo", request -> ServerResponse.ok().build()) .POST("/", RequestPredicates.contentType(MediaType.TEXT_PLAIN), request -> ServerResponse.noContent().build()) @@ -103,7 +103,7 @@ public class RouterFunctionBuilderTests { } @Test - public void resources() { + void resources() { Resource resource = new ClassPathResource("/org/springframework/web/reactive/function/server/"); assertThat(resource.exists()).isTrue(); @@ -134,7 +134,7 @@ public class RouterFunctionBuilderTests { } @Test - public void resourcesCaching() { + void resourcesCaching() { Resource resource = new ClassPathResource("/org/springframework/web/reactive/function/server/"); assertThat(resource.exists()).isTrue(); @@ -156,7 +156,7 @@ public class RouterFunctionBuilderTests { } @Test - public void nest() { + void nest() { RouterFunction route = RouterFunctions.route() .path("/foo", builder -> builder.path("/bar", @@ -178,7 +178,7 @@ public class RouterFunctionBuilderTests { } @Test - public void filters() { + void filters() { AtomicInteger filterCount = new AtomicInteger(); RouterFunction route = RouterFunctions.route() @@ -232,7 +232,7 @@ public class RouterFunctionBuilderTests { } @Test - public void multipleOnErrors() { + void multipleOnErrors() { RouterFunction route = RouterFunctions.route() .GET("/error", request -> Mono.error(new IOException())) .onError(IOException.class, (t, r) -> ServerResponse.status(200).build()) @@ -253,7 +253,7 @@ public class RouterFunctionBuilderTests { } @Test - public void attributes() { + void attributes() { RouterFunction route = RouterFunctions.route() .GET("/atts/1", request -> ServerResponse.ok().build()) .withAttribute("foo", "bar") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionTests.java index 49561cf865..f8bba5cc51 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -36,10 +36,10 @@ import static org.springframework.web.reactive.function.server.RequestPredicates /** * @author Arjen Poutsma */ -public class RouterFunctionTests { +class RouterFunctionTests { @Test - public void and() { + void and() { HandlerFunction handlerFunction = request -> ServerResponse.ok().build(); RouterFunction routerFunction1 = request -> Mono.empty(); RouterFunction routerFunction2 = request -> Mono.just(handlerFunction); @@ -58,7 +58,7 @@ public class RouterFunctionTests { } @Test - public void andOther() { + void andOther() { HandlerFunction handlerFunction = request -> ServerResponse.ok().bodyValue("42"); RouterFunction routerFunction1 = request -> Mono.empty(); @@ -79,7 +79,7 @@ public class RouterFunctionTests { } @Test - public void andRoute() { + void andRoute() { RouterFunction routerFunction1 = request -> Mono.empty(); RequestPredicate requestPredicate = request -> true; @@ -97,7 +97,7 @@ public class RouterFunctionTests { } @Test - public void filter() { + void filter() { Mono stringMono = Mono.just("42"); HandlerFunction>> handlerFunction = request -> EntityResponse.fromPublisher(stringMono, String.class).build(); @@ -133,7 +133,7 @@ public class RouterFunctionTests { } @Test - public void attributes() { + void attributes() { RouterFunction route = RouterFunctions.route( GET("/atts/1"), request -> ServerResponse.ok().build()) .withAttribute("foo", "bar") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java index b59316a279..65c3feb7a5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -223,7 +223,6 @@ class RouterFunctionsTests { public HttpStatus statusCode() { return HttpStatus.OK; } - @SuppressWarnings("deprecation") @Override public int rawStatusCode() { return 200; @@ -262,7 +261,6 @@ class RouterFunctionsTests { public HttpStatus statusCode() { return HttpStatus.OK; } - @SuppressWarnings("deprecation") @Override public int rawStatusCode() { return 200; 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 9933a0dcfc..e914213bc6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -131,7 +131,6 @@ class ServerRequestWrapperTests { } @Test - @SuppressWarnings("unchecked") void cookies() { MultiValueMap cookies = mock(); given(mockRequest.cookies()).willReturn(cookies); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java index e2de6a519a..2b07a451ae 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sebastien Deleuze * @author Rossen Stoyanchev */ -public class CorsUrlHandlerMappingTests { +class CorsUrlHandlerMappingTests { private AbstractUrlHandlerMapping handlerMapping; @@ -47,7 +47,7 @@ public class CorsUrlHandlerMappingTests { @BeforeEach - public void setup() { + void setup() { this.handlerMapping = new AbstractUrlHandlerMapping() {}; this.handlerMapping.registerHandler("/welcome.html", this.welcomeController); this.handlerMapping.registerHandler("/cors.html", this.corsController); @@ -55,7 +55,7 @@ public class CorsUrlHandlerMappingTests { @Test - public void actualRequestWithoutCorsConfigurationProvider() throws Exception { + void actualRequestWithoutCorsConfigurationProvider() { String origin = "https://domain2.com"; ServerWebExchange exchange = createExchange(HttpMethod.GET, "/welcome.html", origin); Object actual = this.handlerMapping.getHandler(exchange).block(); @@ -65,7 +65,7 @@ public class CorsUrlHandlerMappingTests { } @Test - public void preflightRequestWithoutCorsConfigurationProvider() throws Exception { + void preflightRequestWithoutCorsConfigurationProvider() { String origin = "https://domain2.com"; ServerWebExchange exchange = createExchange(HttpMethod.OPTIONS, "/welcome.html", origin); Object actual = this.handlerMapping.getHandler(exchange).block(); @@ -75,7 +75,7 @@ public class CorsUrlHandlerMappingTests { } @Test - public void actualRequestWithCorsAwareHandler() throws Exception { + void actualRequestWithCorsAwareHandler() { String origin = "https://domain2.com"; ServerWebExchange exchange = createExchange(HttpMethod.GET, "/cors.html", origin); Object actual = this.handlerMapping.getHandler(exchange).block(); @@ -86,7 +86,7 @@ public class CorsUrlHandlerMappingTests { } @Test - public void preFlightWithCorsAwareHandler() throws Exception { + void preFlightWithCorsAwareHandler() { String origin = "https://domain2.com"; ServerWebExchange exchange = createExchange(HttpMethod.OPTIONS, "/cors.html", origin); Object actual = this.handlerMapping.getHandler(exchange).block(); @@ -97,7 +97,7 @@ public class CorsUrlHandlerMappingTests { } @Test - public void actualRequestWithGlobalCorsConfig() throws Exception { + void actualRequestWithGlobalCorsConfig() { CorsConfiguration mappedConfig = new CorsConfiguration(); mappedConfig.addAllowedOrigin("*"); this.handlerMapping.setCorsConfigurations(Collections.singletonMap("/welcome.html", mappedConfig)); @@ -112,7 +112,7 @@ public class CorsUrlHandlerMappingTests { } @Test - public void actualRequestWithGlobalPatternCorsConfig() throws Exception { + void actualRequestWithGlobalPatternCorsConfig() { CorsConfiguration mappedConfig = new CorsConfiguration(); mappedConfig.addAllowedOriginPattern("https://*.domain2.com"); this.handlerMapping.setCorsConfigurations(Collections.singletonMap("/welcome.html", mappedConfig)); @@ -128,7 +128,7 @@ public class CorsUrlHandlerMappingTests { } @Test - public void preFlightRequestWithGlobalCorsConfig() throws Exception { + void preFlightRequestWithGlobalCorsConfig() { CorsConfiguration mappedConfig = new CorsConfiguration(); mappedConfig.addAllowedOrigin("*"); this.handlerMapping.setCorsConfigurations(Collections.singletonMap("/welcome.html", mappedConfig)); @@ -143,7 +143,7 @@ public class CorsUrlHandlerMappingTests { } @Test - public void actualRequestWithCorsConfigurationSource() throws Exception { + void actualRequestWithCorsConfigurationSource() { this.handlerMapping.setCorsConfigurationSource(new CustomCorsConfigurationSource()); String origin = "https://domain2.com"; @@ -159,7 +159,7 @@ public class CorsUrlHandlerMappingTests { } @Test - public void preFlightRequestWithCorsConfigurationSource() throws Exception { + void preFlightRequestWithCorsConfigurationSource() { this.handlerMapping.setCorsConfigurationSource(new CustomCorsConfigurationSource()); String origin = "https://domain2.com"; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java index 65d9ab78c8..adab979d2d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java @@ -41,10 +41,9 @@ import static org.springframework.web.reactive.HandlerMapping.PATH_WITHIN_HANDLE * * @author Rossen Stoyanchev */ -public class SimpleUrlHandlerMappingTests { +class SimpleUrlHandlerMappingTests { @Test - @SuppressWarnings("resource") void handlerMappingJavaConfig() { AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext(); wac.register(WebConfig.class); @@ -61,7 +60,6 @@ public class SimpleUrlHandlerMappingTests { } @Test - @SuppressWarnings("resource") void handlerMappingXmlConfig() { ClassPathXmlApplicationContext wac = new ClassPathXmlApplicationContext("map.xml", getClass()); wac.refresh(); @@ -106,7 +104,6 @@ public class SimpleUrlHandlerMappingTests { if (bean != null) { assertThat(actual).isNotNull(); assertThat(actual).isSameAs(bean); - //noinspection OptionalGetWithoutIsPresent PathContainer path = exchange.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); assertThat(path).isNotNull(); assertThat(path.value()).isEqualTo(pathWithinMapping); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java index d614927394..69d87a1a1e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Rossen Stoyanchev */ -public class WebFluxResponseStatusExceptionHandlerTests extends AbstractResponseStatusExceptionHandlerTests { +class WebFluxResponseStatusExceptionHandlerTests extends AbstractResponseStatusExceptionHandlerTests { @Override protected ResponseStatusExceptionHandler createResponseStatusExceptionHandler() { @@ -42,14 +42,14 @@ public class WebFluxResponseStatusExceptionHandlerTests extends AbstractResponse @Test - public void handleAnnotatedException() { + void handleAnnotatedException() { Throwable ex = new CustomException(); this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.I_AM_A_TEAPOT); } @Test - public void handleNestedAnnotatedException() { + void handleNestedAnnotatedException() { Throwable ex = new Exception(new CustomException()); this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.I_AM_A_TEAPOT); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java index fc1a2437e1..3371ca5141 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java @@ -16,7 +16,6 @@ package org.springframework.web.reactive.resource; -import java.io.IOException; import java.time.Duration; import java.util.ArrayList; import java.util.List; @@ -55,7 +54,7 @@ public class CachingResourceResolverTests { @BeforeEach - public void setup() { + void setup() { this.cache = new ConcurrentMapCache("resourceCache"); @@ -70,7 +69,7 @@ public class CachingResourceResolverTests { @Test - public void resolveResourceInternal() { + void resolveResourceInternal() { Resource expected = new ClassPathResource("test/bar.css", getClass()); MockServerWebExchange exchange = MockServerWebExchange.from(get("")); Resource actual = this.chain.resolveResource(exchange, "bar.css", this.locations).block(TIMEOUT); @@ -80,7 +79,7 @@ public class CachingResourceResolverTests { } @Test - public void resolveResourceInternalFromCache() { + void resolveResourceInternalFromCache() { Resource expected = mock(); this.cache.put(resourceKey("bar.css"), expected); @@ -91,13 +90,13 @@ public class CachingResourceResolverTests { } @Test - public void resolveResourceInternalNoMatch() { + void resolveResourceInternalNoMatch() { MockServerWebExchange exchange = MockServerWebExchange.from(get("")); assertThat(this.chain.resolveResource(exchange, "invalid.css", this.locations).block(TIMEOUT)).isNull(); } @Test - public void resolverUrlPath() { + void resolverUrlPath() { String expected = "/foo.css"; String actual = this.chain.resolveUrlPath(expected, this.locations).block(TIMEOUT); @@ -105,7 +104,7 @@ public class CachingResourceResolverTests { } @Test - public void resolverUrlPathFromCache() { + void resolverUrlPathFromCache() { String expected = "cached-imaginary.css"; this.cache.put(CachingResourceResolver.RESOLVED_URL_PATH_CACHE_KEY_PREFIX + "imaginary.css", expected); String actual = this.chain.resolveUrlPath("imaginary.css", this.locations).block(TIMEOUT); @@ -114,12 +113,12 @@ public class CachingResourceResolverTests { } @Test - public void resolverUrlPathNoMatch() { + void resolverUrlPathNoMatch() { assertThat(this.chain.resolveUrlPath("invalid.css", this.locations).block(TIMEOUT)).isNull(); } @Test - public void resolveResourceAcceptEncodingInCacheKey(GzippedFiles gzippedFiles) throws IOException { + void resolveResourceAcceptEncodingInCacheKey(GzippedFiles gzippedFiles) { String file = "bar.css"; gzippedFiles.create(file); @@ -152,7 +151,7 @@ public class CachingResourceResolverTests { } @Test - public void resolveResourceNoAcceptEncoding() { + void resolveResourceNoAcceptEncoding() { String file = "bar.css"; MockServerWebExchange exchange = MockServerWebExchange.from(get(file)); Resource expected = this.chain.resolveResource(exchange, file, this.locations).block(TIMEOUT); @@ -164,7 +163,7 @@ public class CachingResourceResolverTests { } @Test - public void resolveResourceMatchingEncoding() { + void resolveResourceMatchingEncoding() { Resource resource = mock(); Resource gzipped = mock(); this.cache.put(resourceKey("bar.css"), resource); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ContentBasedVersionStrategyTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ContentBasedVersionStrategyTests.java index 1fae8ba1d8..16ff464ec9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ContentBasedVersionStrategyTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ContentBasedVersionStrategyTests.java @@ -34,19 +34,19 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rossen Stoyanchev * @author Brian Clozel */ -public class ContentBasedVersionStrategyTests { +class ContentBasedVersionStrategyTests { private ContentVersionStrategy strategy = new ContentVersionStrategy(); @BeforeEach - public void setup() { + void setup() { VersionResourceResolver versionResourceResolver = new VersionResourceResolver(); versionResourceResolver.setStrategyMap(Collections.singletonMap("/**", this.strategy)); } @Test - public void extractVersion() { + void extractVersion() { String hash = "7fbe76cdac6093784895bb4989203e5a"; String path = "font-awesome/css/font-awesome.min-" + hash + ".css"; @@ -55,7 +55,7 @@ public class ContentBasedVersionStrategyTests { } @Test - public void removeVersion() { + void removeVersion() { String hash = "7fbe76cdac6093784895bb4989203e5a"; String path = "font-awesome/css/font-awesome.min%s%s.css"; @@ -63,7 +63,7 @@ public class ContentBasedVersionStrategyTests { } @Test - public void getResourceVersion() throws Exception { + void getResourceVersion() throws Exception { Resource expected = new ClassPathResource("test/bar.css", getClass()); String hash = DigestUtils.md5DigestAsHex(FileCopyUtils.copyToByteArray(expected.getInputStream())); @@ -71,7 +71,7 @@ public class ContentBasedVersionStrategyTests { } @Test - public void addVersionToUrl() { + void addVersionToUrl() { assertThat(this.strategy.addVersion("test/bar.css", "123")).isEqualTo("test/bar-123.css"); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java index 98437a1569..f3da6ae0a4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java @@ -165,7 +165,7 @@ class CssLinkResourceTransformerTests { } @Test // https://github.com/spring-projects/spring-framework/issues/22602 - void transformEmptyUrlFunction() throws Exception { + void transformEmptyUrlFunction() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/static/empty_url_function.css")); Resource css = getResource("empty_url_function.css"); String expected = """ diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java index 5661141389..3aff648ca6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java @@ -53,7 +53,7 @@ public class EncodedResourceResolverTests { @BeforeEach - public void setup() { + void setup() { Cache cache = new ConcurrentMapCache("resourceCache"); VersionResourceResolver versionResolver = new VersionResourceResolver(); @@ -73,7 +73,7 @@ public class EncodedResourceResolverTests { @Test - public void resolveGzipped(GzippedFiles gzippedFiles) { + void resolveGzipped(GzippedFiles gzippedFiles) { MockServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.get("").header("Accept-Encoding", "gzip")); @@ -93,7 +93,7 @@ public class EncodedResourceResolverTests { } @Test - public void resolveGzippedWithVersion(GzippedFiles gzippedFiles) { + void resolveGzippedWithVersion(GzippedFiles gzippedFiles) { MockServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.get("").header("Accept-Encoding", "gzip")); @@ -108,7 +108,7 @@ public class EncodedResourceResolverTests { } @Test - public void resolveFromCacheWithEncodingVariants(GzippedFiles gzippedFiles) { + void resolveFromCacheWithEncodingVariants(GzippedFiles gzippedFiles) { // 1. Resolve, and cache .gz variant diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/FixedVersionStrategyTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/FixedVersionStrategyTests.java index 9a2919fc0d..94ca37d6bf 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/FixedVersionStrategyTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/FixedVersionStrategyTests.java @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rossen Stoyanchev * @author Brian Clozel */ -public class FixedVersionStrategyTests { +class FixedVersionStrategyTests { private static final String VERSION = "1df341f"; @@ -39,30 +39,30 @@ public class FixedVersionStrategyTests { @BeforeEach - public void setup() { + void setup() { this.strategy = new FixedVersionStrategy(VERSION); } @Test - public void emptyPrefixVersion() { + void emptyPrefixVersion() { assertThatIllegalArgumentException().isThrownBy(() -> new FixedVersionStrategy(" ")); } @Test - public void extractVersion() { + void extractVersion() { assertThat(this.strategy.extractVersion(VERSION + "/" + PATH)).isEqualTo(VERSION); assertThat(this.strategy.extractVersion(PATH)).isNull(); } @Test - public void removeVersion() { + void removeVersion() { assertThat(this.strategy.removeVersion(VERSION + "/" + PATH, VERSION)).isEqualTo(("/" + PATH)); } @Test - public void addVersion() { + void addVersion() { assertThat(this.strategy.addVersion("/" + PATH, VERSION)).isEqualTo((VERSION + "/" + PATH)); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java index 76af75c05b..4a6d5366a4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/GzipSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -47,7 +47,7 @@ class GzipSupport implements AfterEachCallback, ParameterResolver { private static final Namespace namespace = Namespace.create(GzipSupport.class); @Override - public void afterEach(ExtensionContext context) throws Exception { + public void afterEach(ExtensionContext context) { GzippedFiles gzippedFiles = getStore(context).remove(GzippedFiles.class, GzippedFiles.class); if (gzippedFiles != null) { for (File gzippedFile: gzippedFiles.created) { 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 69479a3a2e..4610d4b40d 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 @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class PathResourceResolverTests { +class PathResourceResolverTests { private static final Duration TIMEOUT = Duration.ofSeconds(5); @@ -44,7 +44,7 @@ public class PathResourceResolverTests { @Test - public void resolveFromClasspath() throws IOException { + void resolveFromClasspath() throws IOException { Resource location = new ClassPathResource("test/", PathResourceResolver.class); String path = "bar.css"; List locations = Collections.singletonList(location); @@ -54,7 +54,7 @@ public class PathResourceResolverTests { } @Test - public void resolveFromClasspathRoot() { + void resolveFromClasspathRoot() { Resource location = new ClassPathResource("/"); String path = "org/springframework/web/reactive/resource/test/bar.css"; List locations = Collections.singletonList(location); @@ -80,7 +80,7 @@ public class PathResourceResolverTests { } @Test - public void checkResource() throws IOException { + void checkResource() throws IOException { Resource location = new ClassPathResource("test/", PathResourceResolver.class); testCheckResource(location, "../testsecret/secret.txt"); testCheckResource(location, "test/../../testsecret/secret.txt"); @@ -98,7 +98,7 @@ public class PathResourceResolverTests { testCheckResource(location, "url:" + secretPath); } - private void testCheckResource(Resource location, String requestPath) throws IOException { + private void testCheckResource(Resource location, String requestPath) { List locations = Collections.singletonList(location); Resource actual = this.resolver.resolveResource(null, requestPath, locations, null).block(TIMEOUT); assertThat(actual).isNull(); @@ -116,7 +116,7 @@ public class PathResourceResolverTests { } @Test - public void checkResourceWithAllowedLocations() { + void checkResourceWithAllowedLocations() { this.resolver.setAllowedLocations( new ClassPathResource("test/", PathResourceResolver.class), new ClassPathResource("testalternatepath/", PathResourceResolver.class) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java index 2a8ad67318..8f15a9eac7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rossen Stoyanchev * @author Brian Clozel */ -public class ResourceTransformerSupportTests { +class ResourceTransformerSupportTests { private static final Duration TIMEOUT = Duration.ofSeconds(5); @@ -50,7 +50,7 @@ public class ResourceTransformerSupportTests { @BeforeEach - public void setup() { + void setup() { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy())); PathResourceResolver pathResolver = new PathResourceResolver(); @@ -78,7 +78,7 @@ public class ResourceTransformerSupportTests { @Test - public void resolveUrlPath() { + void resolveUrlPath() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/resources/main.css")); String resourcePath = "/resources/bar.css"; Resource resource = getResource("main.css"); @@ -89,7 +89,7 @@ public class ResourceTransformerSupportTests { } @Test - public void resolveUrlPathWithRelativePath() { + void resolveUrlPathWithRelativePath() { Resource resource = getResource("main.css"); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("")); String actual = this.transformer.resolveUrlPath("bar.css", exchange, resource, this.chain).block(TIMEOUT); @@ -98,7 +98,7 @@ public class ResourceTransformerSupportTests { } @Test - public void resolveUrlPathWithRelativePathInParentDirectory() { + void resolveUrlPathWithRelativePathInParentDirectory() { Resource resource = getResource("images/image.png"); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("")); String actual = this.transformer.resolveUrlPath("../bar.css", exchange, resource, this.chain).block(TIMEOUT); @@ -107,7 +107,7 @@ public class ResourceTransformerSupportTests { } @Test - public void toAbsolutePath() { + void toAbsolutePath() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/resources/main.css")); String absolute = this.transformer.toAbsolutePath("img/image.png", exchange); assertThat(absolute).isEqualTo("/resources/img/image.png"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java index 023943dc04..ce16fc30de 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java @@ -46,7 +46,7 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * @author Rossen Stoyanchev * @author Brian Clozel */ -public class ResourceUrlProviderTests { +class ResourceUrlProviderTests { private static final Duration TIMEOUT = Duration.ofSeconds(5); @@ -129,7 +129,6 @@ public class ResourceUrlProviderTests { } @Test // SPR-12592 - @SuppressWarnings("resource") void initializeOnce() { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setServletContext(new MockServletContext()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java index 82161f3873..9915b3f660 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java @@ -135,7 +135,7 @@ class ResourceWebHandlerTests { } @Test - void servesHtmlResources() throws Exception { + void servesHtmlResources() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("")); setPathWithinHandlerMapping(exchange, "foo.html"); setBestMachingPattern(exchange, "/**"); @@ -204,7 +204,7 @@ class ResourceWebHandlerTests { @ParameterizedTest @MethodSource("httpMethods") - void resourceNotFound(HttpMethod method) throws Exception { + void resourceNotFound(HttpMethod method) { MockServerHttpRequest request = MockServerHttpRequest.method(method, "").build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); setPathWithinHandlerMapping(exchange, "not-there.css"); @@ -579,7 +579,7 @@ class ResourceWebHandlerTests { private ResourceWebHandler handler; @BeforeEach - void setup() throws Exception { + void setup() { this.handler = new ResourceWebHandler(); this.handler.setLocations(List.of(testResource, testAlternatePathResource, webjarsResource)); } @@ -690,23 +690,23 @@ class ResourceWebHandlerTests { Resource location = new ClassPathResource("test/", getClass()); this.handler.setLocations(List.of(location)); - testResolvePathWithTraversal(method, "../testsecret/secret.txt", location); - testResolvePathWithTraversal(method, "test/../../testsecret/secret.txt", location); - testResolvePathWithTraversal(method, ":/../../testsecret/secret.txt", location); + testResolvePathWithTraversal(method, "../testsecret/secret.txt"); + testResolvePathWithTraversal(method, "test/../../testsecret/secret.txt"); + testResolvePathWithTraversal(method, ":/../../testsecret/secret.txt"); location = new UrlResource(getClass().getResource("./test/")); this.handler.setLocations(List.of(location)); Resource secretResource = new UrlResource(getClass().getResource("testsecret/secret.txt")); String secretPath = secretResource.getURL().getPath(); - testResolvePathWithTraversal(method, "file:" + secretPath, location); - testResolvePathWithTraversal(method, "/file:" + secretPath, location); - testResolvePathWithTraversal(method, "url:" + secretPath, location); - testResolvePathWithTraversal(method, "/url:" + secretPath, location); - testResolvePathWithTraversal(method, "////../.." + secretPath, location); - testResolvePathWithTraversal(method, "/%2E%2E/testsecret/secret.txt", location); - testResolvePathWithTraversal(method, "%2F%2F%2E%2E%2F%2Ftestsecret/secret.txt", location); - testResolvePathWithTraversal(method, "url:" + secretPath, location); + testResolvePathWithTraversal(method, "file:" + secretPath); + testResolvePathWithTraversal(method, "/file:" + secretPath); + testResolvePathWithTraversal(method, "url:" + secretPath); + testResolvePathWithTraversal(method, "/url:" + secretPath); + testResolvePathWithTraversal(method, "////../.." + secretPath); + testResolvePathWithTraversal(method, "/%2E%2E/testsecret/secret.txt"); + testResolvePathWithTraversal(method, "%2F%2F%2E%2E%2F%2Ftestsecret/secret.txt"); + testResolvePathWithTraversal(method, "url:" + secretPath); // The following tests fail with a MalformedURLException on Windows // testResolvePathWithTraversal(location, "/" + secretPath); @@ -717,7 +717,7 @@ class ResourceWebHandlerTests { return Arrays.stream(HttpMethod.values()); } - private void testResolvePathWithTraversal(HttpMethod httpMethod, String requestPath, Resource location) { + private void testResolvePathWithTraversal(HttpMethod httpMethod, String requestPath) { ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.method(httpMethod, "")); setPathWithinHandlerMapping(exchange, requestPath); setBestMachingPattern(exchange, "/**"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java index a9c6b0c151..da3565fa8e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java @@ -45,7 +45,7 @@ import static org.springframework.http.MediaType.TEXT_PLAIN; * * @author Rossen Stoyanchev */ -public class HandlerResultHandlerTests { +class HandlerResultHandlerTests { private final TestResultHandler resultHandler = new TestResultHandler(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java index b9a4ce1c90..c68fb25721 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -74,7 +74,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra ResponseEntity response = new RestTemplate().exchange(request, byte[].class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isEqualTo("foo".getBytes("UTF-8")); + assertThat(response.getBody()).isEqualTo("foo".getBytes(StandardCharsets.UTF_8)); } @ParameterizedHttpServerTest @@ -87,7 +87,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra ResponseEntity response = new RestTemplate().exchange(request, byte[].class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isEqualTo("bar".getBytes("UTF-8")); + assertThat(response.getBody()).isEqualTo("bar".getBytes(StandardCharsets.UTF_8)); } @ParameterizedHttpServerTest diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java index 8d25d2eb72..eaa1a79afe 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * * @author Rossen Stoyanchev */ -public class CompositeRequestConditionTests { +class CompositeRequestConditionTests { private ParamsRequestCondition param1; private ParamsRequestCondition param2; @@ -43,7 +43,7 @@ public class CompositeRequestConditionTests { @BeforeEach - public void setup() throws Exception { + void setup() { this.param1 = new ParamsRequestCondition("param1"); this.param2 = new ParamsRequestCondition("param2"); this.param3 = this.param1.combine(this.param2); @@ -55,7 +55,7 @@ public class CompositeRequestConditionTests { @Test - public void combine() { + void combine() { CompositeRequestCondition cond1 = new CompositeRequestCondition(this.param1, this.header1); CompositeRequestCondition cond2 = new CompositeRequestCondition(this.param2, this.header2); CompositeRequestCondition cond3 = new CompositeRequestCondition(this.param3, this.header3); @@ -64,7 +64,7 @@ public class CompositeRequestConditionTests { } @Test - public void combineEmpty() { + void combineEmpty() { CompositeRequestCondition empty = new CompositeRequestCondition(); CompositeRequestCondition notEmpty = new CompositeRequestCondition(this.param1); @@ -74,7 +74,7 @@ public class CompositeRequestConditionTests { } @Test - public void combineDifferentLength() { + void combineDifferentLength() { CompositeRequestCondition cond1 = new CompositeRequestCondition(this.param1); CompositeRequestCondition cond2 = new CompositeRequestCondition(this.param1, this.header1); assertThatIllegalArgumentException().isThrownBy(() -> @@ -82,7 +82,7 @@ public class CompositeRequestConditionTests { } @Test - public void match() { + void match() { MockServerHttpRequest request = MockServerHttpRequest.get("/path?param1=paramValue1").build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); @@ -96,19 +96,19 @@ public class CompositeRequestConditionTests { } @Test - public void noMatch() { + void noMatch() { CompositeRequestCondition cond = new CompositeRequestCondition(this.param1); assertThat(cond.getMatchingCondition(MockServerWebExchange.from(MockServerHttpRequest.get("/")))).isNull(); } @Test - public void matchEmpty() { + void matchEmpty() { CompositeRequestCondition empty = new CompositeRequestCondition(); assertThat(empty.getMatchingCondition(MockServerWebExchange.from(MockServerHttpRequest.get("/")))).isSameAs(empty); } @Test - public void compare() { + void compare() { CompositeRequestCondition cond1 = new CompositeRequestCondition(this.param1); CompositeRequestCondition cond3 = new CompositeRequestCondition(this.param3); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); @@ -118,7 +118,7 @@ public class CompositeRequestConditionTests { } @Test - public void compareEmpty() { + void compareEmpty() { CompositeRequestCondition empty = new CompositeRequestCondition(); CompositeRequestCondition notEmpty = new CompositeRequestCondition(this.param1); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); @@ -129,7 +129,7 @@ public class CompositeRequestConditionTests { } @Test - public void compareDifferentLength() { + void compareDifferentLength() { CompositeRequestCondition cond1 = new CompositeRequestCondition(this.param1); CompositeRequestCondition cond2 = new CompositeRequestCondition(this.param1, this.header1); assertThatIllegalArgumentException().isThrownBy(() -> diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java index fae987d2c4..be4a8f3026 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.fail; /** * @author Arjen Poutsma */ -public class ConsumesRequestConditionTests { +class ConsumesRequestConditionTests { @Test - public void consumesMatch() { + void consumesMatch() { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain"); @@ -43,7 +43,7 @@ public class ConsumesRequestConditionTests { } @Test - public void negatedConsumesMatch() { + void negatedConsumesMatch() { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("!text/plain"); @@ -51,13 +51,13 @@ public class ConsumesRequestConditionTests { } @Test - public void getConsumableMediaTypesNegatedExpression() { + void getConsumableMediaTypesNegatedExpression() { ConsumesRequestCondition condition = new ConsumesRequestCondition("!application/xml"); assertThat(condition.getConsumableMediaTypes()).isEqualTo(Collections.emptySet()); } @Test - public void consumesWildcardMatch() { + void consumesWildcardMatch() { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/*"); @@ -65,7 +65,7 @@ public class ConsumesRequestConditionTests { } @Test - public void consumesMultipleMatch() { + void consumesMultipleMatch() { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain", "application/xml"); @@ -73,7 +73,7 @@ public class ConsumesRequestConditionTests { } @Test - public void consumesSingleNoMatch() { + void consumesSingleNoMatch() { MockServerWebExchange exchange = postExchange("application/xml"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain"); @@ -105,7 +105,7 @@ public class ConsumesRequestConditionTests { } @Test - public void consumesParseError() { + void consumesParseError() { MockServerWebExchange exchange = postExchange("01"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain"); @@ -113,7 +113,7 @@ public class ConsumesRequestConditionTests { } @Test - public void consumesParseErrorWithNegation() { + void consumesParseErrorWithNegation() { MockServerWebExchange exchange = postExchange("01"); ConsumesRequestCondition condition = new ConsumesRequestCondition("!text/plain"); @@ -139,7 +139,7 @@ public class ConsumesRequestConditionTests { } @Test - public void compareToSingle() { + void compareToSingle() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); ConsumesRequestCondition condition1 = new ConsumesRequestCondition("text/plain"); @@ -153,7 +153,7 @@ public class ConsumesRequestConditionTests { } @Test - public void compareToMultiple() { + void compareToMultiple() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); ConsumesRequestCondition condition1 = new ConsumesRequestCondition("*/*", "text/plain"); @@ -168,7 +168,7 @@ public class ConsumesRequestConditionTests { @Test - public void combine() throws Exception { + void combine() { ConsumesRequestCondition condition1 = new ConsumesRequestCondition("text/plain"); ConsumesRequestCondition condition2 = new ConsumesRequestCondition("application/xml"); @@ -177,7 +177,7 @@ public class ConsumesRequestConditionTests { } @Test - public void combineWithDefault() { + void combineWithDefault() { ConsumesRequestCondition condition1 = new ConsumesRequestCondition("text/plain"); ConsumesRequestCondition condition2 = new ConsumesRequestCondition(); @@ -186,7 +186,7 @@ public class ConsumesRequestConditionTests { } @Test - public void parseConsumesAndHeaders() { + void parseConsumesAndHeaders() { String[] consumes = new String[] {"text/plain"}; String[] headers = new String[]{"foo=bar", "content-type=application/xml,application/pdf"}; ConsumesRequestCondition condition = new ConsumesRequestCondition(consumes, headers); @@ -195,7 +195,7 @@ public class ConsumesRequestConditionTests { } @Test - public void getMatchingCondition() { + void getMatchingCondition() { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain", "application/xml"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java index 532848cbbf..1b9fbd652d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java @@ -31,10 +31,10 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * * @author Rossen Stoyanchev */ -public class HeadersRequestConditionTests { +class HeadersRequestConditionTests { @Test - public void headerEquals() { + void headerEquals() { assertThat(new HeadersRequestCondition("foo")).isEqualTo(new HeadersRequestCondition("foo")); assertThat(new HeadersRequestCondition("FOO")).isEqualTo(new HeadersRequestCondition("foo")); assertThat(new HeadersRequestCondition("bar")).isNotEqualTo(new HeadersRequestCondition("foo")); @@ -43,7 +43,7 @@ public class HeadersRequestConditionTests { } @Test - public void headerPresent() { + void headerPresent() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "")); HeadersRequestCondition condition = new HeadersRequestCondition("accept"); @@ -51,7 +51,7 @@ public class HeadersRequestConditionTests { } @Test - public void headerPresentNoMatch() { + void headerPresentNoMatch() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("bar", "")); HeadersRequestCondition condition = new HeadersRequestCondition("foo"); @@ -59,7 +59,7 @@ public class HeadersRequestConditionTests { } @Test - public void headerNotPresent() { + void headerNotPresent() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/")); HeadersRequestCondition condition = new HeadersRequestCondition("!accept"); @@ -67,7 +67,7 @@ public class HeadersRequestConditionTests { } @Test - public void headerValueMatch() { + void headerValueMatch() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "bar")); HeadersRequestCondition condition = new HeadersRequestCondition("foo=bar"); @@ -75,7 +75,7 @@ public class HeadersRequestConditionTests { } @Test - public void headerValueNoMatch() { + void headerValueNoMatch() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "bazz")); HeadersRequestCondition condition = new HeadersRequestCondition("foo=bar"); @@ -83,7 +83,7 @@ public class HeadersRequestConditionTests { } @Test - public void headerCaseSensitiveValueMatch() { + void headerCaseSensitiveValueMatch() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "bar")); HeadersRequestCondition condition = new HeadersRequestCondition("foo=Bar"); @@ -91,7 +91,7 @@ public class HeadersRequestConditionTests { } @Test - public void headerValueMatchNegated() { + void headerValueMatchNegated() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "baz")); HeadersRequestCondition condition = new HeadersRequestCondition("foo!=bar"); @@ -99,7 +99,7 @@ public class HeadersRequestConditionTests { } @Test - public void headerValueNoMatchNegated() { + void headerValueNoMatchNegated() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "bar")); HeadersRequestCondition condition = new HeadersRequestCondition("foo!=bar"); @@ -107,7 +107,7 @@ public class HeadersRequestConditionTests { } @Test - public void compareTo() { + void compareTo() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/")); HeadersRequestCondition condition1 = new HeadersRequestCondition("foo", "bar", "baz"); @@ -132,7 +132,7 @@ public class HeadersRequestConditionTests { } @Test - public void compareToWithNegatedMatch() { + void compareToWithNegatedMatch() { ServerWebExchange exchange = MockServerWebExchange.from(get("/")); HeadersRequestCondition condition1 = new HeadersRequestCondition("foo!=a"); @@ -142,7 +142,7 @@ public class HeadersRequestConditionTests { } @Test - public void combine() { + void combine() { HeadersRequestCondition condition1 = new HeadersRequestCondition("foo=bar"); HeadersRequestCondition condition2 = new HeadersRequestCondition("foo=baz"); @@ -152,7 +152,7 @@ public class HeadersRequestConditionTests { } @Test - public void getMatchingCondition() { + void getMatchingCondition() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "bar")); HeadersRequestCondition condition = new HeadersRequestCondition("foo"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java index 8c49051043..5a4bc69fd8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java @@ -34,19 +34,19 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * * @author Rossen Stoyanchev */ -public class PatternsRequestConditionTests { +class PatternsRequestConditionTests { private final PathPatternParser parser = new PathPatternParser(); @Test - public void prependNonEmptyPatternsOnly() { + void prependNonEmptyPatternsOnly() { PatternsRequestCondition c = createPatternsCondition(""); assertThat(c.getPatterns().iterator().next().getPatternString()) .as("Do not prepend empty patterns (SPR-8255)").isEmpty(); } @Test - public void combineEmptySets() { + void combineEmptySets() { PatternsRequestCondition c1 = new PatternsRequestCondition(); PatternsRequestCondition c2 = new PatternsRequestCondition(); PatternsRequestCondition c3 = c1.combine(c2); @@ -56,7 +56,7 @@ public class PatternsRequestConditionTests { } @Test - public void combineOnePatternWithEmptySet() { + void combineOnePatternWithEmptySet() { PatternsRequestCondition c1 = createPatternsCondition("/type1", "/type2"); PatternsRequestCondition c2 = new PatternsRequestCondition(); @@ -69,7 +69,7 @@ public class PatternsRequestConditionTests { } @Test - public void combineMultiplePatterns() { + void combineMultiplePatterns() { PatternsRequestCondition c1 = createPatternsCondition("/t1", "/t2"); PatternsRequestCondition c2 = createPatternsCondition("/m1", "/m2"); @@ -77,7 +77,7 @@ public class PatternsRequestConditionTests { } @Test - public void matchDirectPath() { + void matchDirectPath() { PatternsRequestCondition condition = createPatternsCondition("/foo"); MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo")); PatternsRequestCondition match = condition.getMatchingCondition(exchange); @@ -86,7 +86,7 @@ public class PatternsRequestConditionTests { } @Test - public void matchPattern() { + void matchPattern() { PatternsRequestCondition condition = createPatternsCondition("/foo/*"); MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo/bar")); PatternsRequestCondition match = condition.getMatchingCondition(exchange); @@ -95,7 +95,7 @@ public class PatternsRequestConditionTests { } @Test - public void matchSortPatterns() { + void matchSortPatterns() { PatternsRequestCondition condition = createPatternsCondition("/*/*", "/foo/bar", "/foo/*"); MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo/bar")); PatternsRequestCondition match = condition.getMatchingCondition(exchange); @@ -137,7 +137,7 @@ public class PatternsRequestConditionTests { } @Test - public void matchPatternContainsExtension() { + void matchPatternContainsExtension() { PatternsRequestCondition condition = createPatternsCondition("/foo.jpg"); MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo.html")); PatternsRequestCondition match = condition.getMatchingCondition(exchange); @@ -157,7 +157,7 @@ public class PatternsRequestConditionTests { } @Test - public void compareToConsistentWithEquals() { + void compareToConsistentWithEquals() { PatternsRequestCondition c1 = createPatternsCondition("/foo*"); PatternsRequestCondition c2 = createPatternsCondition("/foo*"); @@ -165,7 +165,7 @@ public class PatternsRequestConditionTests { } @Test - public void equallyMatchingPatternsAreBothPresent() { + void equallyMatchingPatternsAreBothPresent() { PatternsRequestCondition c = createPatternsCondition("/a", "/b"); assertThat(c.getPatterns()).hasSize(2); Iterator itr = c.getPatterns().iterator(); @@ -174,7 +174,7 @@ public class PatternsRequestConditionTests { } @Test - public void comparePatternSpecificity() { + void comparePatternSpecificity() { ServerWebExchange exchange = MockServerWebExchange.from(get("/foo")); PatternsRequestCondition c1 = createPatternsCondition("/fo*"); @@ -191,7 +191,7 @@ public class PatternsRequestConditionTests { } @Test - public void compareNumberOfMatchingPatterns() { + void compareNumberOfMatchingPatterns() { ServerWebExchange exchange = MockServerWebExchange.from(get("/foo.html")); PatternsRequestCondition c1 = createPatternsCondition("/foo.*", "/foo.jpeg"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java index c9b5713bf9..5f2b929a8a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java @@ -36,10 +36,10 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * * @author Rossen Stoyanchev */ -public class ProducesRequestConditionTests { +class ProducesRequestConditionTests { @Test - public void match() { + void match() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "text/plain")); ProducesRequestCondition condition = new ProducesRequestCondition("text/plain"); @@ -47,7 +47,7 @@ public class ProducesRequestConditionTests { } @Test - public void matchNegated() { + void matchNegated() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "text/plain")); ProducesRequestCondition condition = new ProducesRequestCondition("!text/plain"); @@ -55,13 +55,13 @@ public class ProducesRequestConditionTests { } @Test - public void getProducibleMediaTypes() { + void getProducibleMediaTypes() { ProducesRequestCondition condition = new ProducesRequestCondition("!application/xml"); assertThat(condition.getProducibleMediaTypes()).isEqualTo(Collections.emptySet()); } @Test - public void matchWildcard() { + void matchWildcard() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "text/plain")); ProducesRequestCondition condition = new ProducesRequestCondition("text/*"); @@ -69,7 +69,7 @@ public class ProducesRequestConditionTests { } @Test - public void matchMultiple() { + void matchMultiple() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "text/plain")); ProducesRequestCondition condition = new ProducesRequestCondition("text/plain", "application/xml"); @@ -77,7 +77,7 @@ public class ProducesRequestConditionTests { } @Test - public void matchSingle() { + void matchSingle() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "application/xml")); ProducesRequestCondition condition = new ProducesRequestCondition("text/plain"); @@ -105,7 +105,7 @@ public class ProducesRequestConditionTests { } @Test - public void matchParseError() { + void matchParseError() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "bogus")); ProducesRequestCondition condition = new ProducesRequestCondition("text/plain"); @@ -113,7 +113,7 @@ public class ProducesRequestConditionTests { } @Test - public void matchParseErrorWithNegation() { + void matchParseErrorWithNegation() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "bogus")); ProducesRequestCondition condition = new ProducesRequestCondition("!text/plain"); @@ -149,7 +149,7 @@ public class ProducesRequestConditionTests { } @Test - public void compareTo() { + void compareTo() { ProducesRequestCondition html = new ProducesRequestCondition("text/html"); ProducesRequestCondition xml = new ProducesRequestCondition("application/xml"); ProducesRequestCondition none = new ProducesRequestCondition(); @@ -185,7 +185,7 @@ public class ProducesRequestConditionTests { } @Test - public void compareToWithSingleExpression() { + void compareToWithSingleExpression() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "text/plain")); ProducesRequestCondition condition1 = new ProducesRequestCondition("text/plain"); @@ -199,7 +199,7 @@ public class ProducesRequestConditionTests { } @Test - public void compareToMultipleExpressions() { + void compareToMultipleExpressions() { ProducesRequestCondition condition1 = new ProducesRequestCondition("*/*", "text/plain"); ProducesRequestCondition condition2 = new ProducesRequestCondition("text/*", "text/plain;q=0.7"); @@ -213,7 +213,7 @@ public class ProducesRequestConditionTests { } @Test - public void compareToMultipleExpressionsAndMultipleAcceptHeaderValues() { + void compareToMultipleExpressionsAndMultipleAcceptHeaderValues() { ProducesRequestCondition condition1 = new ProducesRequestCondition("text/*", "text/plain"); ProducesRequestCondition condition2 = new ProducesRequestCondition("application/*", "application/xml"); @@ -239,7 +239,7 @@ public class ProducesRequestConditionTests { // SPR-8536 @Test - public void compareToMediaTypeAll() { + void compareToMediaTypeAll() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/")); ProducesRequestCondition condition1 = new ProducesRequestCondition(); @@ -275,7 +275,7 @@ public class ProducesRequestConditionTests { // SPR-9021 @Test - public void compareToMediaTypeAllWithParameter() { + void compareToMediaTypeAllWithParameter() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "*/*;q=0.9")); ProducesRequestCondition condition1 = new ProducesRequestCondition(); @@ -286,7 +286,7 @@ public class ProducesRequestConditionTests { } @Test - public void compareToEqualMatch() { + void compareToEqualMatch() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "text/*")); ProducesRequestCondition condition1 = new ProducesRequestCondition("text/plain"); @@ -300,7 +300,7 @@ public class ProducesRequestConditionTests { } @Test - public void compareEmptyInvalidAccept() { + void compareEmptyInvalidAccept() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "foo")); ProducesRequestCondition condition1 = new ProducesRequestCondition(); @@ -312,7 +312,7 @@ public class ProducesRequestConditionTests { @Test - public void combine() { + void combine() { ProducesRequestCondition condition1 = new ProducesRequestCondition("text/plain"); ProducesRequestCondition condition2 = new ProducesRequestCondition("application/xml"); @@ -321,7 +321,7 @@ public class ProducesRequestConditionTests { } @Test - public void combineWithDefault() { + void combineWithDefault() { ProducesRequestCondition condition1 = new ProducesRequestCondition("text/plain"); ProducesRequestCondition condition2 = new ProducesRequestCondition(); @@ -330,7 +330,7 @@ public class ProducesRequestConditionTests { } @Test - public void instantiateWithProducesAndHeaderConditions() { + void instantiateWithProducesAndHeaderConditions() { String[] produces = new String[] {"text/plain"}; String[] headers = new String[]{"foo=bar", "accept=application/xml,application/pdf"}; ProducesRequestCondition condition = new ProducesRequestCondition(produces, headers); @@ -339,7 +339,7 @@ public class ProducesRequestConditionTests { } @Test - public void getMatchingCondition() { + void getMatchingCondition() { MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "text/plain")); ProducesRequestCondition condition = new ProducesRequestCondition("text/plain", "application/xml"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java index c98f4d2a76..d28c5d7e36 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java @@ -30,13 +30,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * * @author Rossen Stoyanchev */ -public class RequestConditionHolderTests { +class RequestConditionHolderTests { private final MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); @Test - public void combine() { + void combine() { RequestConditionHolder params1 = new RequestConditionHolder(new ParamsRequestCondition("name1")); RequestConditionHolder params2 = new RequestConditionHolder(new ParamsRequestCondition("name2")); RequestConditionHolder expected = new RequestConditionHolder(new ParamsRequestCondition("name1", "name2")); @@ -45,7 +45,7 @@ public class RequestConditionHolderTests { } @Test - public void combineEmpty() { + void combineEmpty() { RequestConditionHolder empty = new RequestConditionHolder(null); RequestConditionHolder notEmpty = new RequestConditionHolder(new ParamsRequestCondition("name")); @@ -55,7 +55,7 @@ public class RequestConditionHolderTests { } @Test - public void combineIncompatible() { + void combineIncompatible() { RequestConditionHolder params = new RequestConditionHolder(new ParamsRequestCondition("name")); RequestConditionHolder headers = new RequestConditionHolder(new HeadersRequestCondition("name")); assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> @@ -63,7 +63,7 @@ public class RequestConditionHolderTests { } @Test - public void match() { + void match() { RequestMethodsRequestCondition rm = new RequestMethodsRequestCondition(RequestMethod.GET, RequestMethod.POST); RequestConditionHolder custom = new RequestConditionHolder(rm); RequestMethodsRequestCondition expected = new RequestMethodsRequestCondition(RequestMethod.GET); @@ -74,7 +74,7 @@ public class RequestConditionHolderTests { } @Test - public void noMatch() { + void noMatch() { RequestMethodsRequestCondition rm = new RequestMethodsRequestCondition(RequestMethod.POST); RequestConditionHolder custom = new RequestConditionHolder(rm); @@ -82,13 +82,13 @@ public class RequestConditionHolderTests { } @Test - public void matchEmpty() { + void matchEmpty() { RequestConditionHolder empty = new RequestConditionHolder(null); assertThat(empty.getMatchingCondition(this.exchange)).isSameAs(empty); } @Test - public void compare() { + void compare() { RequestConditionHolder params11 = new RequestConditionHolder(new ParamsRequestCondition("1")); RequestConditionHolder params12 = new RequestConditionHolder(new ParamsRequestCondition("1", "2")); @@ -97,7 +97,7 @@ public class RequestConditionHolderTests { } @Test - public void compareEmpty() { + void compareEmpty() { RequestConditionHolder empty = new RequestConditionHolder(null); RequestConditionHolder empty2 = new RequestConditionHolder(null); RequestConditionHolder notEmpty = new RequestConditionHolder(new ParamsRequestCondition("name")); @@ -108,7 +108,7 @@ public class RequestConditionHolderTests { } @Test - public void compareIncompatible() { + void compareIncompatible() { RequestConditionHolder params = new RequestConditionHolder(new ParamsRequestCondition("name")); RequestConditionHolder headers = new RequestConditionHolder(new HeadersRequestCondition("name")); assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java index 1453e8ffae..2936e9d7a9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java @@ -46,12 +46,12 @@ import static org.springframework.web.reactive.result.method.RequestMappingInfo. * * @author Rossen Stoyanchev */ -public class RequestMappingInfoTests { +class RequestMappingInfoTests { // TODO: CORS pre-flight (see @Disabled) @Test - public void createEmpty() { + void createEmpty() { RequestMappingInfo info = paths().build(); PathPattern emptyPattern = (new PathPatternParser()).parse(""); @@ -83,14 +83,14 @@ public class RequestMappingInfoTests { } @Test - public void throwWhenInvalidPattern() { + void throwWhenInvalidPattern() { assertThatExceptionOfType(PatternParseException.class).isThrownBy(() -> paths("/{foo").build()) .withMessageContaining("Expected close capture character after variable name }"); } @Test - public void prependPatternWithSlash() { + void prependPatternWithSlash() { RequestMappingInfo actual = paths("foo").build(); List patterns = new ArrayList<>(actual.getPatternsCondition().getPatterns()); assertThat(patterns).hasSize(1); @@ -98,7 +98,7 @@ public class RequestMappingInfoTests { } @Test - public void matchPatternsCondition() { + void matchPatternsCondition() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo")); RequestMappingInfo info = paths("/foo*", "/bar").build(); @@ -113,7 +113,7 @@ public class RequestMappingInfoTests { } @Test - public void matchParamsCondition() { + void matchParamsCondition() { ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo?foo=bar")); RequestMappingInfo info = paths("/foo").params("foo=bar").build(); @@ -128,7 +128,7 @@ public class RequestMappingInfoTests { } @Test - public void matchHeadersCondition() { + void matchHeadersCondition() { MockServerHttpRequest request = MockServerHttpRequest.get("/foo").header("foo", "bar").build(); ServerWebExchange exchange = MockServerWebExchange.from(request); @@ -144,7 +144,7 @@ public class RequestMappingInfoTests { } @Test - public void matchConsumesCondition() { + void matchConsumesCondition() { MockServerHttpRequest request = MockServerHttpRequest.post("/foo").contentType(MediaType.TEXT_PLAIN).build(); ServerWebExchange exchange = MockServerWebExchange.from(request); @@ -160,7 +160,7 @@ public class RequestMappingInfoTests { } @Test - public void matchProducesCondition() { + void matchProducesCondition() { MockServerHttpRequest request = MockServerHttpRequest.get("/foo").accept(MediaType.TEXT_PLAIN).build(); ServerWebExchange exchange = MockServerWebExchange.from(request); @@ -176,7 +176,7 @@ public class RequestMappingInfoTests { } @Test - public void matchCustomCondition() { + void matchCustomCondition() { ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo?foo=bar")); RequestMappingInfo info = paths("/foo").params("foo=bar").build(); @@ -193,7 +193,7 @@ public class RequestMappingInfoTests { } @Test - public void compareTwoHttpMethodsOneParam() { + void compareTwoHttpMethodsOneParam() { RequestMappingInfo none = paths().build(); RequestMappingInfo oneMethod = paths().methods(RequestMethod.GET).build(); RequestMappingInfo oneMethodOneParam = paths().methods(RequestMethod.GET).params("foo").build(); @@ -205,13 +205,11 @@ public class RequestMappingInfoTests { Collections.shuffle(list); list.sort(comparator); - assertThat(list).element(0).isEqualTo(oneMethodOneParam); - assertThat(list).element(1).isEqualTo(oneMethod); - assertThat(list).element(2).isEqualTo(none); + assertThat(list).containsExactly(oneMethodOneParam, oneMethod, none); } @Test - public void equals() { + void equals() { RequestMappingInfo info1 = paths("/foo").methods(RequestMethod.GET) .params("foo=bar").headers("foo=bar") .consumes("text/plain").produces("text/plain") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java index bbcd8d1353..e7f2daf2f5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java @@ -16,7 +16,6 @@ package org.springframework.web.reactive.result.condition; -import java.net.URISyntaxException; import java.util.Collections; import org.junit.jupiter.api.Test; @@ -41,24 +40,24 @@ import static org.springframework.web.bind.annotation.RequestMethod.PUT; * * @author Rossen Stoyanchev */ -public class RequestMethodsRequestConditionTests { +class RequestMethodsRequestConditionTests { @Test - public void getMatchingCondition() throws Exception { + void getMatchingCondition() { testMatch(new RequestMethodsRequestCondition(GET), GET); testMatch(new RequestMethodsRequestCondition(GET, POST), GET); testNoMatch(new RequestMethodsRequestCondition(GET), POST); } @Test - public void getMatchingConditionWithHttpHead() throws Exception { + void getMatchingConditionWithHttpHead() { testMatch(new RequestMethodsRequestCondition(HEAD), HEAD); testMatch(new RequestMethodsRequestCondition(GET), GET); testNoMatch(new RequestMethodsRequestCondition(POST), HEAD); } @Test - public void getMatchingConditionWithEmptyConditions() throws Exception { + void getMatchingConditionWithEmptyConditions() { RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition(); for (RequestMethod method : RequestMethod.values()) { if (method != OPTIONS) { @@ -70,14 +69,14 @@ public class RequestMethodsRequestConditionTests { } @Test - public void getMatchingConditionWithCustomMethod() throws Exception { + void getMatchingConditionWithCustomMethod() { ServerWebExchange exchange = getExchange("PROPFIND"); assertThat(new RequestMethodsRequestCondition().getMatchingCondition(exchange)).isNotNull(); assertThat(new RequestMethodsRequestCondition(GET, POST).getMatchingCondition(exchange)).isNull(); } @Test - public void getMatchingConditionWithCorsPreFlight() { + void getMatchingConditionWithCorsPreFlight() { MockServerHttpRequest request = MockServerHttpRequest.method(HttpMethod.valueOf("OPTIONS"), "/") .header("Origin", "https://example.com") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PUT") @@ -90,7 +89,7 @@ public class RequestMethodsRequestConditionTests { } @Test - public void compareTo() throws Exception { + void compareTo() { RequestMethodsRequestCondition c1 = new RequestMethodsRequestCondition(GET, HEAD); RequestMethodsRequestCondition c2 = new RequestMethodsRequestCondition(POST); RequestMethodsRequestCondition c3 = new RequestMethodsRequestCondition(); @@ -111,7 +110,7 @@ public class RequestMethodsRequestConditionTests { } @Test - public void combine() { + void combine() { RequestMethodsRequestCondition condition1 = new RequestMethodsRequestCondition(GET); RequestMethodsRequestCondition condition2 = new RequestMethodsRequestCondition(POST); @@ -120,19 +119,19 @@ public class RequestMethodsRequestConditionTests { } - private void testMatch(RequestMethodsRequestCondition condition, RequestMethod method) throws Exception { + private void testMatch(RequestMethodsRequestCondition condition, RequestMethod method) { ServerWebExchange exchange = getExchange(method.name()); RequestMethodsRequestCondition actual = condition.getMatchingCondition(exchange); assertThat(actual).isNotNull(); assertThat(actual.getContent()).isEqualTo(Collections.singleton(method)); } - private void testNoMatch(RequestMethodsRequestCondition condition, RequestMethod method) throws Exception { + private void testNoMatch(RequestMethodsRequestCondition condition, RequestMethod method) { ServerWebExchange exchange = getExchange(method.name()); assertThat(condition.getMatchingCondition(exchange)).isNull(); } - private ServerWebExchange getExchange(String method) throws URISyntaxException { + private ServerWebExchange getExchange(String method) { return MockServerWebExchange.from(MockServerHttpRequest.method(HttpMethod.valueOf(method), "/")); } 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 f01227e35c..427787cd9b 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 @@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Rossen Stoyanchev * @author Sam Brannen */ -public class HandlerMethodMappingTests { +class HandlerMethodMappingTests { private MyHandlerMethodMapping mapping; @@ -66,7 +66,7 @@ public class HandlerMethodMappingTests { @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { this.mapping = new MyHandlerMethodMapping(); this.handler = new MyHandler(); this.method1 = handler.getClass().getMethod("handlerMethod1"); @@ -75,14 +75,14 @@ public class HandlerMethodMappingTests { @Test - public void registerDuplicates() { + void registerDuplicates() { this.mapping.registerMapping("foo", this.handler, this.method1); assertThatIllegalStateException().isThrownBy(() -> this.mapping.registerMapping("foo", this.handler, this.method2)); } @Test - public void directMatch() { + void directMatch() { this.mapping.registerMapping("/foo", this.handler, this.method1); this.mapping.registerMapping("/fo*", this.handler, this.method2); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo")); @@ -93,7 +93,7 @@ public class HandlerMethodMappingTests { } @Test - public void patternMatch() { + void patternMatch() { this.mapping.registerMapping("/fo*", this.handler, this.method1); this.mapping.registerMapping("/f*", this.handler, this.method2); @@ -103,7 +103,7 @@ public class HandlerMethodMappingTests { } @Test - public void ambiguousMatch() { + void ambiguousMatch() { this.mapping.registerMapping("/f?o", this.handler, this.method1); this.mapping.registerMapping("/fo?", this.handler, this.method2); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo")); @@ -113,7 +113,7 @@ public class HandlerMethodMappingTests { } @Test // gh-26490 - public void ambiguousMatchOnPreFlightRequestWithoutCorsConfig() throws Exception { + public void ambiguousMatchOnPreFlightRequestWithoutCorsConfig() { this.mapping.registerMapping("/f?o", this.handler, this.method1); this.mapping.registerMapping("/fo?", this.handler, this.method2); @@ -146,7 +146,7 @@ public class HandlerMethodMappingTests { } @Test - public void registerMapping() { + void registerMapping() { String key1 = "/foo"; String key2 = "/foo*"; this.mapping.registerMapping(key1, this.handler, this.method1); @@ -156,7 +156,7 @@ public class HandlerMethodMappingTests { } @Test - public void registerMappingWithSameMethodAndTwoHandlerInstances() { + void registerMappingWithSameMethodAndTwoHandlerInstances() { String key1 = "foo"; String key2 = "bar"; MyHandler handler1 = new MyHandler(); @@ -168,7 +168,7 @@ public class HandlerMethodMappingTests { } @Test - public void unregisterMapping() { + void unregisterMapping() { String key = "foo"; this.mapping.registerMapping(key, this.handler, this.method1); Mono result = this.mapping.getHandler(MockServerWebExchange.from(MockServerHttpRequest.get(key))); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java index 83b275a349..239f22da48 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java @@ -56,7 +56,7 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * @author Rossen Stoyanchev * @author Juergen Hoeller */ -public class InvocableHandlerMethodTests { +class InvocableHandlerMethodTests { private static final Duration TIMEOUT = Duration.ofSeconds(5); @@ -67,7 +67,7 @@ public class InvocableHandlerMethodTests { @Test - public void resolveArg() { + void resolveArg() { this.resolvers.add(stubResolver("value1")); Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method(); Mono mono = invoke(new TestController(), method); @@ -76,7 +76,7 @@ public class InvocableHandlerMethodTests { } @Test - public void resolveNoArgValue() { + void resolveNoArgValue() { this.resolvers.add(stubResolver(Mono.empty())); Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method(); Mono mono = invoke(new TestController(), method); @@ -85,14 +85,14 @@ public class InvocableHandlerMethodTests { } @Test - public void resolveNoArgs() { + void resolveNoArgs() { Method method = ResolvableMethod.on(TestController.class).mockCall(TestController::noArgs).method(); Mono mono = invoke(new TestController(), method); assertHandlerResultValue(mono, "success"); } @Test - public void cannotResolveArg() { + void cannotResolveArg() { Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method(); Mono mono = invoke(new TestController(), method); assertThatIllegalStateException().isThrownBy( @@ -101,7 +101,7 @@ public class InvocableHandlerMethodTests { } @Test - public void resolveProvidedArg() { + void resolveProvidedArg() { Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method(); Mono mono = invoke(new TestController(), method, "value1"); @@ -109,7 +109,7 @@ public class InvocableHandlerMethodTests { } @Test - public void resolveProvidedArgFirst() { + void resolveProvidedArgFirst() { this.resolvers.add(stubResolver("value1")); Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method(); Mono mono = invoke(new TestController(), method, "value2"); @@ -118,7 +118,7 @@ public class InvocableHandlerMethodTests { } @Test - public void exceptionInResolvingArg() { + void exceptionInResolvingArg() { this.resolvers.add(stubResolver(Mono.error(new UnsupportedMediaTypeStatusException("boo")))); Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method(); Mono mono = invoke(new TestController(), method); @@ -129,7 +129,7 @@ public class InvocableHandlerMethodTests { } @Test - public void illegalArgumentException() { + void illegalArgumentException() { this.resolvers.add(stubResolver(1)); Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method(); Mono mono = invoke(new TestController(), method); @@ -143,7 +143,7 @@ public class InvocableHandlerMethodTests { } @Test - public void invocationTargetException() { + void invocationTargetException() { Method method = ResolvableMethod.on(TestController.class).mockCall(TestController::exceptionMethod).method(); Mono mono = invoke(new TestController(), method); @@ -153,7 +153,7 @@ public class InvocableHandlerMethodTests { } @Test - public void responseStatusAnnotation() { + void responseStatusAnnotation() { Method method = ResolvableMethod.on(TestController.class).mockCall(TestController::created).method(); Mono mono = invoke(new TestController(), method); @@ -162,7 +162,7 @@ public class InvocableHandlerMethodTests { } @Test - public void voidMethodWithResponseArg() { + void voidMethodWithResponseArg() { ServerHttpResponse response = this.exchange.getResponse(); this.resolvers.add(stubResolver(response)); Method method = ResolvableMethod.on(TestController.class).mockCall(c -> c.response(response)).method(); @@ -173,7 +173,7 @@ public class InvocableHandlerMethodTests { } @Test - public void voidMonoMethodWithResponseArg() { + void voidMonoMethodWithResponseArg() { ServerHttpResponse response = this.exchange.getResponse(); this.resolvers.add(stubResolver(response)); Method method = ResolvableMethod.on(TestController.class).mockCall(c -> c.responseMonoVoid(response)).method(); @@ -184,7 +184,7 @@ public class InvocableHandlerMethodTests { } @Test - public void voidMethodWithExchangeArg() { + void voidMethodWithExchangeArg() { this.resolvers.add(stubResolver(this.exchange)); Method method = ResolvableMethod.on(TestController.class).mockCall(c -> c.exchange(exchange)).method(); HandlerResult result = invokeForResult(new TestController(), method); @@ -194,7 +194,7 @@ public class InvocableHandlerMethodTests { } @Test - public void voidMonoMethodWithExchangeArg() { + void voidMonoMethodWithExchangeArg() { this.resolvers.add(stubResolver(this.exchange)); Method method = ResolvableMethod.on(TestController.class).mockCall(c -> c.exchangeMonoVoid(exchange)).method(); HandlerResult result = invokeForResult(new TestController(), method); @@ -204,7 +204,7 @@ public class InvocableHandlerMethodTests { } @Test - public void checkNotModified() { + void checkNotModified() { MockServerHttpRequest request = MockServerHttpRequest.get("/").ifModifiedSince(10 * 1000 * 1000).build(); ServerWebExchange exchange = MockServerWebExchange.from(request); this.resolvers.add(stubResolver(exchange)); @@ -226,11 +226,11 @@ public class InvocableHandlerMethodTests { return invocable.invoke(this.exchange, new BindingContext(), providedArgs); } - private HandlerMethodArgumentResolver stubResolver(Object stubValue) { + private HandlerMethodArgumentResolver stubResolver(Object stubValue) { return stubResolver(Mono.just(stubValue)); } - private HandlerMethodArgumentResolver stubResolver(Mono stubValue) { + private HandlerMethodArgumentResolver stubResolver(Mono stubValue) { HandlerMethodArgumentResolver resolver = mock(); given(resolver.supportsParameter(any())).willReturn(true); given(resolver.resolveArgument(any(), any(), any())).willReturn(stubValue); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java index 850b812ffb..16970ecf66 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java @@ -82,7 +82,7 @@ import static org.springframework.web.testfixture.method.ResolvableMethod.on; * @author Rossen Stoyanchev * @author Sam Brannen */ -public class RequestMappingInfoHandlerMappingTests { +class RequestMappingInfoHandlerMappingTests { private static final HandlerMethod handlerMethod = new HandlerMethod(new TestController(), ClassUtils.getMethod(TestController.class, "dummy")); @@ -91,14 +91,14 @@ public class RequestMappingInfoHandlerMappingTests { @BeforeEach - public void setup() { + void setup() { this.handlerMapping = new TestRequestMappingInfoHandlerMapping(); this.handlerMapping.registerHandler(new TestController()); } @Test - public void getHandlerDirectMatch() { + void getHandlerDirectMatch() { Method expected = on(TestController.class).annot(getMapping("/foo").params()).resolveMethod(); ServerWebExchange exchange = MockServerWebExchange.from(get("/foo")); HandlerMethod hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block(); @@ -107,7 +107,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void getHandlerGlobMatch() { + void getHandlerGlobMatch() { Method expected = on(TestController.class).annot(requestMapping("/ba*").method(GET, HEAD)).resolveMethod(); ServerWebExchange exchange = MockServerWebExchange.from(get("/bar")); HandlerMethod hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block(); @@ -116,7 +116,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void getHandlerEmptyPathMatch() { + void getHandlerEmptyPathMatch() { Method expected = on(TestController.class).annot(requestMapping("")).resolveMethod(); ServerWebExchange exchange = MockServerWebExchange.from(get("")); HandlerMethod hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block(); @@ -124,7 +124,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void getHandlerBestMatch() { + void getHandlerBestMatch() { Method expected = on(TestController.class).annot(getMapping("/foo").params("p")).resolveMethod(); ServerWebExchange exchange = MockServerWebExchange.from(get("/foo?p=anything")); HandlerMethod hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block(); @@ -133,7 +133,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void getHandlerRequestMethodNotAllowed() { + void getHandlerRequestMethodNotAllowed() { ServerWebExchange exchange = MockServerWebExchange.from(post("/bar")); Mono mono = this.handlerMapping.getHandler(exchange); @@ -159,7 +159,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void getHandlerTestInvalidContentType() { + void getHandlerTestInvalidContentType() { MockServerHttpRequest request = put("/person/1").header("content-type", "bogus").build(); ServerWebExchange exchange = MockServerWebExchange.from(request); Mono mono = this.handlerMapping.getHandler(exchange); @@ -185,7 +185,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void getHandlerHttpOptions() { + void getHandlerHttpOptions() { List allMethodExceptTrace = new ArrayList<>(Arrays.asList(HttpMethod.values())); allMethodExceptTrace.remove(HttpMethod.TRACE); @@ -198,7 +198,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void getHandlerProducibleMediaTypesAttribute() { + void getHandlerProducibleMediaTypesAttribute() { ServerWebExchange exchange = MockServerWebExchange.from(get("/content").accept(MediaType.APPLICATION_XML)); this.handlerMapping.getHandler(exchange).block(); @@ -247,7 +247,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void handleMatchBestMatchingPatternAttribute() { + void handleMatchBestMatchingPatternAttribute() { RequestMappingInfo key = paths("/{path1}/2", "/**").build(); ServerWebExchange exchange = MockServerWebExchange.from(get("/1/2")); this.handlerMapping.handleMatch(key, handlerMethod, exchange); @@ -260,7 +260,6 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - @SuppressWarnings("removal") public void handleMatchBestMatchingPatternAttributeInObservationContext() { RequestMappingInfo key = paths("/{path1}/2", "/**").build(); ServerWebExchange exchange = MockServerWebExchange.from(get("/1/2")); @@ -280,7 +279,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void handleMatchMatrixVariables() { + void handleMatchMatrixVariables() { MultiValueMap matrixVariables; Map uriVariables; @@ -313,7 +312,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void handleMatchMatrixVariablesDecoding() { + void handleMatchMatrixVariablesDecoding() { MockServerHttpRequest request = method(HttpMethod.GET, URI.create("/cars;mvar=a%2Fb")).build(); ServerWebExchange exchange = MockServerWebExchange.from(request); handleMatch(exchange, "/{cars}"); @@ -327,7 +326,7 @@ public class RequestMappingInfoHandlerMappingTests { } @Test - public void handlePatchUnsupportedMediaType() { + void handlePatchUnsupportedMediaType() { MockServerHttpRequest request = MockServerHttpRequest.patch("/qux") .header("content-type", "application/xml") .build(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java index 80e301cb01..293cbdeec5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -55,7 +55,6 @@ class ContextPathIntegrationTests { server.start(); try { - @SuppressWarnings("resource") RestTemplate restTemplate = new RestTemplate(); String actual; @@ -88,7 +87,6 @@ class ContextPathIntegrationTests { try { String url = "http://localhost:" + server.getPort() + "/app/api/test"; - @SuppressWarnings("resource") String actual = new RestTemplate().getForObject(url, String.class); assertThat(actual).isEqualTo("Tested in /app/api"); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java index cf18b20d5d..fc95d3ebe3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -53,19 +53,19 @@ import static org.mockito.Mockito.mock; * * @author Rossen Stoyanchev */ -public class ControllerAdviceTests { +class ControllerAdviceTests { private final MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); @Test - public void resolveExceptionGlobalHandler() throws Exception { + void resolveExceptionGlobalHandler() throws Exception { testException(new IllegalAccessException(), "SecondControllerAdvice: IllegalAccessException"); } @Test - public void resolveExceptionGlobalHandlerOrdered() throws Exception { + void resolveExceptionGlobalHandlerOrdered() throws Exception { testException(new IllegalStateException(), "OneControllerAdvice: IllegalStateException"); } @@ -75,13 +75,13 @@ public class ControllerAdviceTests { } @Test - public void resolveExceptionWithAssertionError() throws Exception { + void resolveExceptionWithAssertionError() throws Exception { AssertionError error = new AssertionError("argh"); testException(error, error.toString()); } @Test - public void resolveExceptionWithAssertionErrorAsRootCause() throws Exception { + void resolveExceptionWithAssertionErrorAsRootCause() throws Exception { AssertionError rootCause = new AssertionError("argh"); FatalBeanException cause = new FatalBeanException("wrapped", rootCause); Exception exception = new Exception(cause); @@ -100,7 +100,7 @@ public class ControllerAdviceTests { } @Test - public void modelAttributeAdvice() throws Exception { + void modelAttributeAdvice() throws Exception { ApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class); RequestMappingHandlerAdapter adapter = createAdapter(context); TestController controller = context.getBean(TestController.class); @@ -113,7 +113,7 @@ public class ControllerAdviceTests { } @Test - public void initBinderAdvice() throws Exception { + void initBinderAdvice() throws Exception { ApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class); RequestMappingHandlerAdapter adapter = createAdapter(context); TestController controller = context.getBean(TestController.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java index 9e73bc5cd5..f76d0a09b9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java @@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class ControllerMethodResolverTests { +class ControllerMethodResolverTests { private ControllerMethodResolver methodResolver; @@ -62,7 +62,7 @@ public class ControllerMethodResolverTests { @BeforeEach - public void setup() { + void setup() { ArgumentResolverConfigurer resolvers = new ArgumentResolverConfigurer(); resolvers.addCustomResolver(new CustomArgumentResolver()); resolvers.addCustomResolver(new CustomSyncArgumentResolver()); @@ -85,7 +85,7 @@ public class ControllerMethodResolverTests { @Test - public void requestMappingArgumentResolvers() { + void requestMappingArgumentResolvers() { InvocableHandlerMethod invocable = this.methodResolver.getRequestMappingMethod(this.handlerMethod); List resolvers = invocable.getResolvers(); @@ -123,7 +123,7 @@ public class ControllerMethodResolverTests { } @Test - public void modelAttributeArgumentResolvers() { + void modelAttributeArgumentResolvers() { List methods = this.methodResolver.getModelAttributeMethods(this.handlerMethod); assertThat(methods).as("Expected one each from Controller + ControllerAdvice").hasSize(2); @@ -160,7 +160,7 @@ public class ControllerMethodResolverTests { } @Test - public void initBinderArgumentResolvers() { + void initBinderArgumentResolvers() { List methods = this.methodResolver.getInitBinderMethods(this.handlerMethod); @@ -190,7 +190,7 @@ public class ControllerMethodResolverTests { } @Test - public void exceptionHandlerArgumentResolvers() { + void exceptionHandlerArgumentResolvers() { InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod( new ResponseStatusException(HttpStatus.BAD_REQUEST, "reason"), this.handlerMethod); @@ -225,7 +225,7 @@ public class ControllerMethodResolverTests { } @Test - public void exceptionHandlerFromControllerAdvice() { + void exceptionHandlerFromControllerAdvice() { InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod( new IllegalStateException("reason"), this.handlerMethod); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java index a0c4f5cdc3..bab8864ce9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Rossen Stoyanchev */ -public class CookieValueMethodArgumentResolverTests { +class CookieValueMethodArgumentResolverTests { private CookieValueMethodArgumentResolver resolver; @@ -56,8 +56,7 @@ public class CookieValueMethodArgumentResolverTests { @BeforeEach - @SuppressWarnings("resource") - public void setup() throws Exception { + void setup() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.refresh(); @@ -74,13 +73,13 @@ public class CookieValueMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.cookieParameter)).isTrue(); assertThat(this.resolver.supportsParameter(this.cookieStringParameter)).isTrue(); } @Test - public void doesNotSupportParameter() { + void doesNotSupportParameter() { assertThat(this.resolver.supportsParameter(this.stringParameter)).isFalse(); assertThatIllegalStateException().isThrownBy(() -> this.resolver.supportsParameter(this.cookieMonoParameter)) @@ -88,7 +87,7 @@ public class CookieValueMethodArgumentResolverTests { } @Test - public void resolveCookieArgument() { + void resolveCookieArgument() { HttpCookie expected = new HttpCookie("name", "foo"); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/").cookie(expected)); @@ -99,7 +98,7 @@ public class CookieValueMethodArgumentResolverTests { } @Test - public void resolveCookieStringArgument() { + void resolveCookieStringArgument() { HttpCookie cookie = new HttpCookie("name", "foo"); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/").cookie(cookie)); @@ -110,7 +109,7 @@ public class CookieValueMethodArgumentResolverTests { } @Test - public void resolveCookieDefaultValue() { + void resolveCookieDefaultValue() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); Object result = this.resolver.resolveArgument(this.cookieStringParameter, this.bindingContext, exchange).block(); @@ -120,7 +119,7 @@ public class CookieValueMethodArgumentResolverTests { } @Test - public void notFound() { + void notFound() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); Mono mono = resolver.resolveArgument(this.cookieParameter, this.bindingContext, exchange); StepVerifier.create(mono) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java index f761b4c489..7ff1e3c672 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Rossen Stoyanchev */ -public class ExpressionValueMethodArgumentResolverTests { +class ExpressionValueMethodArgumentResolverTests { private ExpressionValueMethodArgumentResolver resolver; @@ -51,8 +51,7 @@ public class ExpressionValueMethodArgumentResolverTests { @BeforeEach - @SuppressWarnings("resource") - public void setup() throws Exception { + void setup() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.refresh(); ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); @@ -66,12 +65,12 @@ public class ExpressionValueMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.paramSystemProperty)).isTrue(); } @Test - public void doesNotSupport() { + void doesNotSupport() { assertThat(this.resolver.supportsParameter(this.paramNotSupported)).isFalse(); assertThatIllegalStateException().isThrownBy(() -> this.resolver.supportsParameter(this.paramAlsoNotSupported)) @@ -79,7 +78,7 @@ public class ExpressionValueMethodArgumentResolverTests { } @Test - public void resolveSystemProperty() { + void resolveSystemProperty() { System.setProperty("systemProperty", "22"); try { Mono mono = this.resolver.resolveArgument( diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java index 07c0563430..96c7177391 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java @@ -60,7 +60,7 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * @author Rossen Stoyanchev * @author Sebastien Deleuze */ -public class HttpEntityMethodArgumentResolverTests { +class HttpEntityMethodArgumentResolverTests { private final HttpEntityMethodArgumentResolver resolver = createResolver(); @@ -75,7 +75,7 @@ public class HttpEntityMethodArgumentResolverTests { @Test - public void supports() throws Exception { + void supports() { testSupports(this.testMethod.arg(httpEntityType(String.class))); testSupports(this.testMethod.arg(httpEntityType(Mono.class, String.class))); testSupports(this.testMethod.arg(httpEntityType(Single.class, String.class))); @@ -92,7 +92,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void doesNotSupport() { + void doesNotSupport() { assertThat(this.resolver.supportsParameter(this.testMethod.arg(Mono.class, String.class))).isFalse(); assertThat(this.resolver.supportsParameter(this.testMethod.arg(String.class))).isFalse(); assertThatIllegalStateException().isThrownBy(() -> @@ -101,7 +101,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void emptyBodyWithString() { + void emptyBodyWithString() { ResolvableType type = httpEntityType(String.class); HttpEntity entity = resolveValueWithEmptyBody(type); @@ -109,7 +109,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void emptyBodyWithMono() { + void emptyBodyWithMono() { ResolvableType type = httpEntityType(Mono.class, String.class); HttpEntity> entity = resolveValueWithEmptyBody(type); @@ -117,7 +117,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void emptyBodyWithFlux() { + void emptyBodyWithFlux() { ResolvableType type = httpEntityType(Flux.class, String.class); HttpEntity> entity = resolveValueWithEmptyBody(type); @@ -125,7 +125,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void emptyBodyWithSingle() { + void emptyBodyWithSingle() { ResolvableType type = httpEntityType(Single.class, String.class); HttpEntity> entity = resolveValueWithEmptyBody(type); @@ -136,7 +136,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void emptyBodyWithMaybe() { + void emptyBodyWithMaybe() { ResolvableType type = httpEntityType(Maybe.class, String.class); HttpEntity> entity = resolveValueWithEmptyBody(type); @@ -147,7 +147,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void emptyBodyWithObservable() { + void emptyBodyWithObservable() { ResolvableType type = httpEntityType(Observable.class, String.class); HttpEntity> entity = resolveValueWithEmptyBody(type); @@ -158,7 +158,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void emptyBodyWithFlowable() { + void emptyBodyWithFlowable() { ResolvableType type = httpEntityType(Flowable.class, String.class); HttpEntity> entity = resolveValueWithEmptyBody(type); @@ -169,7 +169,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void emptyBodyWithCompletableFuture() { + void emptyBodyWithCompletableFuture() { ResolvableType type = httpEntityType(CompletableFuture.class, String.class); HttpEntity> entity = resolveValueWithEmptyBody(type); @@ -180,7 +180,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void httpEntityWithStringBody() { + void httpEntityWithStringBody() { ServerWebExchange exchange = postExchange("line1"); ResolvableType type = httpEntityType(String.class); HttpEntity httpEntity = resolveValue(exchange, type); @@ -190,7 +190,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void httpEntityWithMonoBody() { + void httpEntityWithMonoBody() { ServerWebExchange exchange = postExchange("line1"); ResolvableType type = httpEntityType(Mono.class, String.class); HttpEntity> httpEntity = resolveValue(exchange, type); @@ -200,7 +200,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void httpEntityWithSingleBody() { + void httpEntityWithSingleBody() { ServerWebExchange exchange = postExchange("line1"); ResolvableType type = httpEntityType(Single.class, String.class); HttpEntity> httpEntity = resolveValue(exchange, type); @@ -210,7 +210,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void httpEntityWithMaybeBody() { + void httpEntityWithMaybeBody() { ServerWebExchange exchange = postExchange("line1"); ResolvableType type = httpEntityType(Maybe.class, String.class); HttpEntity> httpEntity = resolveValue(exchange, type); @@ -220,7 +220,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void httpEntityWithCompletableFutureBody() throws Exception { + void httpEntityWithCompletableFutureBody() throws Exception { ServerWebExchange exchange = postExchange("line1"); ResolvableType type = httpEntityType(CompletableFuture.class, String.class); HttpEntity> httpEntity = resolveValue(exchange, type); @@ -230,7 +230,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void httpEntityWithFluxBody() { + void httpEntityWithFluxBody() { ServerWebExchange exchange = postExchange("line1\nline2\nline3\n"); ResolvableType type = httpEntityType(Flux.class, String.class); HttpEntity> httpEntity = resolveValue(exchange, type); @@ -245,7 +245,7 @@ public class HttpEntityMethodArgumentResolverTests { } @Test - public void requestEntity() { + void requestEntity() { ServerWebExchange exchange = postExchange("line1"); ResolvableType type = forClassWithGenerics(RequestEntity.class, String.class); RequestEntity requestEntity = resolveValue(exchange, type); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java index c096119af9..52557547f0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java @@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Rossen Stoyanchev */ -public class InitBinderBindingContextTests { +class InitBinderBindingContextTests { private final ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer(); @@ -53,7 +53,7 @@ public class InitBinderBindingContextTests { @Test - public void createBinder() throws Exception { + void createBinder() throws Exception { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); BindingContext context = createBindingContext("initBinder", WebDataBinder.class); WebDataBinder dataBinder = context.createDataBinder(exchange, null); @@ -63,7 +63,7 @@ public class InitBinderBindingContextTests { } @Test - public void createBinderWithGlobalInitialization() throws Exception { + void createBinderWithGlobalInitialization() throws Exception { ConversionService conversionService = new DefaultFormattingConversionService(); bindingInitializer.setConversionService(conversionService); @@ -75,7 +75,7 @@ public class InitBinderBindingContextTests { } @Test - public void createBinderWithAttrName() throws Exception { + void createBinderWithAttrName() throws Exception { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); BindingContext context = createBindingContext("initBinderWithAttributeName", WebDataBinder.class); WebDataBinder dataBinder = context.createDataBinder(exchange, "foo"); @@ -85,7 +85,7 @@ public class InitBinderBindingContextTests { } @Test - public void createBinderWithAttrNameNoMatch() throws Exception { + void createBinderWithAttrNameNoMatch() throws Exception { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); BindingContext context = createBindingContext("initBinderWithAttributeName", WebDataBinder.class); WebDataBinder dataBinder = context.createDataBinder(exchange, "invalidName"); @@ -94,7 +94,7 @@ public class InitBinderBindingContextTests { } @Test - public void createBinderNullAttrName() throws Exception { + void createBinderNullAttrName() throws Exception { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); BindingContext context = createBindingContext("initBinderWithAttributeName", WebDataBinder.class); WebDataBinder dataBinder = context.createDataBinder(exchange, null); @@ -103,14 +103,14 @@ public class InitBinderBindingContextTests { } @Test - public void returnValueNotExpected() throws Exception { + void returnValueNotExpected() throws Exception { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); BindingContext context = createBindingContext("initBinderReturnValue", WebDataBinder.class); assertThatIllegalStateException().isThrownBy(() -> context.createDataBinder(exchange, "invalidName")); } @Test - public void createBinderTypeConversion() throws Exception { + void createBinderTypeConversion() throws Exception { MockServerHttpRequest request = MockServerHttpRequest.get("/path?requestParam=22").build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java index 2112a7f50b..1e622521c2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java @@ -45,7 +45,7 @@ import static org.springframework.web.testfixture.method.MvcAnnotationPredicates * * @author Rossen Stoyanchev */ -public class MatrixVariablesMapMethodArgumentResolverTests { +class MatrixVariablesMapMethodArgumentResolverTests { private final MatrixVariableMapMethodArgumentResolver resolver = new MatrixVariableMapMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); @@ -56,13 +56,13 @@ public class MatrixVariablesMapMethodArgumentResolverTests { @BeforeEach - public void setUp() throws Exception { + void setUp() { this.exchange.getAttributes().put(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, new LinkedHashMap<>()); } @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.testMethod.arg(String.class))).isFalse(); @@ -80,7 +80,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { } @Test - public void resolveArgument() throws Exception { + void resolveArgument() throws Exception { MultiValueMap params = getMatrixVariables("cars"); params.add("colors", "red"); params.add("colors", "green"); @@ -111,7 +111,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { } @Test - public void resolveArgumentPathVariable() throws Exception { + void resolveArgumentPathVariable() { MultiValueMap params1 = getMatrixVariables("cars"); params1.add("colors", "red"); params1.add("colors", "purple"); @@ -141,7 +141,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { } @Test - public void resolveMultiValueMapArgumentNoParams() { + void resolveMultiValueMapArgumentNoParams() { MethodParameter param = this.testMethod.annot(matrixAttribute().noPathVar()) .arg(MultiValueMap.class, String.class, String.class); @@ -154,7 +154,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { } @Test - public void resolveArgumentNoParams() throws Exception { + void resolveArgumentNoParams() { MethodParameter param = this.testMethod.annot(matrixAttribute().noName()) .arg(Map.class, String.class, String.class); @@ -167,7 +167,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { } @Test - public void resolveArgumentNoMatch() throws Exception { + void resolveArgumentNoMatch() { MultiValueMap params2 = getMatrixVariables("planes"); params2.add("colors", "yellow"); params2.add("colors", "orange"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java index 0cc69f0265..3e8525ca7c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java @@ -47,7 +47,7 @@ import static org.springframework.web.testfixture.method.MvcAnnotationPredicates * * @author Rossen Stoyanchev */ -public class MatrixVariablesMethodArgumentResolverTests { +class MatrixVariablesMethodArgumentResolverTests { private MatrixVariableMethodArgumentResolver resolver = new MatrixVariableMethodArgumentResolver(null, ReactiveAdapterRegistry.getSharedInstance()); @@ -58,13 +58,13 @@ public class MatrixVariablesMethodArgumentResolverTests { @BeforeEach - public void setUp() throws Exception { + void setUp() { this.exchange.getAttributes().put(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, new LinkedHashMap<>()); } @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.testMethod.arg(String.class))).isFalse(); @@ -76,7 +76,7 @@ public class MatrixVariablesMethodArgumentResolverTests { } @Test - public void resolveArgument() throws Exception { + void resolveArgument() throws Exception { MultiValueMap params = getVariablesFor("cars"); params.add("colors", "red"); params.add("colors", "green"); @@ -87,7 +87,7 @@ public class MatrixVariablesMethodArgumentResolverTests { } @Test - public void resolveArgumentPathVariable() throws Exception { + void resolveArgumentPathVariable() { getVariablesFor("cars").add("year", "2006"); getVariablesFor("bikes").add("year", "2005"); MethodParameter param = this.testMethod.annot(matrixAttribute().name("year")).arg(int.class); @@ -97,14 +97,14 @@ public class MatrixVariablesMethodArgumentResolverTests { } @Test - public void resolveArgumentDefaultValue() throws Exception { + void resolveArgumentDefaultValue() { MethodParameter param = this.testMethod.annot(matrixAttribute().name("year")).arg(int.class); Object actual = this.resolver.resolveArgument(param, new BindingContext(), this.exchange).block(Duration.ZERO); assertThat(actual).isEqualTo(2013); } @Test - public void resolveArgumentMultipleMatches() throws Exception { + void resolveArgumentMultipleMatches() { getVariablesFor("var1").add("colors", "red"); getVariablesFor("var2").add("colors", "green"); @@ -114,14 +114,14 @@ public class MatrixVariablesMethodArgumentResolverTests { } @Test - public void resolveArgumentRequired() throws Exception { + void resolveArgumentRequired() { MethodParameter param = this.testMethod.annot(matrixAttribute().noName()).arg(List.class, String.class); assertThatExceptionOfType(ServerWebInputException.class).isThrownBy(() -> this.resolver.resolveArgument(param, new BindingContext(), this.exchange).block(Duration.ZERO)); } @Test - public void resolveArgumentNoMatch() throws Exception { + void resolveArgumentNoMatch() { MultiValueMap params = getVariablesFor("cars"); params.add("anotherYear", "2012"); MethodParameter param = this.testMethod.annot(matrixAttribute().name("year")).arg(int.class); 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 7db468e2a4..ac6a1d7342 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 @@ -68,7 +68,7 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * * @author Rossen Stoyanchev */ -public class MessageReaderArgumentResolverTests { +class MessageReaderArgumentResolverTests { private AbstractMessageReaderArgumentResolver resolver = resolver(new Jackson2JsonDecoder()); @@ -78,7 +78,7 @@ public class MessageReaderArgumentResolverTests { @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setValidator(new TestBeanValidator()); this.bindingContext = new BindingContext(initializer); @@ -87,7 +87,7 @@ public class MessageReaderArgumentResolverTests { @SuppressWarnings("unchecked") @Test - public void missingContentType() throws Exception { + void missingContentType() { MockServerHttpRequest request = post("/path").body("{\"bar\":\"BARBAR\",\"foo\":\"FOOFOO\"}"); ServerWebExchange exchange = MockServerWebExchange.from(request); ResolvableType type = forClassWithGenerics(Mono.class, TestBean.class); @@ -101,7 +101,7 @@ public class MessageReaderArgumentResolverTests { // More extensive "empty body" tests in RequestBody- and HttpEntityArgumentResolverTests @Test @SuppressWarnings("unchecked") // SPR-9942 - public void emptyBody() throws Exception { + public void emptyBody() { MockServerHttpRequest request = post("/path").contentType(MediaType.APPLICATION_JSON).build(); ServerWebExchange exchange = MockServerWebExchange.from(request); ResolvableType type = forClassWithGenerics(Mono.class, TestBean.class); @@ -113,7 +113,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void monoTestBean() throws Exception { + void monoTestBean() { String body = "{\"bar\":\"BARBAR\",\"foo\":\"FOOFOO\"}"; ResolvableType type = forClassWithGenerics(Mono.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -123,7 +123,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void fluxTestBean() throws Exception { + void fluxTestBean() { String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"; ResolvableType type = forClassWithGenerics(Flux.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -133,7 +133,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void singleTestBean() throws Exception { + void singleTestBean() { String body = "{\"bar\":\"b1\",\"foo\":\"f1\"}"; ResolvableType type = forClassWithGenerics(Single.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -143,7 +143,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void maybeTestBean() throws Exception { + void maybeTestBean() { String body = "{\"bar\":\"b1\",\"foo\":\"f1\"}"; ResolvableType type = forClassWithGenerics(Maybe.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -153,7 +153,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void observableTestBean() throws Exception { + void observableTestBean() { String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"; ResolvableType type = forClassWithGenerics(Observable.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -163,7 +163,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void flowableTestBean() throws Exception { + void flowableTestBean() { String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"; ResolvableType type = forClassWithGenerics(Flowable.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -173,7 +173,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void futureTestBean() throws Exception { + void futureTestBean() throws Exception { String body = "{\"bar\":\"b1\",\"foo\":\"f1\"}"; ResolvableType type = forClassWithGenerics(CompletableFuture.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -183,7 +183,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void testBean() throws Exception { + void testBean() { String body = "{\"bar\":\"b1\",\"foo\":\"f1\"}"; MethodParameter param = this.testMethod.arg(TestBean.class); TestBean value = resolveValue(param, body); @@ -192,7 +192,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void map() throws Exception { + void map() throws Exception { String body = "{\"bar\":\"b1\",\"foo\":\"f1\"}"; Map map = new HashMap<>(); map.put("foo", "f1"); @@ -205,7 +205,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void list() throws Exception { + void list() throws Exception { String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"; ResolvableType type = forClassWithGenerics(List.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -215,7 +215,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void monoList() throws Exception { + void monoList() { String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"; ResolvableType type = forClassWithGenerics(Mono.class, forClassWithGenerics(List.class, TestBean.class)); MethodParameter param = this.testMethod.arg(type); @@ -226,7 +226,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void array() throws Exception { + void array() { String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"; MethodParameter param = this.testMethod.arg(TestBean[].class); TestBean[] value = resolveValue(param, body); @@ -235,7 +235,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void validateMonoTestBean() throws Exception { + void validateMonoTestBean() { String body = "{\"bar\":\"b1\"}"; ResolvableType type = forClassWithGenerics(Mono.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); @@ -245,7 +245,7 @@ public class MessageReaderArgumentResolverTests { } @Test - public void validateFluxTestBean() throws Exception { + void validateFluxTestBean() { String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\"}]"; ResolvableType type = forClassWithGenerics(Flux.class, TestBean.class); MethodParameter param = this.testMethod.arg(type); 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 dacd74a5ef..13dcf1043e 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 @@ -64,7 +64,7 @@ import static org.springframework.web.testfixture.method.ResolvableMethod.on; * @author Rossen Stoyanchev * @author Sebastien Deleuze */ -public class MessageWriterResultHandlerTests { +class MessageWriterResultHandlerTests { private final AbstractMessageWriterResultHandler resultHandler = initResultHandler(); @@ -90,7 +90,7 @@ public class MessageWriterResultHandlerTests { @Test // SPR-12894 - public void useDefaultContentType() throws Exception { + public void useDefaultContentType() { Resource body = new ClassPathResource("logo.png", getClass()); MethodParameter type = on(TestController.class).resolveReturnType(Resource.class); this.resultHandler.writeBody(body, type, this.exchange).block(Duration.ofSeconds(5)); @@ -99,7 +99,7 @@ public class MessageWriterResultHandlerTests { } @Test // SPR-13631 - public void useDefaultCharset() throws Exception { + public void useDefaultCharset() { this.exchange.getAttributes().put(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, Collections.singleton(APPLICATION_JSON)); @@ -111,7 +111,7 @@ public class MessageWriterResultHandlerTests { } @Test - public void voidReturnType() throws Exception { + void voidReturnType() { testVoid(null, on(TestController.class).resolveReturnType(void.class)); testVoid(Mono.empty(), on(TestController.class).resolveReturnType(Mono.class, Void.class)); testVoid(Flux.empty(), on(TestController.class).resolveReturnType(Flux.class, Void.class)); @@ -137,7 +137,7 @@ public class MessageWriterResultHandlerTests { } @Test // SPR-13135 - public void unsupportedReturnType() throws Exception { + public void unsupportedReturnType() { ByteArrayOutputStream body = new ByteArrayOutputStream(); MethodParameter type = on(TestController.class).resolveReturnType(OutputStream.class); @@ -148,7 +148,7 @@ public class MessageWriterResultHandlerTests { } @Test // SPR-12811 - public void jacksonTypeOfListElement() throws Exception { + public void jacksonTypeOfListElement() { MethodParameter returnType = on(TestController.class).resolveReturnType(List.class, ParentClass.class); List body = Arrays.asList(new Foo("foo"), new Bar("bar")); @@ -160,7 +160,7 @@ public class MessageWriterResultHandlerTests { } @Test // SPR-13318 - public void jacksonTypeWithSubType() throws Exception { + public void jacksonTypeWithSubType() { SimpleBean body = new SimpleBean(123L, "foo"); MethodParameter type = on(TestController.class).resolveReturnType(Identifiable.class); this.resultHandler.writeBody(body, type, this.exchange).block(Duration.ofSeconds(5)); @@ -170,7 +170,7 @@ public class MessageWriterResultHandlerTests { } @Test // SPR-13318 - public void jacksonTypeWithSubTypeOfListElement() throws Exception { + public void jacksonTypeWithSubTypeOfListElement() { MethodParameter returnType = on(TestController.class).resolveReturnType(List.class, Identifiable.class); @@ -182,7 +182,7 @@ public class MessageWriterResultHandlerTests { } @Test - public void jacksonTypeWithSubTypeAndObjectReturnValue() { + void jacksonTypeWithSubTypeAndObjectReturnValue() { MethodParameter returnType = on(TestController.class).resolveReturnType(Object.class); SimpleBean body = new SimpleBean(123L, "foo"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MethodValidationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MethodValidationTests.java index 4ed9a43af3..9c8bb19111 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MethodValidationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MethodValidationTests.java @@ -77,7 +77,7 @@ import static org.mockito.Mockito.mock; * * @author Rossen Stoyanchev */ -public class MethodValidationTests { +class MethodValidationTests { private static final Person mockPerson = mock(Person.class); 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 43423fad5d..13be6a3648 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 @@ -341,7 +341,7 @@ class ModelAttributeMethodArgumentResolverTests { } @Test - void validationErrorWithoutBindingForSingle() throws Exception { + void validationErrorWithoutBindingForSingle() { MethodParameter parameter = this.testMethod.annotPresent(ModelAttribute.class).arg(Single.class, ValidatedPojo.class); testValidationErrorWithoutBinding(parameter, resolvedArgumentMono -> { 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 323b2bbd44..3b05422072 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 @@ -61,7 +61,7 @@ import static org.mockito.Mockito.mock; * * @author Rossen Stoyanchev */ -public class ModelInitializerTests { +class ModelInitializerTests { private static final Duration TIMEOUT = Duration.ofMillis(5000); @@ -72,7 +72,7 @@ public class ModelInitializerTests { @BeforeEach - public void setup() { + void setup() { ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); ArgumentResolverConfigurer resolverConfigurer = new ArgumentResolverConfigurer(); @@ -87,7 +87,7 @@ public class ModelInitializerTests { @Test - public void initBinderMethod() { + void initBinderMethod() { Validator validator = mock(); TestController controller = new TestController(); @@ -104,7 +104,7 @@ public class ModelInitializerTests { @SuppressWarnings("unchecked") @Test - public void modelAttributeMethods() { + void modelAttributeMethods() { TestController controller = new TestController(); InitBinderBindingContext context = getBindingContext(controller); @@ -132,7 +132,7 @@ public class ModelInitializerTests { } @Test - public void saveModelAttributeToSession() { + void saveModelAttributeToSession() { TestController controller = new TestController(); InitBinderBindingContext context = getBindingContext(controller); @@ -150,7 +150,7 @@ public class ModelInitializerTests { } @Test - public void retrieveModelAttributeFromSession() { + void retrieveModelAttributeFromSession() { WebSession session = this.exchange.getSession().block(TIMEOUT); assertThat(session).isNotNull(); @@ -170,7 +170,7 @@ public class ModelInitializerTests { } @Test - public void requiredSessionAttributeMissing() { + void requiredSessionAttributeMissing() { TestController controller = new TestController(); InitBinderBindingContext context = getBindingContext(controller); @@ -182,7 +182,7 @@ public class ModelInitializerTests { } @Test - public void clearModelAttributeFromSession() { + void clearModelAttributeFromSession() { WebSession session = this.exchange.getSession().block(TIMEOUT); assertThat(session).isNotNull(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java index 62aa055ff4..1183a1eb5b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java @@ -39,7 +39,7 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * * @author Rossen Stoyanchev */ -public class ModelMethodArgumentResolverTests { +class ModelMethodArgumentResolverTests { private final ModelMethodArgumentResolver resolver = new ModelMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); @@ -50,7 +50,7 @@ public class ModelMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.resolvable.arg(Model.class))).isTrue(); assertThat(this.resolver.supportsParameter(this.resolvable.arg(ModelMap.class))).isTrue(); assertThat(this.resolver.supportsParameter( @@ -62,7 +62,7 @@ public class ModelMethodArgumentResolverTests { } @Test - public void resolveArgument() { + void resolveArgument() { testResolveArgument(this.resolvable.arg(Model.class)); testResolveArgument(this.resolvable.annotNotPresent().arg(Map.class, String.class, Object.class)); testResolveArgument(this.resolvable.arg(ModelMap.class)); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java index 5cb4eaca0b..92d872e5d4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java @@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Rossen Stoyanchev */ -public class PathVariableMapMethodArgumentResolverTests { +class PathVariableMapMethodArgumentResolverTests { private PathVariableMapMethodArgumentResolver resolver; @@ -55,7 +55,7 @@ public class PathVariableMapMethodArgumentResolverTests { @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { this.resolver = new PathVariableMapMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class[]) null); @@ -67,7 +67,7 @@ public class PathVariableMapMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(resolver.supportsParameter(paramMap)).isTrue(); assertThat(resolver.supportsParameter(paramNamedMap)).isFalse(); assertThat(resolver.supportsParameter(paramMapNoAnnot)).isFalse(); @@ -77,7 +77,7 @@ public class PathVariableMapMethodArgumentResolverTests { } @Test - public void resolveArgument() throws Exception { + void resolveArgument() throws Exception { Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name1", "value1"); uriTemplateVars.put("name2", "value2"); @@ -90,7 +90,7 @@ public class PathVariableMapMethodArgumentResolverTests { } @Test - public void resolveArgumentNoUriVars() throws Exception { + void resolveArgumentNoUriVars() { Mono mono = this.resolver.resolveArgument(this.paramMap, new BindingContext(), this.exchange); Object result = mono.block(); 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 84a2703f0b..50293f82fc 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 @@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Rossen Stoyanchev * @author Juergen Hoeller */ -public class PathVariableMethodArgumentResolverTests { +class PathVariableMethodArgumentResolverTests { private PathVariableMethodArgumentResolver resolver; @@ -62,7 +62,7 @@ public class PathVariableMethodArgumentResolverTests { @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { this.resolver = new PathVariableMethodArgumentResolver(null, ReactiveAdapterRegistry.getSharedInstance()); Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class[]) null); @@ -75,7 +75,7 @@ public class PathVariableMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.paramNamedString)).isTrue(); assertThat(this.resolver.supportsParameter(this.paramString)).isFalse(); assertThatIllegalStateException().isThrownBy(() -> @@ -84,7 +84,7 @@ public class PathVariableMethodArgumentResolverTests { } @Test - public void resolveArgument() { + void resolveArgument() { Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name", "value"); this.exchange.getAttributes().put(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); @@ -96,7 +96,7 @@ public class PathVariableMethodArgumentResolverTests { } @Test - public void resolveArgumentNotRequired() { + void resolveArgumentNotRequired() { Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name", "value"); this.exchange.getAttributes().put(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); @@ -108,7 +108,7 @@ public class PathVariableMethodArgumentResolverTests { } @Test - public void resolveArgumentWrappedAsOptional() { + void resolveArgumentWrappedAsOptional() { Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name", "value"); this.exchange.getAttributes().put(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); @@ -123,7 +123,7 @@ public class PathVariableMethodArgumentResolverTests { } @Test - public void handleMissingValue() { + void handleMissingValue() { BindingContext bindingContext = new BindingContext(); Mono mono = this.resolver.resolveArgument(this.paramNamedString, bindingContext, this.exchange); StepVerifier.create(mono) @@ -133,7 +133,7 @@ public class PathVariableMethodArgumentResolverTests { } @Test - public void nullIfNotRequired() { + void nullIfNotRequired() { BindingContext bindingContext = new BindingContext(); Mono mono = this.resolver.resolveArgument(this.paramNotRequired, bindingContext, this.exchange); StepVerifier.create(mono) @@ -143,7 +143,7 @@ public class PathVariableMethodArgumentResolverTests { } @Test - public void wrapEmptyWithOptional() { + void wrapEmptyWithOptional() { BindingContext bindingContext = new BindingContext(); Mono mono = this.resolver.resolveArgument(this.paramOptional, bindingContext, this.exchange); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java index bd88136efe..4898a99f43 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class PrincipalMethodArgumentResolverTests { +class PrincipalMethodArgumentResolverTests { private final PrincipalMethodArgumentResolver resolver = new PrincipalMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); @@ -46,7 +46,7 @@ public class PrincipalMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.testMethod.arg(Principal.class))).isTrue(); assertThat(this.resolver.supportsParameter(this.testMethod.arg(Mono.class, Principal.class))).isTrue(); assertThat(this.resolver.supportsParameter(this.testMethod.arg(Single.class, Principal.class))).isTrue(); @@ -54,7 +54,7 @@ public class PrincipalMethodArgumentResolverTests { @Test - public void resolverArgument() { + void resolverArgument() { Principal user = () -> "Joe"; ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")) .mutate().principal(Mono.just(user)).build(); 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 343bf5f68e..478672f65f 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 @@ -45,7 +45,7 @@ import static org.springframework.web.testfixture.method.MvcAnnotationPredicates * * @author Rossen Stoyanchev */ -public class RequestAttributeMethodArgumentResolverTests { +class RequestAttributeMethodArgumentResolverTests { private RequestAttributeMethodArgumentResolver resolver; @@ -56,8 +56,7 @@ public class RequestAttributeMethodArgumentResolverTests { @BeforeEach - @SuppressWarnings("resource") - public void setup() throws Exception { + void setup() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.refresh(); ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance(); @@ -66,7 +65,7 @@ public class RequestAttributeMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter( this.testMethod.annot(requestAttribute().noName()).arg(Foo.class))).isTrue(); @@ -79,7 +78,7 @@ public class RequestAttributeMethodArgumentResolverTests { } @Test - public void resolve() { + void resolve() { MethodParameter param = this.testMethod.annot(requestAttribute().noName()).arg(Foo.class); Mono mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange); StepVerifier.create(mono) @@ -94,7 +93,7 @@ public class RequestAttributeMethodArgumentResolverTests { } @Test - public void resolveWithName() { + void resolveWithName() { MethodParameter param = this.testMethod.annot(requestAttribute().name("specialFoo")).arg(); Foo foo = new Foo(); this.exchange.getAttributes().put("specialFoo", foo); @@ -103,7 +102,7 @@ public class RequestAttributeMethodArgumentResolverTests { } @Test - public void resolveNotRequired() { + void resolveNotRequired() { MethodParameter param = this.testMethod.annot(requestAttribute().name("foo").notRequired()).arg(); Mono mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange); assertThat(mono.block()).isNull(); @@ -115,7 +114,7 @@ public class RequestAttributeMethodArgumentResolverTests { } @Test - public void resolveOptional() { + void resolveOptional() { MethodParameter param = this.testMethod.annot(requestAttribute().name("foo")).arg(Optional.class, Foo.class); Mono mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java index 008f2ee1f4..a3fc62ccff 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java @@ -58,7 +58,7 @@ import static org.springframework.web.testfixture.method.MvcAnnotationPredicates * * @author Rossen Stoyanchev */ -public class RequestBodyMethodArgumentResolverTests { +class RequestBodyMethodArgumentResolverTests { private RequestBodyMethodArgumentResolver resolver; @@ -66,7 +66,7 @@ public class RequestBodyMethodArgumentResolverTests { @BeforeEach - public void setup() { + void setup() { List> readers = new ArrayList<>(); readers.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes())); this.resolver = new RequestBodyMethodArgumentResolver(readers, ReactiveAdapterRegistry.getSharedInstance()); @@ -74,7 +74,7 @@ public class RequestBodyMethodArgumentResolverTests { @Test - public void supports() { + void supports() { MethodParameter param; param = this.testMethod.annot(requestBody()).arg(Mono.class, String.class); @@ -85,7 +85,7 @@ public class RequestBodyMethodArgumentResolverTests { } @Test - public void stringBody() { + void stringBody() { String body = "line1"; MethodParameter param = this.testMethod.annot(requestBody()).arg(String.class); String value = resolveValue(param, body); @@ -94,14 +94,14 @@ public class RequestBodyMethodArgumentResolverTests { } @Test - public void emptyBodyWithString() { + void emptyBodyWithString() { MethodParameter param = this.testMethod.annot(requestBody()).arg(String.class); assertThatExceptionOfType(ServerWebInputException.class).isThrownBy(() -> resolveValueWithEmptyBody(param)); } @Test - public void emptyBodyWithStringNotRequired() { + void emptyBodyWithStringNotRequired() { MethodParameter param = this.testMethod.annot(requestBody().notRequired()).arg(String.class); String body = resolveValueWithEmptyBody(param); @@ -149,7 +149,7 @@ public class RequestBodyMethodArgumentResolverTests { } @Test - public void emptyBodyWithSingle() { + void emptyBodyWithSingle() { MethodParameter param = this.testMethod.annot(requestBody()).arg(Single.class, String.class); Single single = resolveValueWithEmptyBody(param); StepVerifier.create(single.toFlowable()) @@ -166,7 +166,7 @@ public class RequestBodyMethodArgumentResolverTests { } @Test - public void emptyBodyWithMaybe() { + void emptyBodyWithMaybe() { MethodParameter param = this.testMethod.annot(requestBody()).arg(Maybe.class, String.class); Maybe maybe = resolveValueWithEmptyBody(param); StepVerifier.create(maybe.toFlowable()) @@ -183,7 +183,7 @@ public class RequestBodyMethodArgumentResolverTests { } @Test - public void emptyBodyWithObservable() { + void emptyBodyWithObservable() { MethodParameter param = this.testMethod.annot(requestBody()).arg(Observable.class, String.class); Observable observable = resolveValueWithEmptyBody(param); StepVerifier.create(observable.toFlowable(BackpressureStrategy.BUFFER)) @@ -200,7 +200,7 @@ public class RequestBodyMethodArgumentResolverTests { } @Test - public void emptyBodyWithCompletableFuture() { + void emptyBodyWithCompletableFuture() { MethodParameter param = this.testMethod.annot(requestBody()).arg(CompletableFuture.class, String.class); CompletableFuture future = resolveValueWithEmptyBody(param); future.whenComplete((text, ex) -> { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java index cfbb50a12a..96c84fa974 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java @@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Rossen Stoyanchev */ -public class RequestHeaderMapMethodArgumentResolverTests { +class RequestHeaderMapMethodArgumentResolverTests { private RequestHeaderMapMethodArgumentResolver resolver; @@ -55,7 +55,7 @@ public class RequestHeaderMapMethodArgumentResolverTests { @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { resolver = new RequestHeaderMapMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); Method method = ReflectionUtils.findMethod(getClass(), "params", (Class[]) null); @@ -69,7 +69,7 @@ public class RequestHeaderMapMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(resolver.supportsParameter(paramMap)).as("Map parameter not supported").isTrue(); assertThat(resolver.supportsParameter(paramMultiValueMap)).as("MultiValueMap parameter not supported").isTrue(); assertThat(resolver.supportsParameter(paramHttpHeaders)).as("HttpHeaders parameter not supported").isTrue(); @@ -80,7 +80,7 @@ public class RequestHeaderMapMethodArgumentResolverTests { } @Test - public void resolveMapArgument() { + void resolveMapArgument() { String name = "foo"; String value = "bar"; Map expected = Collections.singletonMap(name, value); @@ -116,7 +116,7 @@ public class RequestHeaderMapMethodArgumentResolverTests { } @Test - public void resolveHttpHeadersArgument() { + void resolveHttpHeadersArgument() { String name = "foo"; String value1 = "bar"; String value2 = "baz"; 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 b636e7a82b..b1a956b648 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 @@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Rossen Stoyanchev */ -public class RequestHeaderMethodArgumentResolverTests { +class RequestHeaderMethodArgumentResolverTests { private RequestHeaderMethodArgumentResolver resolver; @@ -67,8 +67,7 @@ public class RequestHeaderMethodArgumentResolverTests { @BeforeEach - @SuppressWarnings("resource") - public void setup() throws Exception { + void setup() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.refresh(); ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); @@ -92,7 +91,7 @@ public class RequestHeaderMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(resolver.supportsParameter(paramNamedDefaultValueStringHeader)).as("String parameter not supported").isTrue(); assertThat(resolver.supportsParameter(paramNamedValueStringArray)).as("String array parameter not supported").isTrue(); assertThat(resolver.supportsParameter(paramNamedValueMap)).as("non-@RequestParam parameter supported").isFalse(); @@ -102,7 +101,7 @@ public class RequestHeaderMethodArgumentResolverTests { } @Test - public void resolveStringArgument() { + void resolveStringArgument() { String expected = "foo"; ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/").header("name", expected)); @@ -116,7 +115,7 @@ public class RequestHeaderMethodArgumentResolverTests { } @Test - public void resolveStringArrayArgument() { + void resolveStringArrayArgument() { MockServerHttpRequest request = MockServerHttpRequest.get("/").header("name", "foo", "bar").build(); ServerWebExchange exchange = MockServerWebExchange.from(request); @@ -130,7 +129,7 @@ public class RequestHeaderMethodArgumentResolverTests { } @Test - public void resolveDefaultValue() { + void resolveDefaultValue() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); Mono mono = this.resolver.resolveArgument( this.paramNamedDefaultValueStringHeader, this.bindingContext, exchange); @@ -142,7 +141,7 @@ public class RequestHeaderMethodArgumentResolverTests { } @Test - public void resolveDefaultValueFromSystemProperty() { + void resolveDefaultValueFromSystemProperty() { System.setProperty("systemProperty", "bar"); try { Mono mono = this.resolver.resolveArgument( @@ -160,7 +159,7 @@ public class RequestHeaderMethodArgumentResolverTests { } @Test - public void resolveNameFromSystemPropertyThroughExpression() { + void resolveNameFromSystemPropertyThroughExpression() { String expected = "foo"; MockServerHttpRequest request = MockServerHttpRequest.get("/").header("bar", expected).build(); ServerWebExchange exchange = MockServerWebExchange.from(request); @@ -181,7 +180,7 @@ public class RequestHeaderMethodArgumentResolverTests { } @Test - public void resolveNameFromSystemPropertyThroughPlaceholder() { + void resolveNameFromSystemPropertyThroughPlaceholder() { String expected = "foo"; MockServerHttpRequest request = MockServerHttpRequest.get("/").header("bar", expected).build(); ServerWebExchange exchange = MockServerWebExchange.from(request); @@ -202,7 +201,7 @@ public class RequestHeaderMethodArgumentResolverTests { } @Test - public void notFound() { + void notFound() { Mono mono = resolver.resolveArgument( this.paramNamedValueStringArray, this.bindingContext, MockServerWebExchange.from(MockServerHttpRequest.get("/"))); @@ -229,7 +228,7 @@ public class RequestHeaderMethodArgumentResolverTests { } @Test - public void instantConversion() { + void instantConversion() { String rfc1123val = "Thu, 21 Apr 2016 17:11:08 +0100"; MockServerHttpRequest request = MockServerHttpRequest.get("/").header("name", rfc1123val).build(); ServerWebExchange exchange = MockServerWebExchange.from(request); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java index e7df37b4b9..cc146be163 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Rossen Stoyanchev * @author Juergen Hoeller */ -public class RequestMappingExceptionHandlingIntegrationTests extends AbstractRequestMappingIntegrationTests { +class RequestMappingExceptionHandlingIntegrationTests extends AbstractRequestMappingIntegrationTests { @Override protected ApplicationContext initApplicationContext() { @@ -86,7 +86,7 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq doTest("/mono-error", "Recovered from error: Argument"); } - private void doTest(String url, String expected) throws Exception { + private void doTest(String url, String expected) { assertThat(performGet(url, new HttpHeaders(), String.class).getBody()).isEqualTo(expected); } @@ -115,14 +115,14 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq } @Test - public void globalExceptionHandlerWithHandlerNotFound() throws Exception { + void globalExceptionHandlerWithHandlerNotFound() throws Exception { startServer(new ReactorHttpServer()); assertThatExceptionOfType(HttpStatusCodeException.class) .isThrownBy(() -> performGet("/no-such-handler", new HttpHeaders(), String.class)) .satisfies(ex -> { assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); - assertThat(ex.getResponseBodyAsString()).isEqualTo("" + + assertThat(ex.getResponseBodyAsString()).isEqualTo( "{\"type\":\"about:blank\"," + "\"title\":\"Not Found\"," + "\"status\":404," + @@ -131,7 +131,7 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq } @Test - public void globalExceptionHandlerWithMissingRequestParameter() throws Exception { + void globalExceptionHandlerWithMissingRequestParameter() throws Exception { startServer(new ReactorHttpServer()); assertThatExceptionOfType(HttpStatusCodeException.class) @@ -198,7 +198,7 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq } @GetMapping(path = "/SPR-16318", produces = "text/plain") - public Mono handleTextPlain() throws Exception { + public Mono handleTextPlain() { return Mono.error(new Spr16318Exception()); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java index a625059b90..71299abb82 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java @@ -224,8 +224,7 @@ class RequestMappingHandlerMappingTests { assertThat(paths.iterator().next().getPatternString()).isEqualTo(path); Set methods = info.getMethodsCondition().getMethods(); - assertThat(methods).hasSize(1); - assertThat(methods).element(0).isEqualTo(requestMethod); + assertThat(methods).containsExactly(requestMethod); return info; } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java index 5fda49e6fc..eb0b9e4c1b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -91,7 +91,6 @@ class RequestMappingViewResolutionIntegrationTests extends AbstractRequestMappin URI uri = URI.create("http://localhost:" + this.port + "/redirect"); RequestEntity request = RequestEntity.get(uri).accept(MediaType.ALL).build(); - @SuppressWarnings("resource") ResponseEntity response = new RestTemplate(factory).exchange(request, Void.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.SEE_OTHER); 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 3aa688eee4..55d09bf228 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 @@ -42,7 +42,7 @@ import static org.springframework.web.testfixture.method.MvcAnnotationPredicates * * @author Rossen Stoyanchev */ -public class RequestParamMapMethodArgumentResolverTests { +class RequestParamMapMethodArgumentResolverTests { private final RequestParamMapMethodArgumentResolver resolver = new RequestParamMapMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); @@ -51,7 +51,7 @@ public class RequestParamMapMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { MethodParameter param = this.testMethod.annot(requestParam().name("")).arg(Map.class); assertThat(this.resolver.supportsParameter(param)).isTrue(); @@ -70,7 +70,7 @@ public class RequestParamMapMethodArgumentResolverTests { } @Test - public void resolveMapArgumentWithQueryString() { + void resolveMapArgumentWithQueryString() { MethodParameter param = this.testMethod.annot(requestParam().name("")).arg(Map.class); Object result= resolve(param, MockServerWebExchange.from(MockServerHttpRequest.get("/path?foo=bar"))); boolean condition = result instanceof Map; @@ -79,7 +79,7 @@ public class RequestParamMapMethodArgumentResolverTests { } @Test - public void resolveMultiValueMapArgument() { + void resolveMultiValueMapArgument() { MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(MultiValueMap.class); ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path?foo=bar&foo=baz")); Object result= resolve(param, exchange); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java index 9005683178..ccb90f34d6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java @@ -47,7 +47,7 @@ import static org.springframework.web.testfixture.method.MvcAnnotationPredicates * * @author Rossen Stoyanchev */ -public class RequestParamMethodArgumentResolverTests { +class RequestParamMethodArgumentResolverTests { private RequestParamMethodArgumentResolver resolver; @@ -57,7 +57,7 @@ public class RequestParamMethodArgumentResolverTests { @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); this.resolver = new RequestParamMethodArgumentResolver(null, adapterRegistry, true); @@ -69,7 +69,7 @@ public class RequestParamMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { MethodParameter param = this.testMethod.annot(requestParam().notRequired("bar")).arg(String.class); assertThat(this.resolver.supportsParameter(param)).isTrue(); @@ -95,7 +95,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - public void doesNotSupportParameterWithDefaultResolutionTurnedOff() { + void doesNotSupportParameterWithDefaultResolutionTurnedOff() { ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); this.resolver = new RequestParamMethodArgumentResolver(null, adapterRegistry, false); @@ -104,7 +104,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - public void doesNotSupportReactiveWrapper() { + void doesNotSupportReactiveWrapper() { assertThatIllegalStateException().isThrownBy(() -> this.resolver.supportsParameter(this.testMethod.annot(requestParam()).arg(Mono.class, String.class))) .withMessageStartingWith("RequestParamMethodArgumentResolver does not support reactive type wrapper"); @@ -114,14 +114,14 @@ public class RequestParamMethodArgumentResolverTests { } @Test - public void resolveWithQueryString() { + void resolveWithQueryString() { MethodParameter param = this.testMethod.annot(requestParam().notRequired("bar")).arg(String.class); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path?name=foo")); assertThat(resolve(param, exchange)).isEqualTo("foo"); } @Test - public void resolveStringArray() { + void resolveStringArray() { MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(String[].class); MockServerHttpRequest request = MockServerHttpRequest.get("/path?name=foo&name=bar").build(); Object result = resolve(param, MockServerWebExchange.from(request)); @@ -131,7 +131,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - public void resolveDefaultValue() { + void resolveDefaultValue() { MethodParameter param = this.testMethod.annot(requestParam().notRequired("bar")).arg(String.class); assertThat(resolve(param, MockServerWebExchange.from(MockServerHttpRequest.get("/")))).isEqualTo("bar"); } @@ -145,7 +145,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - public void missingRequestParam() { + void missingRequestParam() { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(String[].class); @@ -158,7 +158,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - public void resolveSimpleTypeParam() { + void resolveSimpleTypeParam() { MockServerHttpRequest request = MockServerHttpRequest.get("/path?stringNotAnnot=plainValue").build(); ServerWebExchange exchange = MockServerWebExchange.from(request); MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class); @@ -181,21 +181,21 @@ public class RequestParamMethodArgumentResolverTests { } @Test - public void resolveEmptyValueWithoutDefault() { + void resolveEmptyValueWithoutDefault() { MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class); MockServerHttpRequest request = MockServerHttpRequest.get("/path?stringNotAnnot=").build(); assertThat(resolve(param, MockServerWebExchange.from(request))).isEqualTo(""); } @Test - public void resolveEmptyValueRequiredWithoutDefault() { + void resolveEmptyValueRequiredWithoutDefault() { MethodParameter param = this.testMethod.annot(requestParam()).arg(String.class); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path?name=")); assertThat(resolve(param, exchange)).isEqualTo(""); } @Test - public void resolveOptionalParamValue() { + void resolveOptionalParamValue() { ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); MethodParameter param = this.testMethod.arg(forClassWithGenerics(Optional.class, Integer.class)); Object result = resolve(param, exchange); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java index e693e9fe44..0643f334a4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java @@ -64,13 +64,13 @@ import static org.springframework.web.testfixture.method.ResolvableMethod.on; * @author Sebastien Deleuze * @author Rossen Stoyanchev */ -public class ResponseBodyResultHandlerTests { +class ResponseBodyResultHandlerTests { private ResponseBodyResultHandler resultHandler; @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { List> writerList = new ArrayList<>(5); writerList.add(new EncoderHttpMessageWriter<>(new ByteBufferEncoder())); writerList.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.allMimeTypes())); @@ -83,7 +83,7 @@ public class ResponseBodyResultHandlerTests { @Test - public void supports() { + void supports() { Object controller = new TestController(); Method method; @@ -96,7 +96,7 @@ public class ResponseBodyResultHandlerTests { } @Test - public void supportsRestController() { + void supportsRestController() { Object controller = new TestRestController(); Method method; @@ -156,7 +156,7 @@ public class ResponseBodyResultHandlerTests { } @Test - public void defaultOrder() { + void defaultOrder() { assertThat(this.resultHandler.getOrder()).isEqualTo(100); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandlerTests.java index 4e4121cbe1..c8bc65ad25 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandlerTests.java @@ -63,7 +63,7 @@ import static org.mockito.BDDMockito.mock; * * @author Rossen Stoyanchev */ -public class ResponseEntityExceptionHandlerTests { +class ResponseEntityExceptionHandlerTests { private final GlobalExceptionHandler exceptionHandler = new GlobalExceptionHandler(); @@ -110,12 +110,12 @@ public class ResponseEntityExceptionHandlerTests { } @Test - public void handlerMethodValidationException() { + void handlerMethodValidationException() { testException(new HandlerMethodValidationException(mock(MethodValidationResult.class))); } @Test - public void methodValidationException() { + void methodValidationException() { MethodValidationException ex = new MethodValidationException(mock(MethodValidationResult.class)); ResponseEntity entity = this.exceptionHandler.handleException(ex, this.exchange).block(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java index 16db12509c..ea31d83a7d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java @@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Rossen Stoyanchev */ -public class ServerWebExchangeMethodArgumentResolverTests { +class ServerWebExchangeMethodArgumentResolverTests { private final ServerWebExchangeMethodArgumentResolver resolver = new ServerWebExchangeMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); @@ -57,7 +57,7 @@ public class ServerWebExchangeMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.testMethod.arg(ServerWebExchange.class))).isTrue(); assertThat(this.resolver.supportsParameter(this.testMethod.arg(ServerHttpRequest.class))).isTrue(); assertThat(this.resolver.supportsParameter(this.testMethod.arg(ServerHttpResponse.class))).isTrue(); @@ -76,7 +76,7 @@ public class ServerWebExchangeMethodArgumentResolverTests { } @Test - public void resolveArgument() { + void resolveArgument() { testResolveArgument(this.testMethod.arg(ServerWebExchange.class), this.exchange); testResolveArgument(this.testMethod.arg(ServerHttpRequest.class), this.exchange.getRequest()); testResolveArgument(this.testMethod.arg(ServerHttpResponse.class), this.exchange.getResponse()); @@ -91,7 +91,7 @@ public class ServerWebExchangeMethodArgumentResolverTests { } @Test - public void resolveUriComponentsBuilder() { + void resolveUriComponentsBuilder() { MethodParameter param = this.testMethod.arg(UriComponentsBuilder.class); Object value = this.resolver.resolveArgument(param, new BindingContext(), this.exchange).block(); 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 9bae08a74a..e711d1bf78 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 @@ -61,7 +61,6 @@ class SessionAttributeMethodArgumentResolverTests { @BeforeEach - @SuppressWarnings("resource") void setup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.refresh(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java index 9afbe8b962..ca5e52d659 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -34,14 +34,14 @@ import static org.assertj.core.api.Assertions.assertThat; * Test fixture with {@link SessionAttributesHandler}. * @author Rossen Stoyanchev */ -public class SessionAttributesHandlerTests { +class SessionAttributesHandlerTests { private final SessionAttributesHandler sessionAttributesHandler = new SessionAttributesHandler(TestController.class); @Test - public void isSessionAttribute() { + void isSessionAttribute() { assertThat(this.sessionAttributesHandler.isHandlerSessionAttribute("attr1", String.class)).isTrue(); assertThat(this.sessionAttributesHandler.isHandlerSessionAttribute("attr2", String.class)).isTrue(); assertThat(this.sessionAttributesHandler.isHandlerSessionAttribute("simple", TestBean.class)).isTrue(); @@ -49,7 +49,7 @@ public class SessionAttributesHandlerTests { } @Test - public void retrieveAttributes() { + void retrieveAttributes() { WebSession session = new MockWebSession(); session.getAttributes().put("attr1", "value1"); session.getAttributes().put("attr2", "value2"); @@ -65,7 +65,7 @@ public class SessionAttributesHandlerTests { } @Test - public void cleanupAttributes() { + void cleanupAttributes() { WebSession session = new MockWebSession(); session.getAttributes().put("attr1", "value1"); session.getAttributes().put("attr2", "value2"); @@ -85,7 +85,7 @@ public class SessionAttributesHandlerTests { } @Test - public void storeAttributes() { + void storeAttributes() { ModelMap model = new ModelMap(); model.put("attr1", "value1"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java index 31c58f400e..bebf2fb342 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java @@ -37,7 +37,7 @@ import static org.mockito.Mockito.mock; * * @author Rossen Stoyanchev */ -public class WebSessionMethodArgumentResolverTests { +class WebSessionMethodArgumentResolverTests { private final WebSessionMethodArgumentResolver resolver = new WebSessionMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); @@ -46,7 +46,7 @@ public class WebSessionMethodArgumentResolverTests { @Test - public void supportsParameter() { + void supportsParameter() { assertThat(this.resolver.supportsParameter(this.testMethod.arg(WebSession.class))).isTrue(); assertThat(this.resolver.supportsParameter(this.testMethod.arg(Mono.class, WebSession.class))).isTrue(); assertThat(this.resolver.supportsParameter(this.testMethod.arg(Single.class, WebSession.class))).isTrue(); @@ -54,7 +54,7 @@ public class WebSessionMethodArgumentResolverTests { @Test - public void resolverArgument() { + void resolverArgument() { BindingContext context = new BindingContext(); WebSession session = mock(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java index 48f778135b..3c2d42c4eb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java @@ -44,13 +44,13 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Sebastien Deleuze */ -public class AbstractViewTests { +class AbstractViewTests { private MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); @Test - public void resolveAsyncAttributes() { + void resolveAsyncAttributes() { TestBean testBean1 = new TestBean("Bean1"); TestBean testBean2 = new TestBean("Bean2"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java index f4c0b92948..1c33c68808 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class DefaultRenderingBuilderTests { +class DefaultRenderingBuilderTests { @Test - public void defaultValues() { + void defaultValues() { Rendering rendering = Rendering.view("abc").build(); assertThat(rendering.view()).isEqualTo("abc"); @@ -44,7 +44,7 @@ public class DefaultRenderingBuilderTests { } @Test - public void defaultValuesForRedirect() throws Exception { + void defaultValuesForRedirect() { Rendering rendering = Rendering.redirectTo("abc").build(); Object view = rendering.view(); @@ -56,13 +56,13 @@ public class DefaultRenderingBuilderTests { @Test - public void viewName() { + void viewName() { Rendering rendering = Rendering.view("foo").build(); assertThat(rendering.view()).isEqualTo("foo"); } @Test - public void modelAttribute() throws Exception { + void modelAttribute() { Foo foo = new Foo(); Rendering rendering = Rendering.view("foo").modelAttribute(foo).build(); @@ -70,7 +70,7 @@ public class DefaultRenderingBuilderTests { } @Test - public void modelAttributes() throws Exception { + void modelAttributes() { Foo foo = new Foo(); Bar bar = new Bar(); Rendering rendering = Rendering.view("foo").modelAttributes(foo, bar).build(); @@ -82,7 +82,7 @@ public class DefaultRenderingBuilderTests { } @Test - public void model() throws Exception { + void model() { Map map = new LinkedHashMap<>(); map.put("foo", new Foo()); map.put("bar", new Bar()); @@ -92,7 +92,7 @@ public class DefaultRenderingBuilderTests { } @Test - public void header() throws Exception { + void header() { Rendering rendering = Rendering.view("foo").header("foo", "bar").build(); assertThat(rendering.headers()).hasSize(1); @@ -100,7 +100,7 @@ public class DefaultRenderingBuilderTests { } @Test - public void httpHeaders() throws Exception { + void httpHeaders() { HttpHeaders headers = new HttpHeaders(); headers.add("foo", "bar"); Rendering rendering = Rendering.view("foo").headers(headers).build(); @@ -109,7 +109,7 @@ public class DefaultRenderingBuilderTests { } @Test - public void redirectWithAbsoluteUrl() throws Exception { + void redirectWithAbsoluteUrl() { Rendering rendering = Rendering.redirectTo("foo").contextRelative(false).build(); Object view = rendering.view(); @@ -118,7 +118,7 @@ public class DefaultRenderingBuilderTests { } @Test - public void redirectWithPropagateQuery() throws Exception { + void redirectWithPropagateQuery() { Rendering rendering = Rendering.redirectTo("foo").propagateQuery(true).build(); Object view = rendering.view(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java index 668e1442a4..415ec7a6f9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Rossen Stoyanchev */ -public class HttpMessageWriterViewTests { +class HttpMessageWriterViewTests { private HttpMessageWriterView view = new HttpMessageWriterView(new Jackson2JsonEncoder()); @@ -54,7 +54,7 @@ public class HttpMessageWriterViewTests { @Test - public void supportedMediaTypes() { + void supportedMediaTypes() { assertThat(this.view.getSupportedMediaTypes()).containsExactly( MediaType.APPLICATION_JSON, MediaType.parseMediaType("application/*+json"), @@ -62,7 +62,7 @@ public class HttpMessageWriterViewTests { } @Test - public void singleMatch() throws Exception { + void singleMatch() throws Exception { this.view.setModelKeys(Collections.singleton("foo2")); this.model.addAttribute("foo1", Collections.singleton("bar1")); this.model.addAttribute("foo2", Collections.singleton("bar2")); @@ -72,7 +72,7 @@ public class HttpMessageWriterViewTests { } @Test - public void noMatch() throws Exception { + void noMatch() throws Exception { this.view.setModelKeys(Collections.singleton("foo2")); this.model.addAttribute("foo1", "bar1"); @@ -80,7 +80,7 @@ public class HttpMessageWriterViewTests { } @Test - public void noMatchBecauseNotSupported() throws Exception { + void noMatchBecauseNotSupported() throws Exception { this.view = new HttpMessageWriterView(new Jaxb2XmlEncoder()); this.view.setModelKeys(new HashSet<>(Collections.singletonList("foo1"))); this.model.addAttribute("foo1", "bar1"); @@ -89,7 +89,7 @@ public class HttpMessageWriterViewTests { } @Test - public void multipleMatches() throws Exception { + void multipleMatches() throws Exception { this.view.setModelKeys(new HashSet<>(Arrays.asList("foo1", "foo2"))); this.model.addAttribute("foo1", Collections.singleton("bar1")); this.model.addAttribute("foo2", Collections.singleton("bar2")); @@ -99,7 +99,7 @@ public class HttpMessageWriterViewTests { } @Test - public void multipleMatchesNotSupported() throws Exception { + void multipleMatchesNotSupported() throws Exception { this.view = new HttpMessageWriterView(CharSequenceEncoder.allMimeTypes()); this.view.setModelKeys(new HashSet<>(Arrays.asList("foo1", "foo2"))); this.model.addAttribute("foo1", "bar1"); @@ -111,7 +111,7 @@ public class HttpMessageWriterViewTests { } @Test - public void render() throws Exception { + void render() throws Exception { Map pojoData = new LinkedHashMap<>(); pojoData.put("foo", "f"); pojoData.put("bar", "b"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java index db20e2e00a..8012eecaa7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -39,26 +39,26 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * * @author Sebastien Deleuze */ -public class RedirectViewTests { +class RedirectViewTests { private MockServerWebExchange exchange; @BeforeEach - public void setup() { + void setup() { this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/context/path").contextPath("/context")); } @Test - public void noUrlSet() throws Exception { + void noUrlSet() { RedirectView rv = new RedirectView(null); assertThatIllegalArgumentException().isThrownBy( rv::afterPropertiesSet); } @Test - public void defaultStatusCode() { + void defaultStatusCode() { String url = "https://url.somewhere.com"; RedirectView view = new RedirectView(url); view.render(new HashMap<>(), MediaType.TEXT_HTML, this.exchange).block(); @@ -67,7 +67,7 @@ public class RedirectViewTests { } @Test - public void customStatusCode() { + void customStatusCode() { String url = "https://url.somewhere.com"; RedirectView view = new RedirectView(url, HttpStatus.FOUND); view.render(new HashMap<>(), MediaType.TEXT_HTML, this.exchange).block(); @@ -76,7 +76,7 @@ public class RedirectViewTests { } @Test - public void contextRelative() { + void contextRelative() { String url = "/test.html"; RedirectView view = new RedirectView(url); view.render(new HashMap<>(), MediaType.TEXT_HTML, this.exchange).block(); @@ -84,7 +84,7 @@ public class RedirectViewTests { } @Test - public void contextRelativeQueryParam() { + void contextRelativeQueryParam() { String url = "/test.html?id=1"; RedirectView view = new RedirectView(url); view.render(new HashMap<>(), MediaType.TEXT_HTML, this.exchange).block(); @@ -92,7 +92,7 @@ public class RedirectViewTests { } @Test - public void remoteHost() { + void remoteHost() { RedirectView view = new RedirectView(""); assertThat(view.isRemoteHost("https://url.somewhere.com")).isFalse(); @@ -107,7 +107,7 @@ public class RedirectViewTests { } @Test - public void expandUriTemplateVariablesFromModel() { + void expandUriTemplateVariablesFromModel() { String url = "https://url.somewhere.com?foo={foo}"; Map model = Collections.singletonMap("foo", "bar"); RedirectView view = new RedirectView(url); @@ -116,7 +116,7 @@ public class RedirectViewTests { } @Test - public void expandUriTemplateVariablesFromExchangeAttribute() { + void expandUriTemplateVariablesFromExchangeAttribute() { String url = "https://url.somewhere.com?foo={foo}"; Map attributes = Collections.singletonMap("foo", "bar"); this.exchange.getAttributes().put(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, attributes); @@ -126,7 +126,7 @@ public class RedirectViewTests { } @Test - public void propagateQueryParams() throws Exception { + void propagateQueryParams() { RedirectView view = new RedirectView("https://url.somewhere.com?foo=bar#bazz"); view.setPropagateQuery(true); this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("https://url.somewhere.com?a=b&c=d")); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java index c1b612fdb9..618706435a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class RequestContextTests { +class RequestContextTests { private final MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/foo/path").contextPath("/foo")); @@ -44,19 +44,19 @@ public class RequestContextTests { @BeforeEach - public void init() { + void init() { this.applicationContext = new GenericApplicationContext(); this.applicationContext.refresh(); } @Test - public void testGetContextUrl() throws Exception { + void testGetContextUrl() { RequestContext context = new RequestContext(this.exchange, this.model, this.applicationContext); assertThat(context.getContextUrl("bar")).isEqualTo("/foo/bar"); } @Test - public void testGetContextUrlWithMap() throws Exception { + void testGetContextUrlWithMap() { RequestContext context = new RequestContext(this.exchange, this.model, this.applicationContext); Map map = new HashMap<>(); map.put("foo", "bar"); @@ -65,7 +65,7 @@ public class RequestContextTests { } @Test - public void testGetContextUrlWithMapEscaping() throws Exception { + void testGetContextUrlWithMapEscaping() { RequestContext context = new RequestContext(this.exchange, this.model, this.applicationContext); Map map = new HashMap<>(); map.put("foo", "bar baz"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java index e8bd0b6a64..83ed83466c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java @@ -39,20 +39,20 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sebastien Deleuze * @author Sam Brannen */ -public class UrlBasedViewResolverTests { +class UrlBasedViewResolverTests { private final UrlBasedViewResolver resolver = new UrlBasedViewResolver(); @BeforeEach - public void setup() { + void setup() { StaticApplicationContext context = new StaticApplicationContext(); context.refresh(); this.resolver.setApplicationContext(context); } @Test - public void urlBasedViewResolverOverridesCustomRequestContextAttributeWithNonNullValue() throws Exception { + void urlBasedViewResolverOverridesCustomRequestContextAttributeWithNonNullValue() { assertThat(new TestView().getRequestContextAttribute()) .as("requestContextAttribute when instantiated directly") .isEqualTo("testRequestContext"); @@ -73,7 +73,7 @@ public class UrlBasedViewResolverTests { } @Test - public void urlBasedViewResolverDoesNotOverrideCustomRequestContextAttributeWithNull() throws Exception { + void urlBasedViewResolverDoesNotOverrideCustomRequestContextAttributeWithNull() { assertThat(new TestView().getRequestContextAttribute()) .as("requestContextAttribute when instantiated directly") .isEqualTo("testRequestContext"); @@ -93,7 +93,7 @@ public class UrlBasedViewResolverTests { } @Test - public void viewNames() throws Exception { + void viewNames() { this.resolver.setViewClass(TestView.class); this.resolver.setViewNames("my*"); @@ -105,7 +105,7 @@ public class UrlBasedViewResolverTests { } @Test - public void redirectView() throws Exception { + void redirectView() { Mono mono = this.resolver.resolveViewName("redirect:foo", Locale.US); StepVerifier.create(mono) @@ -120,7 +120,7 @@ public class UrlBasedViewResolverTests { } @Test - public void customizedRedirectView() throws Exception { + void customizedRedirectView() { this.resolver.setRedirectViewProvider(url -> new RedirectView(url, HttpStatus.FOUND)); Mono mono = this.resolver.resolveViewName("redirect:foo", Locale.US); @@ -143,7 +143,7 @@ public class UrlBasedViewResolverTests { } @Override - public boolean checkResourceExists(Locale locale) throws Exception { + public boolean checkResourceExists(Locale locale) { return true; } 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 895b8c86ef..f08d538121 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -396,7 +396,7 @@ class ViewResolutionResultHandlerTests { response.getHeaders().setContentType(mediaType); } model = new TreeMap<>(model); - String value = this.name + ": " + model.toString(); + String value = this.name + ": " + model; ByteBuffer byteBuffer = ByteBuffer.wrap(value.getBytes(UTF_8)); DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(byteBuffer); return response.writeWith(Flux.just(dataBuffer)); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurerTests.java index a0041345b2..3644c4ff34 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -41,19 +41,19 @@ import static org.assertj.core.api.Assertions.assertThatIOException; * @author Sam Brannen * @since 5.2 */ -public class FreeMarkerConfigurerTests { +class FreeMarkerConfigurerTests { private final FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); @Test - public void freeMarkerConfigurerDefaultEncoding() throws Exception { + void freeMarkerConfigurerDefaultEncoding() throws Exception { freeMarkerConfigurer.afterPropertiesSet(); Configuration cfg = freeMarkerConfigurer.getConfiguration(); assertThat(cfg.getDefaultEncoding()).isEqualTo("UTF-8"); } @Test - public void freeMarkerConfigurerWithConfigLocation() { + void freeMarkerConfigurerWithConfigLocation() { freeMarkerConfigurer.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); @@ -62,7 +62,7 @@ public class FreeMarkerConfigurerTests { } @Test - public void freeMarkerConfigurerWithResourceLoaderPath() throws Exception { + void freeMarkerConfigurerWithResourceLoaderPath() throws Exception { freeMarkerConfigurer.setTemplateLoaderPath("file:/mydir"); freeMarkerConfigurer.afterPropertiesSet(); Configuration cfg = freeMarkerConfigurer.getConfiguration(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java index 12fb7e7d96..bceadaf45c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -59,7 +59,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 5.2 */ -public class FreeMarkerMacroTests { +class FreeMarkerMacroTests { private static final String TEMPLATE_FILE = "test-macro.ftl"; @@ -73,7 +73,7 @@ public class FreeMarkerMacroTests { @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { this.templateLoaderPath = Files.createTempDirectory("webflux-").toAbsolutePath(); this.applicationContext.refresh(); @@ -84,7 +84,7 @@ public class FreeMarkerMacroTests { } @Test - public void springMacroRequestContextIsAutomaticallyExposedAsModelAttribute() throws Exception { + void springMacroRequestContextIsAutomaticallyExposedAsModelAttribute() throws Exception { storeTemplateInTempDir("<@spring.bind \"testBean.name\"/>\nHi ${spring.status.value}"); FreeMarkerView view = new FreeMarkerView() { @@ -116,7 +116,7 @@ public class FreeMarkerMacroTests { } @Test - public void name() throws Exception { + void name() throws Exception { testMacroOutput("NAME", "Darren"); } @@ -134,57 +134,57 @@ public class FreeMarkerMacroTests { } @Test - public void message() throws Exception { + void message() throws Exception { testMacroOutput("MESSAGE", "Howdy Mundo"); } @Test - public void defaultMessage() throws Exception { + void defaultMessage() throws Exception { testMacroOutput("DEFAULTMESSAGE", "hi planet"); } @Test - public void messageArgs() throws Exception { + void messageArgs() throws Exception { testMacroOutput("MESSAGEARGS", "Howdy[World]"); } @Test - public void messageArgsWithDefaultMessage() throws Exception { + void messageArgsWithDefaultMessage() throws Exception { testMacroOutput("MESSAGEARGSWITHDEFAULTMESSAGE", "Hi"); } @Test - public void url() throws Exception { + void url() throws Exception { testMacroOutput("URL", "/springtest/aftercontext.html"); } @Test - public void urlParams() throws Exception { + void urlParams() throws Exception { testMacroOutput("URLPARAMS", "/springtest/aftercontext/bar?spam=bucket"); } @Test - public void formInput() throws Exception { + void formInput() throws Exception { testMacroOutput("FORM1", ""); } @Test - public void formInputWithCss() throws Exception { + void formInputWithCss() throws Exception { testMacroOutput("FORM2", ""); } @Test - public void formTextarea() throws Exception { + void formTextarea() throws Exception { testMacroOutput("FORM3", ""); } @Test - public void formTextareaWithCustomRowsAndColumns() throws Exception { + void formTextareaWithCustomRowsAndColumns() throws Exception { testMacroOutput("FORM4", ""); } @Test - public void formSingleSelectFromMap() throws Exception { + void formSingleSelectFromMap() throws Exception { testMacroOutput("FORM5", "", // "", // @@ -206,7 +206,7 @@ public class FreeMarkerMacroTests { } @Test - public void formMultiSelect() throws Exception { + void formMultiSelect() throws Exception { testMacroOutput("FORM6", "", // "", // @@ -230,28 +230,28 @@ public class FreeMarkerMacroTests { } @Test - public void formCheckboxForStringProperty() throws Exception { + void formCheckboxForStringProperty() throws Exception { testMacroOutput("FORM15", "", ""); } @Test - public void formCheckboxForBooleanProperty() throws Exception { + void formCheckboxForBooleanProperty() throws Exception { testMacroOutput("FORM16", "", ""); } @Test - public void formCheckboxForNestedPath() throws Exception { + void formCheckboxForNestedPath() throws Exception { testMacroOutput("FORM18", "", ""); } @Test - public void formCheckboxForStringArray() throws Exception { + void formCheckboxForStringArray() throws Exception { testMacroOutput("FORM8", "", // "", // @@ -265,37 +265,37 @@ public class FreeMarkerMacroTests { } @Test - public void formPasswordInput() throws Exception { + void formPasswordInput() throws Exception { testMacroOutput("FORM9", ""); } @Test - public void formHiddenInput() throws Exception { + void formHiddenInput() throws Exception { testMacroOutput("FORM10", ""); } @Test - public void formInputText() throws Exception { + void formInputText() throws Exception { testMacroOutput("FORM11", ""); } @Test - public void formInputHidden() throws Exception { + void formInputHidden() throws Exception { testMacroOutput("FORM12", ""); } @Test - public void formInputPassword() throws Exception { + void formInputPassword() throws Exception { testMacroOutput("FORM13", ""); } @Test - public void forInputWithNestedPath() throws Exception { + void forInputWithNestedPath() throws Exception { testMacroOutput("FORM17", ""); } 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 956b56642c..d09171e430 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 @@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Sebastien Deleuze */ -public class JythonScriptTemplateTests { +class JythonScriptTemplateTests { @Test - public void renderTemplate() throws Exception { + void renderTemplate() throws Exception { Map model = new HashMap<>(); model.put("title", "Layout example"); model.put("body", "This is the body"); 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 1c50212de1..3424013f70 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 @@ -27,10 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Sebastien Deleuze */ -public class ScriptTemplateViewResolverTests { +class ScriptTemplateViewResolverTests { @Test - public void viewClass() throws Exception { + void viewClass() { ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver(); assertThat(resolver.requiredViewClass()).isEqualTo(ScriptTemplateView.class); DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractReactiveWebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractReactiveWebSocketIntegrationTests.java index 887f585168..d6954505fa 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractReactiveWebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractReactiveWebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -88,7 +88,6 @@ abstract class AbstractReactiveWebSocketIntegrationTests { static Stream arguments() throws IOException { - @SuppressWarnings("removal") WebSocketClient[] clients = new WebSocketClient[] { new TomcatWebSocketClient(), new ReactorNettyWebSocketClient(), @@ -101,7 +100,7 @@ abstract class AbstractReactiveWebSocketIntegrationTests { servers.put(new ReactorHttpServer(), ReactorNettyConfig.class); servers.put(new UndertowHttpServer(), UndertowConfig.class); - // Try each client once against each server.. + // Try each client once against each server Flux f1 = Flux.fromArray(clients) .concatMap(c -> Mono.just(c).repeat(servers.size() - 1)); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/WebSocketUpgradeHandlerPredicateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/WebSocketUpgradeHandlerPredicateTests.java index f33971bfd1..e5ee618ecc 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/WebSocketUpgradeHandlerPredicateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/WebSocketUpgradeHandlerPredicateTests.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.mock; * * @author Rossen Stoyanchev */ -public class WebSocketUpgradeHandlerPredicateTests { +class WebSocketUpgradeHandlerPredicateTests { private final WebSocketUpgradeHandlerPredicate predicate = new WebSocketUpgradeHandlerPredicate(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategyTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategyTests.java index 1eeee00252..9ae91280e3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategyTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategyTests.java @@ -26,7 +26,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; * * @author Rossen Stoyanchev */ -public class ReactorNettyRequestUpgradeStrategyTests { +class ReactorNettyRequestUpgradeStrategyTests { @Test // gh-25315 void defaultWebSocketSpecBuilderIsUniquePerRequest() {