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 ;
2527import reactor .core .publisher .MonoProcessor ;
2628
2729import org .springframework .http .CacheControl ;
3335import org .springframework .mock .http .client .reactive .MockClientHttpResponse ;
3436
3537import static org .hamcrest .CoreMatchers .*;
36- import static org .junit .Assert .*;
38+ import static org .junit .jupiter . api . Assertions .*;
3739import static org .mockito .Mockito .*;
3840
3941/**
@@ -51,32 +53,11 @@ public void valueEquals() {
5153 headers .add ("foo" , "bar" );
5254 HeaderAssertions assertions = headerAssertions (headers );
5355
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- }
56+ assertDoesNotThrow (() -> assertions .valueEquals ("foo" , "bar" ));
6457
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- }
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" );
8061 }
8162
8263 @ Test
@@ -104,7 +85,6 @@ public void valueEqualsWithMultipeValues() {
10485 catch (AssertionError error ) {
10586 // expected
10687 }
107-
10888 }
10989
11090 @ Test
@@ -263,4 +243,8 @@ private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) {
263243 return new HeaderAssertions (result , mock (WebTestClient .ResponseSpec .class ));
264244 }
265245
246+ public static AssertionError assertThrows (Executable executable , String message ) {
247+ return Assertions .assertThrows (AssertionError .class , executable , message );
248+ }
249+
266250}
0 commit comments