Skip to content

Commit ef50777

Browse files
committed
Polishing
1 parent d9e3b8b commit ef50777

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.web.reactive.result.method.annotation;
1716

17+
package org.springframework.web.reactive.result.method.annotation;
1818

1919
import org.junit.jupiter.api.Test;
2020

@@ -38,18 +38,12 @@
3838
*
3939
* @author Rossen Stoyanchev
4040
*/
41-
public class ContextPathIntegrationTests {
42-
41+
class ContextPathIntegrationTests {
4342

4443
@Test
45-
public void multipleWebFluxApps() throws Exception {
46-
AnnotationConfigApplicationContext context1 = new AnnotationConfigApplicationContext();
47-
context1.register(WebAppConfig.class);
48-
context1.refresh();
49-
50-
AnnotationConfigApplicationContext context2 = new AnnotationConfigApplicationContext();
51-
context2.register(WebAppConfig.class);
52-
context2.refresh();
44+
void multipleWebFluxApps() throws Exception {
45+
AnnotationConfigApplicationContext context1 = new AnnotationConfigApplicationContext(WebAppConfig.class);
46+
AnnotationConfigApplicationContext context2 = new AnnotationConfigApplicationContext(WebAppConfig.class);
5347

5448
HttpHandler webApp1Handler = WebHttpHandlerBuilder.applicationContext(context1).build();
5549
HttpHandler webApp2Handler = WebHttpHandlerBuilder.applicationContext(context2).build();
@@ -78,10 +72,8 @@ public void multipleWebFluxApps() throws Exception {
7872
}
7973

8074
@Test
81-
public void servletPathMapping() throws Exception {
82-
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
83-
context.register(WebAppConfig.class);
84-
context.refresh();
75+
void servletPathMapping() throws Exception {
76+
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(WebAppConfig.class);
8577

8678
TomcatHttpServer server = new TomcatHttpServer();
8779
server.setContextPath("/app");
@@ -94,11 +86,8 @@ public void servletPathMapping() throws Exception {
9486
server.start();
9587

9688
try {
97-
RestTemplate restTemplate = new RestTemplate();
98-
String actual;
99-
10089
String url = "http://localhost:" + server.getPort() + "/app/api/test";
101-
actual = restTemplate.getForObject(url, String.class);
90+
String actual = new RestTemplate().getForObject(url, String.class);
10291
assertThat(actual).isEqualTo("Tested in /app/api");
10392
}
10493
finally {
@@ -107,13 +96,12 @@ public void servletPathMapping() throws Exception {
10796
}
10897

10998

110-
11199
@EnableWebFlux
112100
@Configuration
113101
static class WebAppConfig {
114102

115103
@Bean
116-
public TestController testController() {
104+
TestController testController() {
117105
return new TestController();
118106
}
119107
}
@@ -123,7 +111,7 @@ public TestController testController() {
123111
static class TestController {
124112

125113
@GetMapping("/test")
126-
public String handle(ServerHttpRequest request) {
114+
String handle(ServerHttpRequest request) {
127115
return "Tested in " + request.getPath().contextPath().value();
128116
}
129117
}

0 commit comments

Comments
 (0)