Skip to content

Commit

Permalink
Revert "PoC: migrate from JUnit 4 to JUnit Jupiter Assertions"
Browse files Browse the repository at this point in the history
This reverts commit fd352b8, and the
PoC will be moved to a feature branch.
  • Loading branch information
sbrannen committed Sep 6, 2018
1 parent fd352b8 commit c450f8d
Showing 1 changed file with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
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;
Expand All @@ -35,7 +33,7 @@
import org.springframework.mock.http.client.reactive.MockClientHttpResponse;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

/**
Expand All @@ -53,11 +51,32 @@ public void valueEquals() {
headers.add("foo", "bar");
HeaderAssertions assertions = headerAssertions(headers);

assertDoesNotThrow(() -> assertions.valueEquals("foo", "bar"));
// Success
assertions.valueEquals("foo", "bar");

try {
assertions.valueEquals("what?!", "bar");
fail("Missing header 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");
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
}
}

@Test
Expand Down Expand Up @@ -85,6 +104,7 @@ public void valueEqualsWithMultipeValues() {
catch (AssertionError error) {
// expected
}

}

@Test
Expand Down Expand Up @@ -243,8 +263,4 @@ private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) {
return new HeaderAssertions(result, mock(WebTestClient.ResponseSpec.class));
}

public static AssertionError assertThrows(Executable executable, String message) {
return Assertions.assertThrows(AssertionError.class, executable, message);
}

}

0 comments on commit c450f8d

Please sign in to comment.