Clean up warnings and dead code in spring-webflux module
This commit is contained in:
@@ -110,7 +110,7 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
|
||||
* @return indicates completion or error
|
||||
* @since 5.0.2
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected Mono<Void> writeBody(@Nullable Object body, MethodParameter bodyParameter,
|
||||
@Nullable MethodParameter actualParameter, ServerWebExchange exchange) {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,6 +38,7 @@ public class TomcatWebSocketSession extends StandardWebSocketSession {
|
||||
private static final AtomicIntegerFieldUpdater<TomcatWebSocketSession> SUSPENDED =
|
||||
AtomicIntegerFieldUpdater.newUpdater(TomcatWebSocketSession.class, "suspended");
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private volatile int suspended;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,18 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.reactive.accept;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.test.server.MockServerWebExchange;
|
||||
import org.springframework.web.server.NotAcceptableStatusException;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -35,13 +34,7 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
public class HeaderContentTypeResolverTests {
|
||||
|
||||
private HeaderContentTypeResolver resolver;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.resolver = new HeaderContentTypeResolver();
|
||||
}
|
||||
private final HeaderContentTypeResolver resolver = new HeaderContentTypeResolver();
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,14 +27,12 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.http.codec.HttpMessageWriter;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
|
||||
import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder;
|
||||
import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.*;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -305,7 +305,7 @@ public class WebFluxConfigurationSupportTests {
|
||||
@Override
|
||||
protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
|
||||
configurer.registerDefaults(false);
|
||||
configurer.customCodecs().decoder(StringDecoder.textPlainOnly(true));
|
||||
configurer.customCodecs().decoder(StringDecoder.textPlainOnly());
|
||||
configurer.customCodecs().decoder(new Jaxb2XmlDecoder());
|
||||
configurer.customCodecs().encoder(CharSequenceEncoder.textPlainOnly());
|
||||
configurer.customCodecs().encoder(new Jaxb2XmlEncoder());
|
||||
|
||||
@@ -76,7 +76,7 @@ public class BodyExtractorsTests {
|
||||
public void createContext() {
|
||||
final List<HttpMessageReader<?>> messageReaders = new ArrayList<>();
|
||||
messageReaders.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder()));
|
||||
messageReaders.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
messageReaders.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
messageReaders.add(new DecoderHttpMessageReader<>(new Jaxb2XmlDecoder()));
|
||||
messageReaders.add(new DecoderHttpMessageReader<>(new Jackson2JsonDecoder()));
|
||||
messageReaders.add(new FormHttpMessageReader());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,16 +23,12 @@ import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.MultipartBodyBuilder;
|
||||
import org.springframework.http.codec.multipart.FilePart;
|
||||
import org.springframework.http.codec.multipart.FormFieldPart;
|
||||
import org.springframework.http.codec.multipart.Part;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
Mono<String> resultMono = defaultClientResponse.body(toMono(String.class));
|
||||
@@ -148,7 +148,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
Mono<String> resultMono = defaultClientResponse.bodyToMono(String.class);
|
||||
@@ -169,7 +169,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
Mono<String> resultMono =
|
||||
@@ -192,7 +192,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
Flux<String> resultFlux = defaultClientResponse.bodyToFlux(String.class);
|
||||
@@ -214,7 +214,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
Flux<String> resultFlux =
|
||||
@@ -238,7 +238,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
ResponseEntity<String> result = defaultClientResponse.toEntity(String.class).block();
|
||||
@@ -261,7 +261,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
ResponseEntity<String> result = defaultClientResponse.toEntity(
|
||||
@@ -286,7 +286,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
ResponseEntity<List<String>> result = defaultClientResponse.toEntityList(String.class).block();
|
||||
@@ -309,7 +309,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body);
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
ResponseEntity<List<String>> result = defaultClientResponse.toEntityList(
|
||||
@@ -331,7 +331,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body.flux());
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
StepVerifier.create(defaultClientResponse.bodyToMono(Void.class))
|
||||
@@ -356,7 +356,7 @@ public class DefaultClientResponseTests {
|
||||
when(mockResponse.getBody()).thenReturn(body.flux());
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = Collections
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
.singletonList(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders);
|
||||
|
||||
StepVerifier.create(defaultClientResponse.bodyToMono(Void.class))
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.function.server;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@@ -24,7 +23,6 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
@@ -34,8 +32,6 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.codec.CharSequenceEncoder;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -44,16 +40,13 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.codec.EncoderHttpMessageWriter;
|
||||
import org.springframework.http.codec.HttpMessageWriter;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse;
|
||||
import org.springframework.mock.web.test.server.MockServerWebExchange;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.reactive.function.BodyInserter;
|
||||
import org.springframework.web.reactive.result.view.ViewResolver;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
@@ -135,7 +128,6 @@ public class DefaultEntityResponseBuilderTests {
|
||||
.verify();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void lastModified() throws Exception {
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
@@ -197,14 +189,6 @@ public class DefaultEntityResponseBuilderTests {
|
||||
public void bodyInserter() throws Exception {
|
||||
String body = "foo";
|
||||
Publisher<String> publisher = Mono.just(body);
|
||||
BiFunction<ServerHttpResponse, BodyInserter.Context, Mono<Void>> writer =
|
||||
(response, strategies) -> {
|
||||
byte[] bodyBytes = body.getBytes(UTF_8);
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(bodyBytes);
|
||||
DataBuffer buffer = new DefaultDataBufferFactory().wrap(byteBuffer);
|
||||
|
||||
return response.writeWith(Mono.just(buffer));
|
||||
};
|
||||
|
||||
Mono<EntityResponse<Publisher<String>>> result = EntityResponse.fromPublisher(publisher, String.class).build();
|
||||
|
||||
@@ -257,7 +241,6 @@ public class DefaultEntityResponseBuilderTests {
|
||||
.verify();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void notModifiedLastModified() {
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -59,14 +58,8 @@ import static org.springframework.web.reactive.function.BodyExtractors.toMono;
|
||||
*/
|
||||
public class DefaultServerRequestTests {
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders;
|
||||
|
||||
|
||||
@Before
|
||||
public void createMocks() {
|
||||
this.messageReaders = Collections.singletonList(
|
||||
new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
}
|
||||
private final List<HttpMessageReader<?>> messageReaders = Collections.singletonList(
|
||||
new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
|
||||
|
||||
@Test
|
||||
@@ -335,12 +328,12 @@ public class DefaultServerRequestTests {
|
||||
.method(HttpMethod.GET, "http://example.com?foo=bar")
|
||||
.headers(httpHeaders)
|
||||
.body(body);
|
||||
this.messageReaders = Collections.emptyList();
|
||||
DefaultServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), messageReaders);
|
||||
DefaultServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), Collections.emptyList());
|
||||
|
||||
Flux<String> resultFlux = request.bodyToFlux(String.class);
|
||||
StepVerifier.create(resultFlux)
|
||||
.expectError(UnsupportedMediaTypeStatusException.class)
|
||||
.verify();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,26 +16,15 @@
|
||||
|
||||
package org.springframework.web.reactive.function.server.support;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.codec.ByteBufferDecoder;
|
||||
import org.springframework.http.codec.DecoderHttpMessageReader;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.test.server.MockServerWebExchange;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
import org.springframework.web.reactive.function.server.HandlerFunction;
|
||||
import org.springframework.web.reactive.function.server.RequestPredicates;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.RouterFunctions;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -44,20 +33,10 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
*/
|
||||
public class RouterFunctionMappingTests {
|
||||
|
||||
private final ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("http://example.com/match"));
|
||||
|
||||
private List<HttpMessageReader<?>> messageReaders;
|
||||
private final ServerCodecConfigurer codecConfigurer = ServerCodecConfigurer.create();
|
||||
|
||||
private ServerWebExchange exchange;
|
||||
|
||||
private ServerCodecConfigurer codecConfigurer;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.messageReaders = Collections.singletonList(new DecoderHttpMessageReader<>(new ByteBufferDecoder()));
|
||||
this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("http://example.com/match"));
|
||||
codecConfigurer = ServerCodecConfigurer.create();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void normal() {
|
||||
@@ -88,20 +67,4 @@ public class RouterFunctionMappingTests {
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableWebFlux
|
||||
private static class TestConfig {
|
||||
|
||||
public RouterFunction<ServerResponse> match() {
|
||||
HandlerFunction<ServerResponse> handlerFunction = request -> ServerResponse.ok().build();
|
||||
return RouterFunctions.route(RequestPredicates.GET("/match"), handlerFunction);
|
||||
}
|
||||
|
||||
public RouterFunction<ServerResponse> noMatch() {
|
||||
HandlerFunction<ServerResponse> handlerFunction = request -> ServerResponse.ok().build();
|
||||
RouterFunction<ServerResponse> routerFunction = request -> Mono.empty();
|
||||
return RouterFunctions.route(RequestPredicates.GET("/no-match"), handlerFunction);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.reactive.handler;
|
||||
|
||||
import java.net.URI;
|
||||
@@ -44,6 +45,7 @@ import static org.springframework.web.reactive.HandlerMapping.PATH_WITHIN_HANDLE
|
||||
public class SimpleUrlHandlerMappingTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void handlerMappingJavaConfig() throws Exception {
|
||||
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
|
||||
wac.register(WebConfig.class);
|
||||
@@ -61,6 +63,7 @@ public class SimpleUrlHandlerMappingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void handlerMappingXmlConfig() throws Exception {
|
||||
ClassPathXmlApplicationContext wac = new ClassPathXmlApplicationContext("map.xml", getClass());
|
||||
wac.refresh();
|
||||
@@ -118,7 +121,7 @@ public class SimpleUrlHandlerMappingTests {
|
||||
|
||||
@Configuration
|
||||
static class WebConfig {
|
||||
|
||||
|
||||
@Bean @SuppressWarnings("unused")
|
||||
public SimpleUrlHandlerMapping handlerMapping() {
|
||||
SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,6 @@ import org.springframework.web.util.pattern.PathPattern;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ResourceUrlProvider}.
|
||||
*
|
||||
@@ -133,6 +132,7 @@ public class ResourceUrlProviderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-12592
|
||||
@SuppressWarnings("resource")
|
||||
public void initializeOnce() throws Exception {
|
||||
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
||||
context.setServletContext(new MockServletContext());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,6 @@ import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.test.server.MockServerWebExchange;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,6 +58,7 @@ public class CookieValueMethodArgumentResolverTests {
|
||||
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("resource")
|
||||
public void setup() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.refresh();
|
||||
|
||||
@@ -53,6 +53,7 @@ public class ExpressionValueMethodArgumentResolverTests {
|
||||
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("resource")
|
||||
public void setup() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.refresh();
|
||||
|
||||
@@ -62,14 +62,14 @@ import static org.springframework.mock.http.server.reactive.test.MockServerHttpR
|
||||
*/
|
||||
public class HttpEntityArgumentResolverTests {
|
||||
|
||||
private HttpEntityArgumentResolver resolver = createResolver();
|
||||
private final HttpEntityArgumentResolver resolver = createResolver();
|
||||
|
||||
private final ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build();
|
||||
|
||||
|
||||
private HttpEntityArgumentResolver createResolver() {
|
||||
List<HttpMessageReader<?>> readers = new ArrayList<>();
|
||||
readers.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
readers.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
return new HttpEntityArgumentResolver(readers, ReactiveAdapterRegistry.getSharedInstance());
|
||||
}
|
||||
|
||||
|
||||
@@ -361,6 +361,7 @@ public class ModelAttributeMethodArgumentResolverTests {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class Bar {
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
|
||||
import org.springframework.web.bind.support.WebBindingInitializer;
|
||||
@@ -61,6 +60,7 @@ import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ModelInitializer}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ModelInitializerTests {
|
||||
@@ -298,7 +298,4 @@ public class ModelInitializerTests {
|
||||
private static final ReflectionUtils.MethodFilter BINDER_METHODS = method ->
|
||||
AnnotationUtils.findAnnotation(method, InitBinder.class) != null;
|
||||
|
||||
private static final ReflectionUtils.MethodFilter ATTRIBUTE_METHODS = method ->
|
||||
(AnnotationUtils.findAnnotation(method, RequestMapping.class) == null) &&
|
||||
(AnnotationUtils.findAnnotation(method, ModelAttribute.class) != null);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,6 +61,7 @@ public class RequestAttributeMethodArgumentResolverTests {
|
||||
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("resource")
|
||||
public void setup() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.refresh();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,7 +69,7 @@ public class RequestBodyArgumentResolverTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
List<HttpMessageReader<?>> readers = new ArrayList<>();
|
||||
readers.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
|
||||
readers.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
|
||||
this.resolver = new RequestBodyArgumentResolver(readers, ReactiveAdapterRegistry.getSharedInstance());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,6 +70,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("resource")
|
||||
public void setup() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.refresh();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -30,7 +29,6 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -72,6 +72,7 @@ public class SessionAttributeMethodArgumentResolverTests {
|
||||
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("resource")
|
||||
public void setup() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.refresh();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -45,52 +44,47 @@ import static org.junit.Assert.assertNull;
|
||||
*/
|
||||
public class AbstractViewTests {
|
||||
|
||||
private MockServerWebExchange exchange;
|
||||
private MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void resolveAsyncAttributes() {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void resolveAsyncAttributes() {
|
||||
|
||||
TestBean testBean1 = new TestBean("Bean1");
|
||||
TestBean testBean2 = new TestBean("Bean2");
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
attributes.put("attr1", Mono.just(testBean1));
|
||||
attributes.put("attr2", Flux.just(testBean1, testBean2));
|
||||
attributes.put("attr3", Single.just(testBean2));
|
||||
attributes.put("attr4", Observable.just(testBean1, testBean2));
|
||||
attributes.put("attr5", Mono.empty());
|
||||
TestBean testBean1 = new TestBean("Bean1");
|
||||
TestBean testBean2 = new TestBean("Bean2");
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
attributes.put("attr1", Mono.just(testBean1));
|
||||
attributes.put("attr2", Flux.just(testBean1, testBean2));
|
||||
attributes.put("attr3", Single.just(testBean2));
|
||||
attributes.put("attr4", Observable.just(testBean1, testBean2));
|
||||
attributes.put("attr5", Mono.empty());
|
||||
|
||||
TestView view = new TestView();
|
||||
StepVerifier.create(view.render(attributes, null, this.exchange)).verifyComplete();
|
||||
TestView view = new TestView();
|
||||
StepVerifier.create(
|
||||
view.render(attributes, null, this.exchange)).verifyComplete();
|
||||
|
||||
Map<String, Object> actual = view.attributes;
|
||||
assertEquals(testBean1, actual.get("attr1"));
|
||||
assertArrayEquals(new TestBean[] {testBean1, testBean2}, ((List<TestBean>) actual.get("attr2")).toArray());
|
||||
assertEquals(testBean2, actual.get("attr3"));
|
||||
assertArrayEquals(new TestBean[] {testBean1, testBean2}, ((List<TestBean>) actual.get("attr4")).toArray());
|
||||
assertNull(actual.get("attr5"));
|
||||
}
|
||||
assertArrayEquals(new TestBean[] { testBean1, testBean2 },
|
||||
((List<TestBean>) actual.get("attr2")).toArray());
|
||||
assertEquals(testBean2, actual.get("attr3"));
|
||||
assertArrayEquals(new TestBean[] { testBean1, testBean2 },
|
||||
((List<TestBean>) actual.get("attr4")).toArray());
|
||||
assertNull(actual.get("attr5"));
|
||||
}
|
||||
|
||||
private static class TestView extends AbstractView {
|
||||
|
||||
private static class TestView extends AbstractView {
|
||||
private Map<String, Object> attributes;
|
||||
|
||||
private Map<String, Object> attributes;
|
||||
|
||||
@Override
|
||||
protected Mono<Void> renderInternal(Map<String, Object> renderAttributes,
|
||||
@Override
|
||||
protected Mono<Void> renderInternal(Map<String, Object> renderAttributes,
|
||||
MediaType contentType, ServerWebExchange exchange) {
|
||||
|
||||
this.attributes = renderAttributes;
|
||||
return Mono.empty();
|
||||
}
|
||||
this.attributes = renderAttributes;
|
||||
return Mono.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> getAttributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user