Avoid accidental usage of JUnit 4 assumptions

This commit also avoids starting a server if an assumption fails.
This commit is contained in:
Sam Brannen 2019-09-06 16:03:36 +02:00
parent 591995ecc8
commit 5d5f9aceca
4 changed files with 16 additions and 14 deletions

View File

@ -90,8 +90,10 @@ public abstract class AbstractHttpHandlerIntegrationTests {
@AfterEach
void stopServer() {
this.server.stop();
this.port = 0;
if (this.server != null) {
this.server.stop();
this.port = 0;
}
}

View File

@ -33,7 +33,7 @@ import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer;
import org.springframework.web.client.RestTemplate;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* @author Arjen Poutsma
@ -51,10 +51,10 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
@ParameterizedHttpServerTest
public void zeroCopy(HttpServer httpServer) throws Exception {
startServer(httpServer);
assumeTrue(httpServer instanceof ReactorHttpServer || httpServer instanceof UndertowHttpServer,
"Zero-copy only does not support servlet");
// Zero-copy only does not support servlet
assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer);
startServer(httpServer);
URI url = new URI("http://localhost:" + port);
RequestEntity<?> request = RequestEntity.get(url).build();

View File

@ -57,7 +57,7 @@ import org.springframework.util.MultiValueMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.Assume.assumeFalse;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.MediaType.MULTIPART_MIXED;
@ -224,10 +224,10 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
@ParameterizedRestTemplateTest
void patchForObject(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception {
setUpClient(clientHttpRequestFactory);
assumeFalse(clientHttpRequestFactory instanceof SimpleClientHttpRequestFactory,
"JDK client does not support the PATCH method");
// JDK client does not support the PATCH method
assumeFalse(this.clientHttpRequestFactory instanceof SimpleClientHttpRequestFactory);
setUpClient(clientHttpRequestFactory);
String s = template.patchForObject(baseUrl + "/{method}", helloWorld, String.class, "patch");
assertThat(s).as("Invalid content").isEqualTo(helloWorld);

View File

@ -141,9 +141,9 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@ParameterizedSseTest
void sseAsEvent(HttpServer httpServer, ClientHttpConnector connector) throws Exception {
startServer(httpServer, connector);
assumeTrue(httpServer instanceof JettyHttpServer);
assumeTrue(super.server instanceof JettyHttpServer);
startServer(httpServer, connector);
Flux<ServerSentEvent<Person>> result = this.webClient.get()
.uri("/event")
@ -190,9 +190,9 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@ParameterizedSseTest // SPR-16494
@Disabled // https://github.com/reactor/reactor-netty/issues/283
void serverDetectsClientDisconnect(HttpServer httpServer, ClientHttpConnector connector) throws Exception {
startServer(httpServer, connector);
assumeTrue(httpServer instanceof ReactorHttpServer);
assumeTrue(super.server instanceof ReactorHttpServer);
startServer(httpServer, connector);
Flux<String> result = this.webClient.get()
.uri("/infinite")