File tree 2 files changed +10
-13
lines changed
main/java/org/springframework/test/web/servlet/result
test/java/org/springframework/test/web/servlet/result 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -492,6 +492,14 @@ public ResultMatcher isFailedDependency() {
492
492
return matcher (HttpStatus .FAILED_DEPENDENCY );
493
493
}
494
494
495
+ /**
496
+ * Assert the response status code is {@code HttpStatus.TOO_EARLY} (425).
497
+ * @since 5.2
498
+ */
499
+ public ResultMatcher isTooEarly () {
500
+ return matcher (HttpStatus .valueOf (425 ));
501
+ }
502
+
495
503
/**
496
504
* Assert the response status code is {@code HttpStatus.UPGRADE_REQUIRED} (426).
497
505
*/
Original file line number Diff line number Diff line change 20
20
import java .util .ArrayList ;
21
21
import java .util .List ;
22
22
23
- import org .junit .Before ;
24
23
import org .junit .Test ;
25
24
26
25
import org .springframework .core .Conventions ;
42
41
*/
43
42
public class StatusResultMatchersTests {
44
43
45
- private StatusResultMatchers matchers ;
44
+ private final StatusResultMatchers matchers = new StatusResultMatchers () ;
46
45
47
- private MockHttpServletRequest request ;
48
-
49
-
50
- @ Before
51
- public void setup () {
52
- this .matchers = new StatusResultMatchers ();
53
- this .request = new MockHttpServletRequest ();
54
- }
46
+ private final MockHttpServletRequest request = new MockHttpServletRequest ();
55
47
56
48
57
49
@ Test
58
50
public void testHttpStatusCodeResultMatchers () throws Exception {
59
-
60
51
List <AssertionError > failures = new ArrayList <>();
61
-
62
52
for (HttpStatus status : HttpStatus .values ()) {
63
53
MockHttpServletResponse response = new MockHttpServletResponse ();
64
54
response .setStatus (status .value ());
@@ -77,7 +67,6 @@ public void testHttpStatusCodeResultMatchers() throws Exception {
77
67
throw new Exception ("Failed to obtain ResultMatcher for status " + status , ex );
78
68
}
79
69
}
80
-
81
70
if (!failures .isEmpty ()) {
82
71
fail ("Failed status codes: " + failures );
83
72
}
You can’t perform that action at this time.
0 commit comments