40
40
import org .springframework .http .HttpStatus ;
41
41
import org .springframework .http .MediaType ;
42
42
import org .springframework .stereotype .Controller ;
43
- import org .springframework .test .context .junit .jupiter .SpringJUnitConfig ;
44
- import org .springframework .test .context .web .WebAppConfiguration ;
43
+ import org .springframework .test .context .junit .jupiter .web .SpringJUnitWebConfig ;
45
44
import org .springframework .test .web .Person ;
46
45
import org .springframework .test .web .servlet .ResultMatcher ;
47
46
import org .springframework .ui .Model ;
72
71
* @author Brian Clozel
73
72
* @author Stephane Nicoll
74
73
*/
75
- @ SpringJUnitConfig
76
- @ WebAppConfiguration
74
+ @ SpringJUnitWebConfig
77
75
public class MockMvcTesterIntegrationTests {
78
76
79
77
private final MockMvcTester mvc ;
@@ -148,7 +146,6 @@ void statusOk() {
148
146
void statusSeries () {
149
147
assertThat (mvc .get ().uri ("/greet" )).hasStatus2xxSuccessful ();
150
148
}
151
-
152
149
}
153
150
154
151
@ Nested
@@ -169,7 +166,6 @@ private Consumer<HttpHeaders> textContent(String charset) {
169
166
return headers -> assertThat (headers ).containsEntry (
170
167
"Content-Type" , List .of ("text/plain;charset=%s" .formatted (charset )));
171
168
}
172
-
173
169
}
174
170
175
171
@ Nested
@@ -205,7 +201,6 @@ void hasAttributeErrors() {
205
201
void hasAttributeErrorsCount () {
206
202
assertThat (mvc .post ().uri ("/persons" )).model ().extractingBindingResult ("person" ).hasErrorsCount (1 );
207
203
}
208
-
209
204
}
210
205
211
206
@ Nested
@@ -252,7 +247,6 @@ void jsonContentUsingResourceLoaderClass() {
252
247
assertThat (mvc .get ().uri ("/message" )).bodyJson ().withResourceLoadClass (MockMvcTesterIntegrationTests .class )
253
248
.isLenientlyEqualTo ("message.json" );
254
249
}
255
-
256
250
}
257
251
258
252
@ Nested
@@ -278,7 +272,6 @@ void isInvokedOn() {
278
272
assertThat (mvc .get ().uri ("/callable" )).handler ()
279
273
.isInvokedOn (AsyncController .class , AsyncController ::getCallable );
280
274
}
281
-
282
275
}
283
276
284
277
@ Nested
@@ -411,7 +404,6 @@ private void testAssertionFailureWithUnresolvableException(Consumer<MvcTestResul
411
404
ServletException .class .getName (), IllegalStateException .class .getName (),
412
405
"Expected" );
413
406
}
414
-
415
407
}
416
408
417
409
@ Test
@@ -446,8 +438,7 @@ void resultMatcherFailsWithDedicatedException() {
446
438
ResultMatcher matcher = result -> assertThat (result .getResponse ().getStatus ())
447
439
.isEqualTo (HttpStatus .NOT_FOUND .value ());
448
440
assertThatExceptionOfType (AssertionError .class )
449
- .isThrownBy (() -> assertThat (mvc .get ().uri ("/greet" ))
450
- .matches (matcher ))
441
+ .isThrownBy (() -> assertThat (mvc .get ().uri ("/greet" )).matches (matcher ))
451
442
.withMessageContaining ("expected: 404" ).withMessageContaining (" but was: 200" );
452
443
}
453
444
0 commit comments