2222import java .util .concurrent .TimeUnit ;
2323
2424import org .junit .Test ;
25- import org .junit .jupiter .api .Assertions ;
26- import org .junit .jupiter .api .function .Executable ;
2725import reactor .core .publisher .MonoProcessor ;
2826
2927import org .springframework .http .CacheControl ;
3533import org .springframework .mock .http .client .reactive .MockClientHttpResponse ;
3634
3735import static org .hamcrest .CoreMatchers .*;
38- import static org .junit .jupiter . api . Assertions .*;
36+ import static org .junit .Assert .*;
3937import static org .mockito .Mockito .*;
4038
4139/**
@@ -53,11 +51,32 @@ public void valueEquals() {
5351 headers .add ("foo" , "bar" );
5452 HeaderAssertions assertions = headerAssertions (headers );
5553
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+ }
5764
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+ }
6180 }
6281
6382 @ Test
@@ -85,6 +104,7 @@ public void valueEqualsWithMultipeValues() {
85104 catch (AssertionError error ) {
86105 // expected
87106 }
107+
88108 }
89109
90110 @ Test
@@ -243,8 +263,4 @@ private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) {
243263 return new HeaderAssertions (result , mock (WebTestClient .ResponseSpec .class ));
244264 }
245265
246- public static AssertionError assertThrows (Executable executable , String message ) {
247- return Assertions .assertThrows (AssertionError .class , executable , message );
248- }
249-
250266}
0 commit comments