1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -91,14 +91,14 @@ public class RequestMappingInfoHandlerMappingTests {
91
91
92
92
93
93
@ Before
94
- public void setup () throws Exception {
94
+ public void setup () {
95
95
this .handlerMapping = new TestRequestMappingInfoHandlerMapping ();
96
96
this .handlerMapping .registerHandler (new TestController ());
97
97
}
98
98
99
99
100
100
@ Test
101
- public void getHandlerDirectMatch () throws Exception {
101
+ public void getHandlerDirectMatch () {
102
102
Method expected = on (TestController .class ).annot (getMapping ("/foo" ).params ()).resolveMethod ();
103
103
ServerWebExchange exchange = MockServerWebExchange .from (get ("/foo" ));
104
104
HandlerMethod hm = (HandlerMethod ) this .handlerMapping .getHandler (exchange ).block ();
@@ -107,7 +107,7 @@ public void getHandlerDirectMatch() throws Exception {
107
107
}
108
108
109
109
@ Test
110
- public void getHandlerGlobMatch () throws Exception {
110
+ public void getHandlerGlobMatch () {
111
111
Method expected = on (TestController .class ).annot (requestMapping ("/ba*" ).method (GET , HEAD )).resolveMethod ();
112
112
ServerWebExchange exchange = MockServerWebExchange .from (get ("/bar" ));
113
113
HandlerMethod hm = (HandlerMethod ) this .handlerMapping .getHandler (exchange ).block ();
@@ -116,7 +116,7 @@ public void getHandlerGlobMatch() throws Exception {
116
116
}
117
117
118
118
@ Test
119
- public void getHandlerEmptyPathMatch () throws Exception {
119
+ public void getHandlerEmptyPathMatch () {
120
120
Method expected = on (TestController .class ).annot (requestMapping ("" )).resolveMethod ();
121
121
ServerWebExchange exchange = MockServerWebExchange .from (get ("" ));
122
122
HandlerMethod hm = (HandlerMethod ) this .handlerMapping .getHandler (exchange ).block ();
@@ -128,7 +128,7 @@ public void getHandlerEmptyPathMatch() throws Exception {
128
128
}
129
129
130
130
@ Test
131
- public void getHandlerBestMatch () throws Exception {
131
+ public void getHandlerBestMatch () {
132
132
Method expected = on (TestController .class ).annot (getMapping ("/foo" ).params ("p" )).resolveMethod ();
133
133
ServerWebExchange exchange = MockServerWebExchange .from (get ("/foo?p=anything" ));
134
134
HandlerMethod hm = (HandlerMethod ) this .handlerMapping .getHandler (exchange ).block ();
@@ -137,7 +137,7 @@ public void getHandlerBestMatch() throws Exception {
137
137
}
138
138
139
139
@ Test
140
- public void getHandlerRequestMethodNotAllowed () throws Exception {
140
+ public void getHandlerRequestMethodNotAllowed () {
141
141
ServerWebExchange exchange = MockServerWebExchange .from (post ("/bar" ));
142
142
Mono <Object > mono = this .handlerMapping .getHandler (exchange );
143
143
@@ -146,7 +146,7 @@ public void getHandlerRequestMethodNotAllowed() throws Exception {
146
146
}
147
147
148
148
@ Test // SPR-9603
149
- public void getHandlerRequestMethodMatchFalsePositive () throws Exception {
149
+ public void getHandlerRequestMethodMatchFalsePositive () {
150
150
ServerWebExchange exchange = MockServerWebExchange .from (get ("/users" ).accept (MediaType .APPLICATION_XML ));
151
151
this .handlerMapping .registerHandler (new UserController ());
152
152
Mono <Object > mono = this .handlerMapping .getHandler (exchange );
@@ -157,14 +157,14 @@ public void getHandlerRequestMethodMatchFalsePositive() throws Exception {
157
157
}
158
158
159
159
@ Test // SPR-8462
160
- public void getHandlerMediaTypeNotSupported () throws Exception {
160
+ public void getHandlerMediaTypeNotSupported () {
161
161
testHttpMediaTypeNotSupportedException ("/person/1" );
162
162
testHttpMediaTypeNotSupportedException ("/person/1/" );
163
163
testHttpMediaTypeNotSupportedException ("/person/1.json" );
164
164
}
165
165
166
166
@ Test
167
- public void getHandlerTestInvalidContentType () throws Exception {
167
+ public void getHandlerTestInvalidContentType () {
168
168
MockServerHttpRequest request = put ("/person/1" ).header ("content-type" , "bogus" ).build ();
169
169
ServerWebExchange exchange = MockServerWebExchange .from (request );
170
170
Mono <Object > mono = this .handlerMapping .getHandler (exchange );
@@ -175,13 +175,13 @@ public void getHandlerTestInvalidContentType() throws Exception {
175
175
}
176
176
177
177
@ Test // SPR-8462
178
- public void getHandlerTestMediaTypeNotAcceptable () throws Exception {
178
+ public void getHandlerTestMediaTypeNotAcceptable () {
179
179
testMediaTypeNotAcceptable ("/persons" );
180
180
testMediaTypeNotAcceptable ("/persons/" );
181
181
}
182
182
183
183
@ Test // SPR-12854
184
- public void getHandlerTestRequestParamMismatch () throws Exception {
184
+ public void getHandlerTestRequestParamMismatch () {
185
185
ServerWebExchange exchange = MockServerWebExchange .from (get ("/params" ));
186
186
Mono <Object > mono = this .handlerMapping .getHandler (exchange );
187
187
assertError (mono , ServerWebInputException .class , ex -> {
@@ -191,7 +191,7 @@ public void getHandlerTestRequestParamMismatch() throws Exception {
191
191
}
192
192
193
193
@ Test
194
- public void getHandlerHttpOptions () throws Exception {
194
+ public void getHandlerHttpOptions () {
195
195
List <HttpMethod > allMethodExceptTrace = new ArrayList <>(Arrays .asList (HttpMethod .values ()));
196
196
allMethodExceptTrace .remove (HttpMethod .TRACE );
197
197
@@ -202,7 +202,7 @@ public void getHandlerHttpOptions() throws Exception {
202
202
}
203
203
204
204
@ Test
205
- public void getHandlerProducibleMediaTypesAttribute () throws Exception {
205
+ public void getHandlerProducibleMediaTypesAttribute () {
206
206
ServerWebExchange exchange = MockServerWebExchange .from (get ("/content" ).accept (MediaType .APPLICATION_XML ));
207
207
this .handlerMapping .getHandler (exchange ).block ();
208
208
@@ -218,7 +218,7 @@ public void getHandlerProducibleMediaTypesAttribute() throws Exception {
218
218
219
219
@ Test
220
220
@ SuppressWarnings ("unchecked" )
221
- public void handleMatchUriTemplateVariables () throws Exception {
221
+ public void handleMatchUriTemplateVariables () {
222
222
ServerWebExchange exchange = MockServerWebExchange .from (get ("/1/2" ));
223
223
224
224
RequestMappingInfo key = paths ("/{path1}/{path2}" ).build ();
@@ -233,7 +233,7 @@ public void handleMatchUriTemplateVariables() throws Exception {
233
233
}
234
234
235
235
@ Test // SPR-9098
236
- public void handleMatchUriTemplateVariablesDecode () throws Exception {
236
+ public void handleMatchUriTemplateVariablesDecode () {
237
237
RequestMappingInfo key = paths ("/{group}/{identifier}" ).build ();
238
238
URI url = URI .create ("/group/a%2Fb" );
239
239
ServerWebExchange exchange = MockServerWebExchange .from (method (HttpMethod .GET , url ));
@@ -250,7 +250,7 @@ public void handleMatchUriTemplateVariablesDecode() throws Exception {
250
250
}
251
251
252
252
@ Test
253
- public void handleMatchBestMatchingPatternAttribute () throws Exception {
253
+ public void handleMatchBestMatchingPatternAttribute () {
254
254
RequestMappingInfo key = paths ("/{path1}/2" , "/**" ).build ();
255
255
ServerWebExchange exchange = MockServerWebExchange .from (get ("/1/2" ));
256
256
this .handlerMapping .handleMatch (key , handlerMethod , exchange );
@@ -263,7 +263,7 @@ public void handleMatchBestMatchingPatternAttribute() throws Exception {
263
263
}
264
264
265
265
@ Test
266
- public void handleMatchBestMatchingPatternAttributeNoPatternsDefined () throws Exception {
266
+ public void handleMatchBestMatchingPatternAttributeNoPatternsDefined () {
267
267
RequestMappingInfo key = paths ().build ();
268
268
ServerWebExchange exchange = MockServerWebExchange .from (get ("/1/2" ));
269
269
this .handlerMapping .handleMatch (key , handlerMethod , exchange );
@@ -273,7 +273,7 @@ public void handleMatchBestMatchingPatternAttributeNoPatternsDefined() throws Ex
273
273
}
274
274
275
275
@ Test
276
- public void handleMatchMatrixVariables () throws Exception {
276
+ public void handleMatchMatrixVariables () {
277
277
MultiValueMap <String , String > matrixVariables ;
278
278
Map <String , String > uriVariables ;
279
279
@@ -290,17 +290,17 @@ public void handleMatchMatrixVariables() throws Exception {
290
290
}
291
291
292
292
@ Test
293
- public void handleMatchMatrixVariablesDecoding () throws Exception {
294
- MockServerHttpRequest request = method (HttpMethod .GET , URI .create ("/path ;mvar=a%2fb " )).build ();
293
+ public void handleMatchMatrixVariablesDecoding () {
294
+ MockServerHttpRequest request = method (HttpMethod .GET , URI .create ("/cars ;mvar=a%2Fb " )).build ();
295
295
ServerWebExchange exchange = MockServerWebExchange .from (request );
296
- handleMatch (exchange , "/{filter }" );
296
+ handleMatch (exchange , "/{cars }" );
297
297
298
- MultiValueMap <String , String > matrixVariables = getMatrixVariables (exchange , "filter " );
298
+ MultiValueMap <String , String > matrixVariables = getMatrixVariables (exchange , "cars " );
299
299
Map <String , String > uriVariables = getUriTemplateVariables (exchange );
300
300
301
301
assertNotNull (matrixVariables );
302
302
assertEquals (Collections .singletonList ("a/b" ), matrixVariables .get ("mvar" ));
303
- assertEquals ("path " , uriVariables .get ("filter " ));
303
+ assertEquals ("cars " , uriVariables .get ("cars " ));
304
304
}
305
305
306
306
@@ -314,7 +314,7 @@ private <T> void assertError(Mono<Object> mono, final Class<T> exceptionClass, f
314
314
.verify ();
315
315
}
316
316
317
- private void testHttpMediaTypeNotSupportedException (String url ) throws Exception {
317
+ private void testHttpMediaTypeNotSupportedException (String url ) {
318
318
MockServerHttpRequest request = put (url ).contentType (MediaType .APPLICATION_JSON ).build ();
319
319
ServerWebExchange exchange = MockServerWebExchange .from (request );
320
320
Mono <Object > mono = this .handlerMapping .getHandler (exchange );
@@ -325,7 +325,7 @@ private void testHttpMediaTypeNotSupportedException(String url) throws Exception
325
325
ex .getSupportedMediaTypes ()));
326
326
}
327
327
328
- private void testHttpOptions (String requestURI , Set <HttpMethod > allowedMethods ) throws Exception {
328
+ private void testHttpOptions (String requestURI , Set <HttpMethod > allowedMethods ) {
329
329
ServerWebExchange exchange = MockServerWebExchange .from (MockServerHttpRequest .options (requestURI ));
330
330
HandlerMethod handlerMethod = (HandlerMethod ) this .handlerMapping .getHandler (exchange ).block ();
331
331
@@ -342,7 +342,7 @@ private void testHttpOptions(String requestURI, Set<HttpMethod> allowedMethods)
342
342
assertEquals (allowedMethods , ((HttpHeaders ) value ).getAllow ());
343
343
}
344
344
345
- private void testMediaTypeNotAcceptable (String url ) throws Exception {
345
+ private void testMediaTypeNotAcceptable (String url ) {
346
346
ServerWebExchange exchange = MockServerWebExchange .from (get (url ).accept (MediaType .APPLICATION_JSON ));
347
347
Mono <Object > mono = this .handlerMapping .getHandler (exchange );
348
348
0 commit comments