Polishing

(cherry picked from commit 77ab88b144)
This commit is contained in:
Juergen Hoeller
2018-11-23 13:56:02 +01:00
parent f0e69e06b7
commit 3d7e373e5a
22 changed files with 112 additions and 113 deletions

View File

@@ -88,7 +88,7 @@ public abstract class AbstractHttpHandlerIntegrationTests {
* set the number of buffered to an arbitrary number greater than N.
* </ul>
*/
public static Flux<Long> interval(Duration period, int count) {
public static Flux<Long> testInterval(Duration period, int count) {
return Flux.interval(period).take(count).onBackpressureBuffer(count);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.http.server.reactive;
import java.net.URI;
@@ -27,15 +28,13 @@ import reactor.core.publisher.Mono;
import org.springframework.http.HttpCookie;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseCookie;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalToIgnoringCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
/**
* @author Rossen Stoyanchev
@@ -43,11 +42,11 @@ import static org.junit.Assert.assertThat;
@RunWith(Parameterized.class)
public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests {
private CookieHandler cookieHandler;
private final CookieHandler cookieHandler = new CookieHandler();
@Override
protected HttpHandler createHttpHandler() {
this.cookieHandler = new CookieHandler();
return this.cookieHandler;
}

View File

@@ -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.
@@ -26,14 +26,16 @@ import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.*;
/**
* @author Arjen Poutsma
*/
public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
private static final int REQUEST_SIZE = 4096 * 3;
private Random rnd = new Random();
private final Random rnd = new Random();
@Override

View File

@@ -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.
@@ -28,21 +28,23 @@ import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
/**
* @author Arjen Poutsma
*/
public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
private ErrorHandler handler = new ErrorHandler();
private final ErrorHandler handler = new ErrorHandler();
@Override
protected HttpHandler createHttpHandler() {
return handler;
}
@Test
public void responseBodyError() throws Exception {
// TODO: fix Reactor
@@ -83,6 +85,7 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
assertEquals(HttpStatus.OK, response.getStatusCode());
}
private static class ErrorHandler implements HttpHandler {
@Override
@@ -101,6 +104,7 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
}
}
private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new ResponseErrorHandler() {
@Override

View File

@@ -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.
@@ -33,6 +33,9 @@ import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.*;
/**
* @author Arjen Poutsma
*/
public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
public static final int REQUEST_SIZE = 4096 * 3;

View File

@@ -28,6 +28,9 @@ import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.*;
/**
* @author Sebastien Deleuze
*/
public class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@Override
@@ -58,4 +61,5 @@ public class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegr
return Mono.empty();
}
}
}

View File

@@ -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,19 +21,16 @@ import java.nio.charset.StandardCharsets;
import java.util.Random;
import org.junit.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* @author Violeta Georgieva
* @since 5.0
@@ -52,7 +49,6 @@ public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegra
return new WriteOnlyHandler();
}
@Test
public void writeOnly() throws Exception {
RestTemplate restTemplate = new RestTemplate();
@@ -66,7 +62,6 @@ public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegra
assertArrayEquals(body, response.getBody());
}
private byte[] randomBytes() {
byte[] buffer = new byte[REQUEST_SIZE];
rnd.nextBytes(buffer);
@@ -83,4 +78,5 @@ public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegra
return response.writeAndFlushWith(Flux.just(Flux.just(buffer)));
}
}
}

View File

@@ -32,9 +32,8 @@ import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer;
import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
/**
* @author Arjen Poutsma
@@ -43,14 +42,15 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
private final ZeroCopyHandler handler = new ZeroCopyHandler();
@Override
protected HttpHandler createHttpHandler() {
return handler;
return this.handler;
}
@Test
public void zeroCopy() throws Exception {
// Zero-copy only does not support servlet
assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer);
@@ -64,9 +64,9 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
assertEquals(logo.contentLength(), response.getHeaders().getContentLength());
assertEquals(logo.contentLength(), response.getBody().length);
assertEquals(MediaType.IMAGE_PNG, response.getHeaders().getContentType());
}
private static class ZeroCopyHandler implements HttpHandler {
@Override
@@ -85,4 +85,4 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
}
}
}
}

View File

@@ -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.
@@ -38,31 +38,22 @@ import org.springframework.web.server.WebHandler;
import org.springframework.web.server.WebSession;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
/**
* Integration tests for with a server-side session.
*
* @author Rossen Stoyanchev
*/
public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTests {
private RestTemplate restTemplate;
private final RestTemplate restTemplate = new RestTemplate();
private DefaultWebSessionManager sessionManager;
private TestWebHandler handler;
@Override
public void setup() throws Exception {
super.setup();
this.restTemplate = new RestTemplate();
}
@Override
protected HttpHandler createHttpHandler() {
this.sessionManager = new DefaultWebSessionManager();

View File

@@ -123,7 +123,7 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
String path = request.getURI().getPath();
if (path.endsWith("write-and-flush")) {
Flux<Publisher<DataBuffer>> responseBody = interval(Duration.ofMillis(50), 2)
Flux<Publisher<DataBuffer>> responseBody = testInterval(Duration.ofMillis(50), 2)
.map(l -> toDataBuffer("data" + l + "\n", response.bufferFactory()))
.map(Flux::just);
return response.writeAndFlushWith(responseBody.concatWith(Flux.never()));

View File

@@ -37,14 +37,18 @@ import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.junit.Assert.assertEquals;
import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
import static org.junit.Assert.*;
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.*;
/**
* @author Sebastien Deleuze
*/
public class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
private final WebClient webClient = WebClient.create();
@Test
public void multipartData() {
Mono<ClientResponse> result = webClient
@@ -87,6 +91,7 @@ public class MultipartIntegrationTests extends AbstractRouterFunctionIntegration
.andRoute(POST("/parts"), multipartHandler::parts);
}
private static class MultipartHandler {
public Mono<ServerResponse> multipartData(ServerRequest request) {

View File

@@ -31,7 +31,6 @@ import org.springframework.web.reactive.function.client.WebClient;
import static org.junit.Assert.*;
import static org.springframework.http.MediaType.*;
import static org.springframework.web.reactive.function.BodyExtractors.*;
import static org.springframework.web.reactive.function.BodyInserters.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.*;
@@ -43,6 +42,12 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn
private WebClient webClient;
@Before
public void setup() throws Exception {
super.setup();
this.webClient = WebClient.create("http://localhost:" + this.port);
}
@Override
protected RouterFunction<?> routerFunction() {
SseHandler sseHandler = new SseHandler();
@@ -51,12 +56,6 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn
.and(route(RequestPredicates.GET("/event"), sseHandler::sse));
}
@Before
public void setup() throws Exception {
super.setup();
this.webClient = WebClient.create("http://localhost:" + this.port);
}
@Test
public void sseAsString() {
@@ -118,8 +117,7 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn
private static class SseHandler {
private static final Flux<Long> INTERVAL = interval(Duration.ofMillis(100), 2);
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(100), 2);
Mono<ServerResponse> string(ServerRequest request) {
return ServerResponse.ok()

View File

@@ -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.
@@ -39,13 +39,12 @@ import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
import org.springframework.web.server.WebHandler;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
/**
* Integration tests with requests mapped via
@@ -66,6 +65,7 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler
.build();
}
@Test
public void testRequestToFooHandler() throws Exception {
URI url = new URI("http://localhost:" + this.port + "/foo");
@@ -115,7 +115,6 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler
@Configuration
@SuppressWarnings({"unused", "WeakerAccess"})
static class WebConfig {
@Bean

View File

@@ -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.result.method.annotation;
import java.net.URI;
@@ -31,9 +32,7 @@ import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
import static org.springframework.http.RequestEntity.get;
import static org.springframework.http.RequestEntity.options;
import static org.springframework.http.RequestEntity.post;
import static org.springframework.http.RequestEntity.*;
/**
* Base class for integration tests with {@code @RequestMapping methods}.

View File

@@ -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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.result.method.annotation;
import org.junit.Test;
@@ -29,7 +30,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.EnableWebFlux;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
/**
* {@code @RequestMapping} integration focusing on controller method parameters.
@@ -42,7 +43,6 @@ import static org.junit.Assert.assertEquals;
*/
public class ControllerInputIntegrationTests extends AbstractRequestMappingIntegrationTests {
@Override
protected ApplicationContext initApplicationContext() {
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
@@ -58,7 +58,7 @@ public class ControllerInputIntegrationTests extends AbstractRequestMappingInteg
assertEquals(expected, performGet("/param?name=George", new HttpHeaders(), String.class).getBody());
}
@Test // SPR-15140
@Test // SPR-15140
public void handleWithEncodedParam() throws Exception {
String expected = "Hello + \u00e0!";
assertEquals(expected, performGet("/param?name=%20%2B+%C3%A0", new HttpHeaders(), String.class).getBody());
@@ -77,6 +77,7 @@ public class ControllerInputIntegrationTests extends AbstractRequestMappingInteg
static class WebConfig {
}
@RestController
@SuppressWarnings("unused")
private static class TestRestController {

View File

@@ -41,9 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.config.EnableWebFlux;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;
/**
* Integration tests with {@code @CrossOrigin} and {@code @RequestMapping}
@@ -105,7 +103,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
ResponseEntity<String> entity = performGet("/default", this.headers, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
assertEquals("default", entity.getBody());
}
@@ -116,7 +114,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
assertEquals(1800, entity.getHeaders().getAccessControlMaxAge());
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
}
@Test
@@ -133,7 +131,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
ResponseEntity<String> entity = performGet("/customized", this.headers, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
assertEquals(-1, entity.getHeaders().getAccessControlMaxAge());
assertEquals("customized", entity.getBody());
}
@@ -152,7 +150,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
entity.getHeaders().getAccessControlAllowHeaders().toArray());
assertArrayEquals(new String[] {"header3", "header4"},
entity.getHeaders().getAccessControlExposeHeaders().toArray());
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
assertEquals(123, entity.getHeaders().getAccessControlMaxAge());
}
@@ -177,19 +175,19 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
ResponseEntity<String> entity = performGet("/foo", this.headers, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
assertEquals("foo", entity.getBody());
entity = performGet("/bar", this.headers, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
assertEquals("bar", entity.getBody());
entity = performGet("/baz", this.headers, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
assertEquals(true, entity.getHeaders().getAccessControlAllowCredentials());
assertTrue(entity.getHeaders().getAccessControlAllowCredentials());
assertEquals("baz", entity.getBody());
}
@@ -205,7 +203,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
entity.getHeaders().getAccessControlAllowMethods().toArray());
assertArrayEquals(new String[] {"header1"},
entity.getHeaders().getAccessControlAllowHeaders().toArray());
assertEquals(true, entity.getHeaders().getAccessControlAllowCredentials());
assertTrue(entity.getHeaders().getAccessControlAllowCredentials());
}
@Test
@@ -217,7 +215,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
assertArrayEquals(new HttpMethod[] {HttpMethod.GET},
entity.getHeaders().getAccessControlAllowMethods().toArray());
assertEquals(true, entity.getHeaders().getAccessControlAllowCredentials());
assertTrue(entity.getHeaders().getAccessControlAllowCredentials());
}
@@ -228,6 +226,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
static class WebConfig {
}
@RestController @SuppressWarnings("unused")
private static class MethodLevelController {
@@ -254,23 +253,23 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
@CrossOrigin
@GetMapping(path = "/ambiguous-header", headers = "header1=a")
public void ambigousHeader1a() {
public void ambiguousHeader1a() {
}
@CrossOrigin
@GetMapping(path = "/ambiguous-header", headers = "header1=b")
public void ambigousHeader1b() {
public void ambiguousHeader1b() {
}
@CrossOrigin
@GetMapping(path = "/ambiguous-produces", produces = "application/xml")
public String ambigousProducesXml() {
public String ambiguousProducesXml() {
return "<a></a>";
}
@CrossOrigin
@GetMapping(path = "/ambiguous-produces", produces = "application/json")
public String ambigousProducesJson() {
public String ambiguousProducesJson() {
return "{}";
}
@@ -299,6 +298,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
}
}
@RestController
@CrossOrigin(allowCredentials = "false")
@SuppressWarnings("unused")

View File

@@ -102,7 +102,7 @@ public class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegra
@GetMapping(value = "/stream",
produces = { APPLICATION_STREAM_JSON_VALUE, "application/stream+x-jackson-smile" })
Flux<Person> person() {
return interval(Duration.ofMillis(100), 50).map(l -> new Person("foo " + l));
return testInterval(Duration.ofMillis(100), 50).map(l -> new Person("foo " + l));
}
}

View File

@@ -73,8 +73,8 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
doTest("/mono-error", "Recovered from error: Argument");
}
@Test // SPR-16051
public void exceptionAfterSeveralItems() throws Exception {
@Test // SPR-16051
public void exceptionAfterSeveralItems() {
try {
performGet("/SPR-16051", new HttpHeaders(), String.class).getBody();
fail();

View File

@@ -86,7 +86,7 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr
@GetMapping("/stream")
public Publisher<Long> stream() {
return interval(Duration.ofMillis(50), 5);
return testInterval(Duration.ofMillis(50), 5);
}
}

View File

@@ -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,8 +43,7 @@ import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.server.ServerWebExchange;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;
/**
* {@code @RequestMapping} integration tests with view resolution scenarios.
@@ -78,10 +77,9 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques
assertNull(response.getBody());
}
@Test // SPR-15291
@Test // SPR-15291
public void redirect() throws Exception {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory() {
@Override
protected void prepareConnection(HttpURLConnection conn, String method) throws IOException {
super.prepareConnection(conn, method);

View File

@@ -57,6 +57,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
private WebClient webClient;
@Override
@Before
public void setup() throws Exception {
@@ -64,7 +65,6 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
this.webClient = WebClient.create("http://localhost:" + this.port + "/sse");
}
@Override
protected HttpHandler createHttpHandler() {
this.wac = new AnnotationConfigApplicationContext();
@@ -177,7 +177,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@RequestMapping("/sse")
static class SseController {
private static final Flux<Long> INTERVAL = interval(Duration.ofMillis(100), 50);
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(100), 50);
private MonoProcessor<Void> cancellation = MonoProcessor.create();

View File

@@ -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.
@@ -39,11 +39,11 @@ import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.result.method.annotation.AbstractRequestMappingIntegrationTests;
import org.springframework.web.server.i18n.LocaleContextResolver;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.i18n.FixedLocaleContextResolver;
import org.springframework.web.server.i18n.LocaleContextResolver;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
/**
* @author Sebastien Deleuze
@@ -52,6 +52,15 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin
private final WebClient webClient = WebClient.create();
@Override
protected ApplicationContext initApplicationContext() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(WebConfig.class);
context.refresh();
return context;
}
@Test
public void fixedLocale() {
Mono<ClientResponse> result = webClient
@@ -67,14 +76,6 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin
.verifyComplete();
}
@Override
protected ApplicationContext initApplicationContext() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(WebConfig.class);
context.refresh();
return context;
}
@Configuration
@ComponentScan(resourcePattern = "**/LocaleContextResolverIntegrationTests*.class")
@@ -111,9 +112,9 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin
return Mono.empty();
}
}
}
@Controller
@SuppressWarnings("unused")
static class TestController {
@@ -122,7 +123,6 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin
public String foo() {
return "foo";
}
}
}