Move functional web framework to web.reactive.function.server

This commit is contained in:
Arjen Poutsma
2016-12-15 12:15:17 +01:00
parent aa8f531526
commit aac20b3fd1
39 changed files with 115 additions and 76 deletions

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests;
import org.springframework.http.server.reactive.HttpHandler;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.net.InetSocketAddress;
import java.net.URI;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.net.URI;
import java.time.ZonedDateTime;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.util.List;
import java.util.function.Supplier;
@@ -42,15 +42,15 @@ import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.reactive.HandlerAdapter;
import org.springframework.web.reactive.HandlerMapping;
import org.springframework.web.reactive.config.WebReactiveConfigurationSupport;
import org.springframework.web.reactive.function.support.HandlerFunctionAdapter;
import org.springframework.web.reactive.function.support.ServerResponseResultHandler;
import org.springframework.web.reactive.function.server.support.HandlerFunctionAdapter;
import org.springframework.web.reactive.function.server.support.ServerResponseResultHandler;
import org.springframework.web.reactive.result.view.ViewResolver;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
import static org.junit.Assert.assertEquals;
import static org.springframework.http.codec.BodyInserters.fromObject;
import static org.springframework.http.codec.BodyInserters.fromPublisher;
import static org.springframework.web.reactive.function.RouterFunctions.route;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
/**
* Tests the use of {@link HandlerFunction} and {@link RouterFunction} in a

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.util.Collections;
import java.util.List;
@@ -36,7 +36,8 @@ import org.springframework.http.ReactiveHttpOutputMessage;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.codec.HttpMessageWriter;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Arjen Poutsma

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
@@ -30,7 +30,7 @@ import org.junit.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRange;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.support.ServerRequestWrapper;
import org.springframework.web.reactive.function.server.support.ServerRequestWrapper;
import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.mock;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.net.InetSocketAddress;
import java.net.URI;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.io.File;
import java.io.IOException;
@@ -34,9 +34,10 @@ public class PathResourceLookupFunctionTests {
@Test
public void normal() throws Exception {
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/");
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/");
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location);
PathResourceLookupFunction
function = new PathResourceLookupFunction("/resources/**", location);
MockServerRequest request = MockServerRequest.builder()
.uri(new URI("http://localhost/resources/response.txt"))
.build();
@@ -58,14 +59,14 @@ public class PathResourceLookupFunctionTests {
@Test
public void subPath() throws Exception {
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/");
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/");
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location);
MockServerRequest request = MockServerRequest.builder()
.uri(new URI("http://localhost/resources/child/response.txt"))
.build();
Mono<Resource> result = function.apply(request);
File expected = new ClassPathResource("org/springframework/web/reactive/function/child/response.txt").getFile();
File expected = new ClassPathResource("org/springframework/web/reactive/function/server/child/response.txt").getFile();
StepVerifier.create(result)
.expectNextMatches(resource -> {
try {
@@ -81,7 +82,7 @@ public class PathResourceLookupFunctionTests {
@Test
public void notFound() throws Exception {
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/");
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/");
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location);
MockServerRequest request = MockServerRequest.builder()

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.net.URI;
import java.util.List;
@@ -34,9 +34,9 @@ import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertEquals;
import static org.springframework.http.codec.BodyExtractors.toMono;
import static org.springframework.http.codec.BodyInserters.fromPublisher;
import static org.springframework.web.reactive.function.RequestPredicates.GET;
import static org.springframework.web.reactive.function.RequestPredicates.POST;
import static org.springframework.web.reactive.function.RouterFunctions.route;
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
/**
* @author Arjen Poutsma

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import org.junit.Test;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.net.URI;
import java.util.Collections;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.io.IOException;
import java.nio.file.Files;
@@ -35,7 +35,9 @@ import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.adapter.DefaultServerWebExchange;
import org.springframework.web.server.session.MockWebSessionManager;
import static org.junit.Assert.*;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* @author Arjen Poutsma

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import org.junit.Test;
import reactor.core.publisher.Mono;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.util.stream.Stream;
@@ -51,7 +51,8 @@ public class RouterFunctionsTests {
RequestPredicate requestPredicate = mock(RequestPredicate.class);
when(requestPredicate.test(request)).thenReturn(true);
RouterFunction<ServerResponse> result = RouterFunctions.route(requestPredicate, handlerFunction);
RouterFunction<ServerResponse>
result = RouterFunctions.route(requestPredicate, handlerFunction);
assertNotNull(result);
Mono<HandlerFunction<ServerResponse>> resultHandlerFunction = result.route(request);

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function;
package org.springframework.web.reactive.function.server;
import java.time.Duration;
@@ -28,11 +28,11 @@ import org.springframework.http.MediaType;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.http.codec.BodyExtractors;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.web.client.reactive.ClientRequest;
import org.springframework.web.client.reactive.WebClient;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.WebClient;
import static org.springframework.http.codec.BodyInserters.fromServerSentEvents;
import static org.springframework.web.reactive.function.RouterFunctions.route;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
/**
* @author Arjen Poutsma

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.web.reactive.function.support;
package org.springframework.web.reactive.function.server.support;
import java.net.URI;
import java.util.Collections;
@@ -26,7 +26,7 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.http.HttpMethod;
import org.springframework.web.reactive.function.ServerRequest;
import org.springframework.web.reactive.function.server.ServerRequest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;