PoC: migrate from JUnit 4 to JUnit Jupiter Assertions
This commit is contained in:
parent
8658a357c8
commit
fd352b84b3
|
@ -22,6 +22,8 @@ import java.time.ZonedDateTime;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.function.Executable;
|
||||
import reactor.core.publisher.MonoProcessor;
|
||||
|
||||
import org.springframework.http.CacheControl;
|
||||
|
@ -33,7 +35,7 @@ import org.springframework.mock.http.client.reactive.MockClientHttpRequest;
|
|||
import org.springframework.mock.http.client.reactive.MockClientHttpResponse;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
|
@ -51,32 +53,11 @@ public class HeaderAssertionTests {
|
|||
headers.add("foo", "bar");
|
||||
HeaderAssertions assertions = headerAssertions(headers);
|
||||
|
||||
// Success
|
||||
assertions.valueEquals("foo", "bar");
|
||||
assertDoesNotThrow(() -> assertions.valueEquals("foo", "bar"));
|
||||
|
||||
try {
|
||||
assertions.valueEquals("what?!", "bar");
|
||||
fail("Missing header expected");
|
||||
}
|
||||
catch (AssertionError error) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
assertions.valueEquals("foo", "what?!");
|
||||
fail("Wrong value expected");
|
||||
}
|
||||
catch (AssertionError error) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
assertions.valueEquals("foo", "bar", "what?!");
|
||||
fail("Wrong # of values expected");
|
||||
}
|
||||
catch (AssertionError error) {
|
||||
// expected
|
||||
}
|
||||
assertThrows(() -> assertions.valueEquals("what?!", "bar"), "Missing header expected");
|
||||
assertThrows(() -> assertions.valueEquals("foo", "what?!"), "Wrong value expected");
|
||||
assertThrows(() -> assertions.valueEquals("foo", "bar", "what?!"), "Wrong # of values expected");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -104,7 +85,6 @@ public class HeaderAssertionTests {
|
|||
catch (AssertionError error) {
|
||||
// expected
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -263,4 +243,8 @@ public class HeaderAssertionTests {
|
|||
return new HeaderAssertions(result, mock(WebTestClient.ResponseSpec.class));
|
||||
}
|
||||
|
||||
public static AssertionError assertThrows(Executable executable, String message) {
|
||||
return Assertions.assertThrows(AssertionError.class, executable, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue