Avoid accidental usage of JUnit 4 assumptions
This commit also avoids starting a server if an assumption fails.
This commit is contained in:
parent
591995ecc8
commit
5d5f9aceca
|
|
@ -90,8 +90,10 @@ public abstract class AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void stopServer() {
|
void stopServer() {
|
||||||
this.server.stop();
|
if (this.server != null) {
|
||||||
this.port = 0;
|
this.server.stop();
|
||||||
|
this.port = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
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
|
* @author Arjen Poutsma
|
||||||
|
|
@ -51,10 +51,10 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
|
||||||
|
|
||||||
@ParameterizedHttpServerTest
|
@ParameterizedHttpServerTest
|
||||||
public void zeroCopy(HttpServer httpServer) throws Exception {
|
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
|
startServer(httpServer);
|
||||||
assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer);
|
|
||||||
|
|
||||||
URI url = new URI("http://localhost:" + port);
|
URI url = new URI("http://localhost:" + port);
|
||||||
RequestEntity<?> request = RequestEntity.get(url).build();
|
RequestEntity<?> request = RequestEntity.get(url).build();
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ import org.springframework.util.MultiValueMap;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
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.HttpMethod.POST;
|
||||||
import static org.springframework.http.MediaType.MULTIPART_MIXED;
|
import static org.springframework.http.MediaType.MULTIPART_MIXED;
|
||||||
|
|
||||||
|
|
@ -224,10 +224,10 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
|
||||||
|
|
||||||
@ParameterizedRestTemplateTest
|
@ParameterizedRestTemplateTest
|
||||||
void patchForObject(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception {
|
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
|
setUpClient(clientHttpRequestFactory);
|
||||||
assumeFalse(this.clientHttpRequestFactory instanceof SimpleClientHttpRequestFactory);
|
|
||||||
|
|
||||||
String s = template.patchForObject(baseUrl + "/{method}", helloWorld, String.class, "patch");
|
String s = template.patchForObject(baseUrl + "/{method}", helloWorld, String.class, "patch");
|
||||||
assertThat(s).as("Invalid content").isEqualTo(helloWorld);
|
assertThat(s).as("Invalid content").isEqualTo(helloWorld);
|
||||||
|
|
|
||||||
|
|
@ -141,9 +141,9 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
@ParameterizedSseTest
|
@ParameterizedSseTest
|
||||||
void sseAsEvent(HttpServer httpServer, ClientHttpConnector connector) throws Exception {
|
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()
|
Flux<ServerSentEvent<Person>> result = this.webClient.get()
|
||||||
.uri("/event")
|
.uri("/event")
|
||||||
|
|
@ -190,9 +190,9 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
@ParameterizedSseTest // SPR-16494
|
@ParameterizedSseTest // SPR-16494
|
||||||
@Disabled // https://github.com/reactor/reactor-netty/issues/283
|
@Disabled // https://github.com/reactor/reactor-netty/issues/283
|
||||||
void serverDetectsClientDisconnect(HttpServer httpServer, ClientHttpConnector connector) throws Exception {
|
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()
|
Flux<String> result = this.webClient.get()
|
||||||
.uri("/infinite")
|
.uri("/infinite")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue