22
22
import java .util .concurrent .TimeUnit ;
23
23
24
24
import org .junit .Test ;
25
- import org .junit .jupiter .api .Assertions ;
26
- import org .junit .jupiter .api .function .Executable ;
27
25
import reactor .core .publisher .MonoProcessor ;
28
26
29
27
import org .springframework .http .CacheControl ;
35
33
import org .springframework .mock .http .client .reactive .MockClientHttpResponse ;
36
34
37
35
import static org .hamcrest .CoreMatchers .*;
38
- import static org .junit .jupiter . api . Assertions .*;
36
+ import static org .junit .Assert .*;
39
37
import static org .mockito .Mockito .*;
40
38
41
39
/**
@@ -53,11 +51,32 @@ public void valueEquals() {
53
51
headers .add ("foo" , "bar" );
54
52
HeaderAssertions assertions = headerAssertions (headers );
55
53
56
- assertDoesNotThrow (() -> assertions .valueEquals ("foo" , "bar" ));
54
+ // Success
55
+ assertions .valueEquals ("foo" , "bar" );
56
+
57
+ try {
58
+ assertions .valueEquals ("what?!" , "bar" );
59
+ fail ("Missing header expected" );
60
+ }
61
+ catch (AssertionError error ) {
62
+ // expected
63
+ }
57
64
58
- assertThrows (() -> assertions .valueEquals ("what?!" , "bar" ), "Missing header expected" );
59
- assertThrows (() -> assertions .valueEquals ("foo" , "what?!" ), "Wrong value expected" );
60
- assertThrows (() -> assertions .valueEquals ("foo" , "bar" , "what?!" ), "Wrong # of values expected" );
65
+ try {
66
+ assertions .valueEquals ("foo" , "what?!" );
67
+ fail ("Wrong value expected" );
68
+ }
69
+ catch (AssertionError error ) {
70
+ // expected
71
+ }
72
+
73
+ try {
74
+ assertions .valueEquals ("foo" , "bar" , "what?!" );
75
+ fail ("Wrong # of values expected" );
76
+ }
77
+ catch (AssertionError error ) {
78
+ // expected
79
+ }
61
80
}
62
81
63
82
@ Test
@@ -85,6 +104,7 @@ public void valueEqualsWithMultipeValues() {
85
104
catch (AssertionError error ) {
86
105
// expected
87
106
}
107
+
88
108
}
89
109
90
110
@ Test
@@ -243,8 +263,4 @@ private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) {
243
263
return new HeaderAssertions (result , mock (WebTestClient .ResponseSpec .class ));
244
264
}
245
265
246
- public static AssertionError assertThrows (Executable executable , String message ) {
247
- return Assertions .assertThrows (AssertionError .class , executable , message );
248
- }
249
-
250
266
}
0 commit comments