13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
- package org .springframework .web .reactive .result .method .annotation ;
17
16
17
+ package org .springframework .web .reactive .result .method .annotation ;
18
18
19
19
import org .junit .jupiter .api .Test ;
20
20
38
38
*
39
39
* @author Rossen Stoyanchev
40
40
*/
41
- public class ContextPathIntegrationTests {
42
-
41
+ class ContextPathIntegrationTests {
43
42
44
43
@ 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 );
53
47
54
48
HttpHandler webApp1Handler = WebHttpHandlerBuilder .applicationContext (context1 ).build ();
55
49
HttpHandler webApp2Handler = WebHttpHandlerBuilder .applicationContext (context2 ).build ();
@@ -78,10 +72,8 @@ public void multipleWebFluxApps() throws Exception {
78
72
}
79
73
80
74
@ 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 );
85
77
86
78
TomcatHttpServer server = new TomcatHttpServer ();
87
79
server .setContextPath ("/app" );
@@ -94,11 +86,8 @@ public void servletPathMapping() throws Exception {
94
86
server .start ();
95
87
96
88
try {
97
- RestTemplate restTemplate = new RestTemplate ();
98
- String actual ;
99
-
100
89
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 );
102
91
assertThat (actual ).isEqualTo ("Tested in /app/api" );
103
92
}
104
93
finally {
@@ -107,13 +96,12 @@ public void servletPathMapping() throws Exception {
107
96
}
108
97
109
98
110
-
111
99
@ EnableWebFlux
112
100
@ Configuration
113
101
static class WebAppConfig {
114
102
115
103
@ Bean
116
- public TestController testController () {
104
+ TestController testController () {
117
105
return new TestController ();
118
106
}
119
107
}
@@ -123,7 +111,7 @@ public TestController testController() {
123
111
static class TestController {
124
112
125
113
@ GetMapping ("/test" )
126
- public String handle (ServerHttpRequest request ) {
114
+ String handle (ServerHttpRequest request ) {
127
115
return "Tested in " + request .getPath ().contextPath ().value ();
128
116
}
129
117
}
0 commit comments