Skip to content

Commit c450f8d

Browse files
committed
Revert "PoC: migrate from JUnit 4 to JUnit Jupiter Assertions"
This reverts commit fd352b8, and the PoC will be moved to a feature branch.
1 parent fd352b8 commit c450f8d

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

spring-test/src/test/java/org/springframework/test/web/reactive/server/HeaderAssertionTests.java

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import java.util.concurrent.TimeUnit;
2323

2424
import org.junit.Test;
25-
import org.junit.jupiter.api.Assertions;
26-
import org.junit.jupiter.api.function.Executable;
2725
import reactor.core.publisher.MonoProcessor;
2826

2927
import org.springframework.http.CacheControl;
@@ -35,7 +33,7 @@
3533
import org.springframework.mock.http.client.reactive.MockClientHttpResponse;
3634

3735
import static org.hamcrest.CoreMatchers.*;
38-
import static org.junit.jupiter.api.Assertions.*;
36+
import static org.junit.Assert.*;
3937
import 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

Comments
 (0)