Use Named arguments in parameterized tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,7 +96,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
void bodyToMonoVoid(String displayName, DataBufferFactory bufferFactory) {
|
||||
void bodyToMonoVoid(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
this.server.enqueue(new MockResponse()
|
||||
@@ -114,7 +114,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest // SPR-17482
|
||||
void bodyToMonoVoidWithoutContentType(String displayName, DataBufferFactory bufferFactory) {
|
||||
void bodyToMonoVoidWithoutContentType(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
this.server.enqueue(new MockResponse()
|
||||
@@ -131,7 +131,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
void onStatusWithBodyNotConsumed(String displayName, DataBufferFactory bufferFactory) {
|
||||
void onStatusWithBodyNotConsumed(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
RuntimeException ex = new RuntimeException("response error");
|
||||
@@ -139,7 +139,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
void onStatusWithBodyConsumed(String displayName, DataBufferFactory bufferFactory) {
|
||||
void onStatusWithBodyConsumed(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
RuntimeException ex = new RuntimeException("response error");
|
||||
@@ -147,7 +147,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest // SPR-17473
|
||||
void onStatusWithMonoErrorAndBodyNotConsumed(String displayName, DataBufferFactory bufferFactory) {
|
||||
void onStatusWithMonoErrorAndBodyNotConsumed(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
RuntimeException ex = new RuntimeException("response error");
|
||||
@@ -155,7 +155,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
void onStatusWithMonoErrorAndBodyConsumed(String displayName, DataBufferFactory bufferFactory) {
|
||||
void onStatusWithMonoErrorAndBodyConsumed(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
RuntimeException ex = new RuntimeException("response error");
|
||||
@@ -163,7 +163,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest // gh-23230
|
||||
void onStatusWithImmediateErrorAndBodyNotConsumed(String displayName, DataBufferFactory bufferFactory) {
|
||||
void onStatusWithImmediateErrorAndBodyNotConsumed(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
RuntimeException ex = new RuntimeException("response error");
|
||||
@@ -173,7 +173,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
void releaseBody(String displayName, DataBufferFactory bufferFactory) {
|
||||
void releaseBody(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
this.server.enqueue(new MockResponse()
|
||||
@@ -190,7 +190,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
void exchangeToBodilessEntity(String displayName, DataBufferFactory bufferFactory) {
|
||||
void exchangeToBodilessEntity(DataBufferFactory bufferFactory) {
|
||||
setUp(bufferFactory);
|
||||
|
||||
this.server.enqueue(new MockResponse()
|
||||
|
||||
@@ -43,6 +43,7 @@ import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Named;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
@@ -89,16 +90,16 @@ class WebClientIntegrationTests {
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@ParameterizedTest(name = "[{index}] {displayName} [{0}]")
|
||||
@ParameterizedTest(name = "[{index}] {0}")
|
||||
@MethodSource("arguments")
|
||||
@interface ParameterizedWebClientTest {
|
||||
}
|
||||
|
||||
static Stream<ClientHttpConnector> arguments() {
|
||||
static Stream<Named<ClientHttpConnector>> arguments() {
|
||||
return Stream.of(
|
||||
new ReactorClientHttpConnector(),
|
||||
new JettyClientHttpConnector(),
|
||||
new HttpComponentsClientHttpConnector()
|
||||
Named.named("Reactor Netty", new ReactorClientHttpConnector()),
|
||||
Named.named("Jetty", new JettyClientHttpConnector()),
|
||||
Named.named("HttpComponents", new HttpComponentsClientHttpConnector())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,9 +21,11 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.time.Duration;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -56,6 +58,7 @@ import org.springframework.web.testfixture.http.server.reactive.bootstrap.Undert
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
import static org.junit.jupiter.api.Named.named;
|
||||
import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
|
||||
|
||||
/**
|
||||
@@ -64,31 +67,6 @@ import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
|
||||
*/
|
||||
class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@ParameterizedTest(name = "[{index}] server [{0}], webClient [{1}]")
|
||||
@MethodSource("arguments")
|
||||
protected @interface ParameterizedSseTest {
|
||||
}
|
||||
|
||||
static Object[][] arguments() {
|
||||
return new Object[][] {
|
||||
{new JettyHttpServer(), new ReactorClientHttpConnector()},
|
||||
{new JettyHttpServer(), new JettyClientHttpConnector()},
|
||||
{new JettyHttpServer(), new HttpComponentsClientHttpConnector()},
|
||||
{new ReactorHttpServer(), new ReactorClientHttpConnector()},
|
||||
{new ReactorHttpServer(), new JettyClientHttpConnector()},
|
||||
{new ReactorHttpServer(), new HttpComponentsClientHttpConnector()},
|
||||
{new TomcatHttpServer(), new ReactorClientHttpConnector()},
|
||||
{new TomcatHttpServer(), new JettyClientHttpConnector()},
|
||||
{new TomcatHttpServer(), new HttpComponentsClientHttpConnector()},
|
||||
{new UndertowHttpServer(), new ReactorClientHttpConnector()},
|
||||
{new UndertowHttpServer(), new JettyClientHttpConnector()},
|
||||
{new UndertowHttpServer(), new HttpComponentsClientHttpConnector()}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private AnnotationConfigApplicationContext wac;
|
||||
|
||||
private WebClient webClient;
|
||||
@@ -312,4 +290,35 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@ParameterizedTest(name = "[{index}] server = {0}, webClient = {1}")
|
||||
@MethodSource("arguments")
|
||||
private @interface ParameterizedSseTest {
|
||||
}
|
||||
|
||||
static Stream<Arguments> arguments() {
|
||||
return Stream.of(
|
||||
args(new JettyHttpServer(), new ReactorClientHttpConnector()),
|
||||
args(new JettyHttpServer(), new JettyClientHttpConnector()),
|
||||
args(new JettyHttpServer(), new HttpComponentsClientHttpConnector()),
|
||||
args(new ReactorHttpServer(), new ReactorClientHttpConnector()),
|
||||
args(new ReactorHttpServer(), new JettyClientHttpConnector()),
|
||||
args(new ReactorHttpServer(), new HttpComponentsClientHttpConnector()),
|
||||
args(new TomcatHttpServer(), new ReactorClientHttpConnector()),
|
||||
args(new TomcatHttpServer(), new JettyClientHttpConnector()),
|
||||
args(new TomcatHttpServer(), new HttpComponentsClientHttpConnector()),
|
||||
args(new UndertowHttpServer(), new ReactorClientHttpConnector()),
|
||||
args(new UndertowHttpServer(), new JettyClientHttpConnector()),
|
||||
args(new UndertowHttpServer(), new HttpComponentsClientHttpConnector())
|
||||
);
|
||||
}
|
||||
|
||||
private static Arguments args(HttpServer httpServer, ClientHttpConnector connector) {
|
||||
return Arguments.of(
|
||||
named(httpServer.getClass().getSimpleName(), httpServer),
|
||||
named(connector.getClass().getSimpleName(), connector));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user