Skip to content

Commit 2042cb6

Browse files
committed
Merge two DispatcherHandlerIntegrationTests
1 parent 9e30615 commit 2042cb6

File tree

2 files changed

+23
-100
lines changed

2 files changed

+23
-100
lines changed

spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
2828
import org.springframework.core.ParameterizedTypeReference;
2929
import org.springframework.http.HttpMethod;
3030
import org.springframework.http.HttpStatus;
31+
import org.springframework.http.MediaType;
3132
import org.springframework.http.ResponseEntity;
3233
import org.springframework.http.server.reactive.HttpHandler;
3334
import org.springframework.stereotype.Controller;
@@ -44,6 +45,7 @@
4445

4546
import static org.assertj.core.api.Assertions.assertThat;
4647
import static org.springframework.web.reactive.function.BodyInserters.fromPublisher;
48+
import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
4749
import static org.springframework.web.reactive.function.server.RouterFunctions.nest;
4850
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
4951

@@ -122,6 +124,15 @@ void attributes(HttpServer httpServer) throws Exception {
122124
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
123125
}
124126

127+
@ParameterizedHttpServerTest
128+
void nested(HttpServer httpServer) throws Exception {
129+
startServer(httpServer);
130+
131+
ResponseEntity<String> result = this.restTemplate
132+
.getForEntity("http://localhost:" + this.port + "/foo/bar", String.class);
133+
134+
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
135+
}
125136

126137
@EnableWebFlux
127138
@Configuration
@@ -157,6 +168,17 @@ public RouterFunction<ServerResponse> attributesRouterFunction(AttributesHandler
157168
return nest(RequestPredicates.GET("/attributes"),
158169
route(RequestPredicates.GET("/{foo}"), attributesHandler::attributes));
159170
}
171+
172+
@Bean
173+
public RouterFunction<ServerResponse> nested() {
174+
return route()
175+
.path("/foo", () -> route()
176+
.nest(accept(MediaType.APPLICATION_JSON), builder -> builder
177+
.GET("/bar", request -> ServerResponse.ok().build()))
178+
.build())
179+
.build();
180+
}
181+
160182
}
161183

162184

spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)