use JUnit
@@ -6,7 +6,9 @@ import javax.net.ssl.SSLException;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -35,6 +37,9 @@ public class TimeoutLiveTest {
private WebTestClient webTestClient;
+ @Rule
+ public ExpectedException exception = ExpectedException.none();
+
@Before
public void setup() throws SSLException {
webTestClient = WebTestClient.bindToServer(getConnector())
@@ -44,18 +49,15 @@ public class TimeoutLiveTest {
@Test
public void shouldTimeout() {
- try {
+ exception.expect(ReadTimeoutException.class);
webTestClient.get()
.uri("/timeout/{timeout}", 3)
.exchange();
Assert.fail();
- } catch (ReadTimeoutException ignore) {
- }
}
@Test
public void shouldNotTimeout() {
- try {
WebTestClient.ResponseSpec response = webTestClient.get()
.uri("/timeout/{timeout}", 1)
.exchange();
@@ -63,9 +65,6 @@ public class TimeoutLiveTest {
.isOk()
.expectBody(String.class)
.isEqualTo("OK");
- } catch (ReadTimeoutException e) {
- Assert.fail();
- }
}
private ReactorClientHttpConnector getConnector() throws SSLException {
