Polishing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -34,13 +34,15 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
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 {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
@@ -75,6 +77,7 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
private static class ErrorHandler implements HttpHandler {
|
||||
|
||||
@Override
|
||||
@@ -93,6 +96,7 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new ResponseErrorHandler() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -41,10 +41,14 @@ 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) {
|
||||
|
||||
@@ -42,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();
|
||||
@@ -50,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() {
|
||||
|
||||
@@ -93,4 +93,4 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -299,6 +298,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(allowCredentials = "false")
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@@ -43,11 +43,19 @@ import org.springframework.web.reactive.protobuf.SecondMsg;
|
||||
*/
|
||||
public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationTests {
|
||||
|
||||
public static final Msg TEST_MSG = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
|
||||
public static final Msg TEST_MSG =
|
||||
Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
|
||||
|
||||
private WebClient webClient;
|
||||
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
super.setup();
|
||||
this.webClient = WebClient.create("http://localhost:" + this.port);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ApplicationContext initApplicationContext() {
|
||||
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
|
||||
@@ -56,12 +64,6 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
|
||||
return wac;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
super.setup();
|
||||
this.webClient = WebClient.create("http://localhost:" + this.port);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void value() {
|
||||
@@ -140,6 +142,7 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
|
||||
@RestController
|
||||
@SuppressWarnings("unused")
|
||||
static class ProtobufController {
|
||||
@@ -156,7 +159,8 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
|
||||
|
||||
@GetMapping(value = "/message-stream", produces = "application/x-protobuf;delimited=true")
|
||||
Flux<Msg> messageStream() {
|
||||
return testInterval(Duration.ofMillis(50), 5).map(l -> Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(l.intValue()).build()).build());
|
||||
return testInterval(Duration.ofMillis(50), 5).map(l ->
|
||||
Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(l.intValue()).build()).build());
|
||||
}
|
||||
|
||||
@GetMapping("/empty")
|
||||
@@ -168,13 +172,14 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
|
||||
Mono<Msg> defaultInstance() {
|
||||
return Mono.just(Msg.getDefaultInstance());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableWebFlux
|
||||
@ComponentScan(resourcePattern = "**/ProtobufIntegrationTests*.class")
|
||||
@SuppressWarnings("unused")
|
||||
static class TestConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
|
||||
doTest("/mono-error", "Recovered from error: Argument");
|
||||
}
|
||||
|
||||
@Test // SPR-16051
|
||||
@Test // SPR-16051
|
||||
public void exceptionAfterSeveralItems() {
|
||||
try {
|
||||
performGet("/SPR-16051", new HttpHeaders(), String.class).getBody();
|
||||
@@ -89,7 +89,7 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
|
||||
}
|
||||
}
|
||||
|
||||
@Test // SPR-16318
|
||||
@Test // SPR-16318
|
||||
public void exceptionFromMethodWithProducesCondition() throws Exception {
|
||||
try {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -178,7 +178,9 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static class Spr16318Exception extends Exception {}
|
||||
private static class Spr16318Exception extends Exception {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -81,6 +81,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@@ -92,7 +93,6 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected HttpHandler createHttpHandler() {
|
||||
this.wac = new AnnotationConfigApplicationContext();
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user