Polish
This commit is contained in:
parent
d786635239
commit
f1a335708a
|
@ -37,7 +37,7 @@ import static org.mockito.BDDMockito.when;
|
|||
/**
|
||||
* Tests for {@link BindingContext}.
|
||||
*/
|
||||
public class BindingContextTests {
|
||||
class BindingContextTests {
|
||||
|
||||
@Test
|
||||
void jakartaValidatorExcludedWhenMethodValidationApplicable() {
|
||||
|
|
|
@ -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<Void> 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<Void> 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<Void> 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<Void> 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<WebExceptionHandler> handlers = Collections.singletonList(new ServerError500ExceptionHandler());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<MediaType> 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(
|
||||
|
|
|
@ -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<MediaType> 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<String, MediaType> 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<MediaType> mediaTypes = resolver.resolveMediaTypes(exchange);
|
||||
|
|
|
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class RequestedContentTypeResolverBuilderTests {
|
||||
class RequestedContentTypeResolverBuilderTests {
|
||||
|
||||
@Test
|
||||
void defaultSettings() {
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -149,8 +149,8 @@ class ResourceHandlerRegistryTests {
|
|||
|
||||
List<ResourceTransformer> 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<ResourceResolver> 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<ResourceTransformer> 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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<HttpMessageReader<?>> readers, ResolvableType type, MediaType mediaType) {
|
||||
private void assertHasMessageReader(List<HttpMessageReader<?>> readers, ResolvableType type, @Nullable MediaType mediaType) {
|
||||
assertThat(readers.stream().anyMatch(c -> mediaType == null || c.canRead(type, mediaType))).isTrue();
|
||||
}
|
||||
|
||||
private void assertHasMessageWriter(List<HttpMessageWriter<?>> writers, ResolvableType type, MediaType mediaType) {
|
||||
private void assertHasMessageWriter(List<HttpMessageWriter<?>> writers, ResolvableType type, @Nullable MediaType mediaType) {
|
||||
assertThat(writers.stream().anyMatch(c -> mediaType == null || c.canWrite(type, mediaType))).isTrue();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String> 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()
|
||||
|
|
|
@ -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<HttpMessageWriter<?>> 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<String, ReactiveHttpOutputMessage> inserter = BodyInserters.fromValue(body);
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class BodyInsertersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ofObject() {
|
||||
void ofObject() {
|
||||
User body = new User("foo", "bar");
|
||||
BodyInserter<User, ReactiveHttpOutputMessage> 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<User, ReactiveHttpOutputMessage> 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<User> body = Mono.just(new User("foo", "bar"));
|
||||
BodyInserter<?, ReactiveHttpOutputMessage> inserter = BodyInserters.fromProducer(body, User.class);
|
||||
|
||||
|
@ -175,7 +175,7 @@ public class BodyInsertersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ofProducerWithFlux() {
|
||||
void ofProducerWithFlux() {
|
||||
Flux<String> body = Flux.just("foo");
|
||||
BodyInserter<?, ReactiveHttpOutputMessage> inserter = BodyInserters.fromProducer(body, String.class);
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class BodyInsertersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ofProducerWithSingle() {
|
||||
void ofProducerWithSingle() {
|
||||
Single<User> body = Single.just(new User("foo", "bar"));
|
||||
BodyInserter<?, ReactiveHttpOutputMessage> inserter = BodyInserters.fromProducer(body, User.class);
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class BodyInsertersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ofPublisher() {
|
||||
void ofPublisher() {
|
||||
Flux<String> body = Flux.just("foo");
|
||||
BodyInserter<Flux<String>, 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<Resource, ReactiveHttpOutputMessage> inserter = BodyInserters.fromResource(body);
|
||||
|
@ -310,7 +310,7 @@ public class BodyInsertersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ofServerSentEventFlux() {
|
||||
void ofServerSentEventFlux() {
|
||||
ServerSentEvent<String> event = ServerSentEvent.builder("foo").build();
|
||||
Flux<ServerSentEvent<String>> body = Flux.just(event);
|
||||
BodyInserter<Flux<ServerSentEvent<String>>, ServerHttpResponse> inserter =
|
||||
|
@ -322,7 +322,7 @@ public class BodyInsertersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromFormDataMap() {
|
||||
void fromFormDataMap() {
|
||||
MultiValueMap<String, String> 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<MultiValueMap<String, String>, 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<String, Object> 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<DataBuffer> body = Flux.just(dataBuffer);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<String> context = new NamedThreadLocal<>("foo");
|
||||
|
||||
Map<String, Object> actual = new HashMap<>();
|
||||
|
@ -261,7 +261,7 @@ public class DefaultWebClientTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void bodyObjectPublisher() {
|
||||
void bodyObjectPublisher() {
|
||||
Mono<Void> 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<String, Object> 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<String, Object> 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();
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 -> {});
|
||||
|
|
|
@ -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<ClientResponse> 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<ClientResponse> filter(ClientRequest request, ExchangeFunction chain) {
|
||||
Optional<ClientRequestObservationContext> 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<ClientRequestObservationContext> 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() {
|
||||
|
|
|
@ -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<String, ResponseCookie> cookies = mock();
|
||||
given(mockResponse.cookies()).willReturn(cookies);
|
||||
|
|
|
@ -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!";
|
||||
|
||||
|
|
|
@ -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<Map<String, Object>> current = Optional.ofNullable(attributes).stream();
|
||||
Stream<Map<String, Object>> nested = nestedAttributes.stream().filter(Objects::nonNull);
|
||||
routerFunctionsAttributes.add(Stream.concat(current, nested).collect(Collectors.toUnmodifiableList()));
|
||||
routerFunctionsAttributes.add(Stream.concat(current, nested).toList());
|
||||
attributes = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String> responseMono = EntityResponse.fromObject("bar")
|
||||
.lastModified(oneMinuteBeforeNow)
|
||||
|
|
|
@ -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<RenderingResponse> 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<RenderingResponse> result = RenderingResponse.create("foo").headers(headers).build();
|
||||
StepVerifier.create(result)
|
||||
|
@ -81,7 +81,7 @@ public class DefaultRenderingResponseTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void modelAttribute() {
|
||||
void modelAttribute() {
|
||||
Mono<RenderingResponse> 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<RenderingResponse> result = RenderingResponse.create("foo")
|
||||
.modelAttribute("bar").build();
|
||||
StepVerifier.create(result)
|
||||
|
@ -101,7 +101,7 @@ public class DefaultRenderingResponseTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void modelAttributes() {
|
||||
void modelAttributes() {
|
||||
Map<String, String> model = Collections.singletonMap("foo", "bar");
|
||||
Mono<RenderingResponse> result = RenderingResponse.create("foo")
|
||||
.modelAttributes(model).build();
|
||||
|
@ -112,7 +112,7 @@ public class DefaultRenderingResponseTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void modelAttributesConventions() {
|
||||
void modelAttributesConventions() {
|
||||
Set<String> model = Collections.singleton("bar");
|
||||
Mono<RenderingResponse> result = RenderingResponse.create("foo")
|
||||
.modelAttributes(model).build();
|
||||
|
@ -123,7 +123,7 @@ public class DefaultRenderingResponseTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cookies() {
|
||||
void cookies() {
|
||||
MultiValueMap<String, ResponseCookie> newCookies = new LinkedMultiValueMap<>();
|
||||
newCookies.add("name", ResponseCookie.from("name", "value").build());
|
||||
Mono<RenderingResponse> result =
|
||||
|
@ -136,7 +136,7 @@ public class DefaultRenderingResponseTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void render() {
|
||||
void render() {
|
||||
Map<String, Object> model = Collections.singletonMap("foo", "bar");
|
||||
Mono<RenderingResponse> result = RenderingResponse.create("view").modelAttributes(model).build();
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class DefaultRenderingResponseTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void writeTo() {
|
||||
void writeTo() {
|
||||
Map<String, Object> 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<RenderingResponse> 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))
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<HttpMessageReader<?>> 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<String, String> 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<String, String> 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<String, String> 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<MediaType> 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<DataBuffer> 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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<ServerRequest, Mono<Resource>> lookupFunction =
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String, RequestPredicate> 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());
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<ServerResponse> 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<ServerResponse> 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<ServerResponse> route = RouterFunctions.route()
|
||||
.GET("/atts/1", request -> ServerResponse.ok().build())
|
||||
.withAttribute("foo", "bar")
|
||||
|
|
|
@ -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<ServerResponse> handlerFunction = request -> ServerResponse.ok().build();
|
||||
RouterFunction<ServerResponse> routerFunction1 = request -> Mono.empty();
|
||||
RouterFunction<ServerResponse> routerFunction2 = request -> Mono.just(handlerFunction);
|
||||
|
@ -58,7 +58,7 @@ public class RouterFunctionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void andOther() {
|
||||
void andOther() {
|
||||
HandlerFunction<ServerResponse> 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<ServerResponse> routerFunction1 = request -> Mono.empty();
|
||||
RequestPredicate requestPredicate = request -> true;
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class RouterFunctionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void filter() {
|
||||
void filter() {
|
||||
Mono<String> stringMono = Mono.just("42");
|
||||
HandlerFunction<EntityResponse<Mono<String>>> handlerFunction =
|
||||
request -> EntityResponse.fromPublisher(stringMono, String.class).build();
|
||||
|
@ -133,7 +133,7 @@ public class RouterFunctionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void attributes() {
|
||||
void attributes() {
|
||||
RouterFunction<ServerResponse> route = RouterFunctions.route(
|
||||
GET("/atts/1"), request -> ServerResponse.ok().build())
|
||||
.withAttribute("foo", "bar")
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String, HttpCookie> cookies = mock();
|
||||
given(mockRequest.cookies()).willReturn(cookies);
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = """
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<Resource> 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<Resource> 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<Resource> 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)
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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, "/**");
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<byte[]> 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<byte[]> 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
|
||||
|
|
|
@ -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(() ->
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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<PathPattern> 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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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(() ->
|
||||
|
|
|
@ -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<PathPattern> 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")
|
||||
|
|
|
@ -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), "/"));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Object> result = this.mapping.getHandler(MockServerWebExchange.from(MockServerHttpRequest.get(key)));
|
||||
|
|
|
@ -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<HandlerResult> 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<HandlerResult> 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<HandlerResult> 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<HandlerResult> 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<HandlerResult> 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<HandlerResult> 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<HandlerResult> 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<HandlerResult> 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<HandlerResult> 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<HandlerResult> 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 <T> HandlerMethodArgumentResolver stubResolver(Object stubValue) {
|
||||
private HandlerMethodArgumentResolver stubResolver(Object stubValue) {
|
||||
return stubResolver(Mono.just(stubValue));
|
||||
}
|
||||
|
||||
private <T> HandlerMethodArgumentResolver stubResolver(Mono<Object> stubValue) {
|
||||
private HandlerMethodArgumentResolver stubResolver(Mono<Object> stubValue) {
|
||||
HandlerMethodArgumentResolver resolver = mock();
|
||||
given(resolver.supportsParameter(any())).willReturn(true);
|
||||
given(resolver.resolveArgument(any(), any(), any())).willReturn(stubValue);
|
||||
|
|
|
@ -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<Object> 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<Object> mono = this.handlerMapping.getHandler(exchange);
|
||||
|
@ -185,7 +185,7 @@ public class RequestMappingInfoHandlerMappingTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getHandlerHttpOptions() {
|
||||
void getHandlerHttpOptions() {
|
||||
List<HttpMethod> 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<String, String> matrixVariables;
|
||||
Map<String, String> 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();
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<HandlerMethodArgumentResolver> resolvers = invocable.getResolvers();
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class ControllerMethodResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void modelAttributeArgumentResolvers() {
|
||||
void modelAttributeArgumentResolvers() {
|
||||
List<InvocableHandlerMethod> 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<SyncInvocableHandlerMethod> 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);
|
||||
|
||||
|
|
|
@ -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<Object> mono = resolver.resolveArgument(this.cookieParameter, this.bindingContext, exchange);
|
||||
StepVerifier.create(mono)
|
||||
|
|
|
@ -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<Object> mono = this.resolver.resolveArgument(
|
||||
|
|
|
@ -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<Object> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class HttpEntityMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithMono() {
|
||||
void emptyBodyWithMono() {
|
||||
ResolvableType type = httpEntityType(Mono.class, String.class);
|
||||
HttpEntity<Mono<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class HttpEntityMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithFlux() {
|
||||
void emptyBodyWithFlux() {
|
||||
ResolvableType type = httpEntityType(Flux.class, String.class);
|
||||
HttpEntity<Flux<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class HttpEntityMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithSingle() {
|
||||
void emptyBodyWithSingle() {
|
||||
ResolvableType type = httpEntityType(Single.class, String.class);
|
||||
HttpEntity<Single<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class HttpEntityMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithMaybe() {
|
||||
void emptyBodyWithMaybe() {
|
||||
ResolvableType type = httpEntityType(Maybe.class, String.class);
|
||||
HttpEntity<Maybe<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class HttpEntityMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithObservable() {
|
||||
void emptyBodyWithObservable() {
|
||||
ResolvableType type = httpEntityType(Observable.class, String.class);
|
||||
HttpEntity<Observable<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
|
@ -158,7 +158,7 @@ public class HttpEntityMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithFlowable() {
|
||||
void emptyBodyWithFlowable() {
|
||||
ResolvableType type = httpEntityType(Flowable.class, String.class);
|
||||
HttpEntity<Flowable<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class HttpEntityMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithCompletableFuture() {
|
||||
void emptyBodyWithCompletableFuture() {
|
||||
ResolvableType type = httpEntityType(CompletableFuture.class, String.class);
|
||||
HttpEntity<CompletableFuture<String>> 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<String> 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<Mono<String>> 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<Single<String>> 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<Maybe<String>> 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<CompletableFuture<String>> 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<Flux<String>> 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<String> requestEntity = resolveValue(exchange, type);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<String, String> 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<String, String> 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<String, String> params2 = getMatrixVariables("planes");
|
||||
params2.add("colors", "yellow");
|
||||
params2.add("colors", "orange");
|
||||
|
|
|
@ -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<String, String> 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<String, String> params = getVariablesFor("cars");
|
||||
params.add("anotherYear", "2012");
|
||||
MethodParameter param = this.testMethod.annot(matrixAttribute().name("year")).arg(int.class);
|
||||
|
|
|
@ -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<String, String> 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);
|
||||
|
|
|
@ -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<ParentClass> 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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 -> {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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<String, String> 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<Object> mono = this.resolver.resolveArgument(this.paramMap, new BindingContext(), this.exchange);
|
||||
Object result = mono.block();
|
||||
|
||||
|
|
|
@ -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<String, String> 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<String, String> 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<String, String> 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<Object> 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<Object> 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<Object> mono = this.resolver.resolveArgument(this.paramOptional, bindingContext, this.exchange);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<Object> 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<Object> 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<Object> mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange);
|
||||
|
||||
|
|
|
@ -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<HttpMessageReader<?>> 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<String> 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<String> 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<String> 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<String> future = resolveValueWithEmptyBody(param);
|
||||
future.whenComplete((text, ex) -> {
|
||||
|
|
|
@ -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<String, String> 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";
|
||||
|
|
|
@ -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<Object> 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<Object> 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<Object> 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);
|
||||
|
|
|
@ -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<String> handleTextPlain() throws Exception {
|
||||
public Mono<String> handleTextPlain() {
|
||||
return Mono.error(new Spr16318Exception());
|
||||
}
|
||||
|
||||
|
|
|
@ -224,8 +224,7 @@ class RequestMappingHandlerMappingTests {
|
|||
assertThat(paths.iterator().next().getPatternString()).isEqualTo(path);
|
||||
|
||||
Set<RequestMethod> methods = info.getMethodsCondition().getMethods();
|
||||
assertThat(methods).hasSize(1);
|
||||
assertThat(methods).element(0).isEqualTo(requestMethod);
|
||||
assertThat(methods).containsExactly(requestMethod);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
|
|
@ -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<Void> request = RequestEntity.get(uri).accept(MediaType.ALL).build();
|
||||
@SuppressWarnings("resource")
|
||||
ResponseEntity<Void> response = new RestTemplate(factory).exchange(request, Void.class);
|
||||
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.SEE_OTHER);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<HttpMessageWriter<?>> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ class SessionAttributeMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
@SuppressWarnings("resource")
|
||||
void setup() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.refresh();
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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<String, Object> 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();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue