3.0.x jdk17 (#2372)
This commit is contained in:
committed by
GitHub
parent
c195059c3d
commit
5e746e4f3d
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.cors;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -32,13 +31,11 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class CorsTests extends BaseWebClientTests {
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.cors;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -34,13 +33,11 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
properties = "spring.cloud.gateway.globalcors.add-to-simple-url-handler-mapping=true")
|
||||
@DirtiesContext
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.filter;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.Tags;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -33,7 +32,6 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -42,10 +40,9 @@ import static org.springframework.cloud.gateway.config.GatewayMetricsProperties.
|
||||
/**
|
||||
* @author Ingyu Hwang
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class GatewayMetricsFilterCustomTagsTests extends BaseWebClientTests {
|
||||
class GatewayMetricsFilterCustomTagsTests extends BaseWebClientTests {
|
||||
|
||||
private static final String REQUEST_METRICS_NAME = DEFAULT_PREFIX + ".requests";
|
||||
|
||||
@@ -56,7 +53,7 @@ public class GatewayMetricsFilterCustomTagsTests extends BaseWebClientTests {
|
||||
private String testUri;
|
||||
|
||||
@Test
|
||||
public void gatewayRequestsMeterFilterHasCustomTags() {
|
||||
void gatewayRequestsMeterFilterHasCustomTags() {
|
||||
testClient.get().uri("/headers").exchange().expectStatus().isOk();
|
||||
|
||||
// default tags
|
||||
@@ -79,10 +76,10 @@ public class GatewayMetricsFilterCustomTagsTests extends BaseWebClientTests {
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class CustomConfig {
|
||||
static class CustomConfig {
|
||||
|
||||
@Bean
|
||||
public GatewayTagsProvider customGatewayTagsProvider() {
|
||||
GatewayTagsProvider customGatewayTagsProvider() {
|
||||
return exchange -> Tags.of("custom1", "tag1", "custom2", "tag2");
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
package org.springframework.cloud.gateway.filter;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -37,7 +36,6 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -45,7 +43,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
import static org.springframework.cloud.gateway.config.GatewayMetricsProperties.DEFAULT_PREFIX;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class GatewayMetricsFilterTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -27,7 +26,6 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -41,7 +39,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
*
|
||||
* @author echooymxq
|
||||
**/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = { "spring.cloud.gateway.routes[0].id=route_connect_timeout",
|
||||
"spring.cloud.gateway.routes[0].uri=http://localhost:32167",
|
||||
"spring.cloud.gateway.routes[0].predicates[0].name=Path",
|
||||
@@ -53,16 +50,16 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"spring.cloud.gateway.routes[1].filters[0]=StripPrefix=1",
|
||||
"spring.cloud.gateway.routes[1].metadata.response-timeout=1000" }, webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class NettyRoutingFilterCompatibleTests extends BaseWebClientTests {
|
||||
class NettyRoutingFilterCompatibleTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void shouldApplyConnectTimeoutPerRoute() {
|
||||
void shouldApplyConnectTimeoutPerRoute() {
|
||||
assertThat(NettyRoutingFilter.getInteger("5")).isEqualTo(5);
|
||||
assertThat(NettyRoutingFilter.getInteger(5)).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldApplyResponseTimeoutPerRoute() {
|
||||
void shouldApplyResponseTimeoutPerRoute() {
|
||||
testClient.get().uri("/route/delay/2").exchange().expectStatus().isEqualTo(HttpStatus.GATEWAY_TIMEOUT)
|
||||
.expectBody().jsonPath("$.status").isEqualTo(String.valueOf(HttpStatus.GATEWAY_TIMEOUT.value()))
|
||||
.jsonPath("$.message").isEqualTo("Response took longer than timeout: PT1S");
|
||||
@@ -71,7 +68,7 @@ public class NettyRoutingFilterCompatibleTests extends BaseWebClientTests {
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,7 +32,6 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -43,7 +41,6 @@ import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = "spring.cloud.gateway.httpclient.response-timeout=3s", webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class NettyRoutingFilterIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@@ -17,11 +17,9 @@
|
||||
package org.springframework.cloud.gateway.filter;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.netty.DisposableServer;
|
||||
import reactor.netty.http.server.HttpServer;
|
||||
@@ -37,33 +35,34 @@ import org.springframework.cloud.gateway.test.PermitAllSecurityConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class NettyRoutingFilterTests extends BaseWebClientTests {
|
||||
class NettyRoutingFilterTests extends BaseWebClientTests {
|
||||
|
||||
private static int port;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
port = SocketUtils.findAvailableTcpPort();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void mockServerWorks() {
|
||||
@Disabled
|
||||
void mockServerWorks() {
|
||||
WebTestClient client = WebTestClient.bindToApplicationContext(this.context).build();
|
||||
client.get().uri("/mockexample").exchange().expectStatus().value(Matchers.lessThan(500));
|
||||
}
|
||||
|
||||
@Test // gh-2207
|
||||
public void testCaseInsensitiveScheme() {
|
||||
@Test
|
||||
// gh-2207
|
||||
void testCaseInsensitiveScheme() {
|
||||
DisposableServer server = HttpServer.create().port(port).host("127.0.0.1").route(
|
||||
routes -> routes.get("/issue", (request, response) -> response.sendString(Mono.just("issue2207"))))
|
||||
.bindNow();
|
||||
@@ -71,10 +70,10 @@ public class NettyRoutingFilterTests extends BaseWebClientTests {
|
||||
try {
|
||||
testClient.get().uri("/issue").exchange().expectStatus().isOk().expectBody()
|
||||
.consumeWith(entityExchangeResult -> {
|
||||
Assert.assertNotNull(entityExchangeResult);
|
||||
Assert.assertNotNull(entityExchangeResult.getResponseBody());
|
||||
assertThat(entityExchangeResult).isNotNull();
|
||||
assertThat(entityExchangeResult.getResponseBody()).isNotNull();
|
||||
String content = new String(entityExchangeResult.getResponseBody());
|
||||
Assert.assertEquals("issue2207", content);
|
||||
assertThat(content).isEqualTo("issue2207");
|
||||
});
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -22,7 +22,8 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnJre;
|
||||
|
||||
import org.springframework.cloud.gateway.event.PredicateArgsEvent;
|
||||
import org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.GroupWeightConfig;
|
||||
@@ -34,6 +35,7 @@ import org.springframework.web.server.WebFilterChain;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.condition.JRE.JAVA_17;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -95,7 +97,9 @@ public class WeightCalculatorWebFilterTests {
|
||||
return "route" + i;
|
||||
}
|
||||
|
||||
// TODO: modify implementation for testability on JDK17 for Spring 6
|
||||
@Test
|
||||
@DisabledOnJre(JAVA_17)
|
||||
public void testChooseRouteWithRandom() {
|
||||
WeightCalculatorWebFilter filter = createFilter();
|
||||
filter.addWeightConfig(new WeightConfig("groupa", "route1", 1));
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -35,7 +34,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -45,7 +43,6 @@ import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
* @author Spencer Gibb
|
||||
* @author Biju Kunjummen
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ActiveProfiles(profiles = "request-header-web-filter")
|
||||
|
||||
@@ -21,8 +21,7 @@ import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -37,7 +36,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -45,7 +43,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.containsEncodedParts;
|
||||
import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ActiveProfiles(profiles = "request-parameter-web-filter")
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -33,19 +32,17 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class AddResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
class AddResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void testResposneHeaderFilter() {
|
||||
void testResposneHeaderFilter() {
|
||||
URI uri = UriComponentsBuilder.fromUriString(this.baseUri + "/headers").build(true).toUri();
|
||||
String host = "www.addresponseheader.org";
|
||||
String expectedValue = "Bar";
|
||||
@@ -54,7 +51,7 @@ public class AddResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTes
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResposneHeaderFilterJavaDsl() {
|
||||
void testResposneHeaderFilterJavaDsl() {
|
||||
URI uri = UriComponentsBuilder.fromUriString(this.baseUri + "/get").build(true).toUri();
|
||||
String host = "www.addresponseheaderjava.org";
|
||||
String expectedValue = "myresponsevalue-www";
|
||||
@@ -62,7 +59,7 @@ public class AddResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTes
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringFormat() {
|
||||
void toStringFormat() {
|
||||
NameValueConfig config = new NameValueConfig().setName("myname").setValue("myvalue");
|
||||
GatewayFilter filter = new AddResponseHeaderGatewayFilterFactory().apply(config);
|
||||
assertThat(filter.toString()).contains("myname").contains("myvalue");
|
||||
@@ -71,7 +68,7 @@ public class AddResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTes
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
@Value("${test.uri}")
|
||||
String uri;
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -25,17 +24,15 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class DedupeResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
class DedupeResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void dedupeResponseHeaderFilterWorks() {
|
||||
void dedupeResponseHeaderFilterWorks() {
|
||||
testClient.get().uri("/headers").header("Host", "www.deduperesponseheader.org").exchange().expectStatus().isOk()
|
||||
.expectHeader().valueEquals("Access-Control-Allow-Credentials", "true").expectHeader()
|
||||
.valueEquals("Access-Control-Allow-Origin", "https://musk.mars").expectHeader()
|
||||
@@ -46,7 +43,7 @@ public class DedupeResponseHeaderGatewayFilterFactoryTests extends BaseWebClient
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -35,7 +34,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -44,14 +42,13 @@ import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
/**
|
||||
* @author Tony Clarke
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ActiveProfiles(profiles = "request-map-header-web-filter")
|
||||
public class MapRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
class MapRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void mapRequestHeaderFilterWorks() {
|
||||
void mapRequestHeaderFilterWorks() {
|
||||
testClient.get().uri("/headers").header("Host", "www.maprequestheader.org").header("a", "tome").exchange()
|
||||
.expectBody(Map.class).consumeWith(result -> {
|
||||
Map<String, Object> headers = getMap(result.getResponseBody(), "headers");
|
||||
@@ -60,7 +57,7 @@ public class MapRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapRequestHeaderFilterWorksJavaDsl() {
|
||||
void mapRequestHeaderFilterWorksJavaDsl() {
|
||||
testClient.get().uri("/headers").header("Host", "www.maprequestheaderjava.org").header("b", "tome").exchange()
|
||||
.expectBody(Map.class).consumeWith(result -> {
|
||||
Map<String, Object> headers = getMap(result.getResponseBody(), "headers");
|
||||
@@ -70,7 +67,7 @@ public class MapRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTest
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void mapRequestHeaderWithMultiValueFilterWorks() {
|
||||
void mapRequestHeaderWithMultiValueFilterWorks() {
|
||||
testClient.get().uri("/multivalueheaders").header("Host", "www.maprequestheader.org")
|
||||
.header("a", "tome", "toyou").exchange().expectBody(Map.class).consumeWith(result -> {
|
||||
Map<String, Object> headers = getMap(result.getResponseBody(), "headers");
|
||||
@@ -81,7 +78,7 @@ public class MapRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapRequestHeaderWithNullValueFilterWorks() {
|
||||
void mapRequestHeaderWithNullValueFilterWorks() {
|
||||
testClient.get().uri("/headers").header("Host", "www.maprequestheader.org").header("a", (String) null)
|
||||
.exchange().expectBody(Map.class).consumeWith(result -> {
|
||||
Map<String, Object> headers = getMap(result.getResponseBody(), "headers");
|
||||
@@ -90,7 +87,7 @@ public class MapRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapRequestHeaderWhenInputHeaderDoesNotExist() {
|
||||
void mapRequestHeaderWhenInputHeaderDoesNotExist() {
|
||||
testClient.get().uri("/headers").header("Host", "www.maprequestheader.org").exchange().expectBody(Map.class)
|
||||
.consumeWith(result -> {
|
||||
Map<String, Object> headers = getMap(result.getResponseBody(), "headers");
|
||||
@@ -99,7 +96,7 @@ public class MapRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringFormat() {
|
||||
void toStringFormat() {
|
||||
Config config = new Config().setFromHeader("myfromheader").setToHeader("mytoheader");
|
||||
GatewayFilter filter = new MapRequestHeaderGatewayFilterFactory().apply(config);
|
||||
assertThat(filter.toString()).contains("myfromheader").contains("mytoheader");
|
||||
@@ -108,13 +105,13 @@ public class MapRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTest
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
@Value("${test.uri}")
|
||||
String uri;
|
||||
|
||||
@Bean
|
||||
public RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
|
||||
RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
|
||||
return builder.routes().route("map_request_header_java_test",
|
||||
r -> r.path("/headers").and().host("**.maprequestheaderjava.org")
|
||||
.filters(f -> f.prefixPath("/httpbin").mapRequestHeader("b", "X-Request-Example-Java"))
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -33,7 +32,6 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -42,7 +40,6 @@ import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class PreserveHostHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -32,12 +31,10 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RedirectToGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -29,13 +28,11 @@ import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFac
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RemoveRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -33,13 +32,11 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RemoveRequestParameterGatewayFilterFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -27,12 +26,10 @@ import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFac
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RemoveResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -32,7 +31,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
|
||||
@@ -43,7 +41,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
* @author Sakalya Deshpande
|
||||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RequestHeaderSizeGatewayFilterFactoryTest extends BaseWebClientTests {
|
||||
|
||||
@@ -20,9 +20,8 @@ import java.net.URI;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -34,7 +33,6 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -42,7 +40,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
/**
|
||||
* @author Toshiaki Maki
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RequestHeaderToRequestUriGatewayFilterFactoryIntegrationTests extends BaseWebClientTests {
|
||||
@@ -51,7 +48,7 @@ public class RequestHeaderToRequestUriGatewayFilterFactoryIntegrationTests exten
|
||||
int port;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void changeUriWorkWithProperties() {
|
||||
testClient.get().uri("/").header("Host", "www.changeuri.org")
|
||||
.header("X-CF-Forwarded-Url", "http://localhost:" + port + "/actuator/health").exchange()
|
||||
@@ -59,7 +56,7 @@ public class RequestHeaderToRequestUriGatewayFilterFactoryIntegrationTests exten
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void changeUriWorkWithDsl() {
|
||||
testClient.get().uri("/").header("Host", "www.changeuri.org")
|
||||
.header("X-Next-Url", "http://localhost:" + port + "/actuator/health").exchange()
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -45,7 +44,6 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.server.MockServerWebExchange;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -57,7 +55,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RequestRateLimiterGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -32,7 +31,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -42,7 +40,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
* @author Arpan Das
|
||||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RequestSizeGatewayFilterFactoryTest extends BaseWebClientTests {
|
||||
|
||||
@@ -25,16 +25,16 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.system.OutputCaptureRule;
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||
@@ -53,7 +53,6 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -62,7 +61,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
properties = { "spring.cloud.gateway.httpclient.connect-timeout=500",
|
||||
"spring.cloud.gateway.httpclient.response-timeout=2s",
|
||||
@@ -72,11 +70,9 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
// https://github.com/spring-cloud/spring-cloud-gateway/issues/1315,
|
||||
// so we use only PrefixPath filter
|
||||
@ActiveProfiles("retrytests")
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@Rule
|
||||
public final OutputCaptureRule capture = new OutputCaptureRule();
|
||||
|
||||
@Test
|
||||
public void retryFilterGet() {
|
||||
testClient.get().uri("/retry?key=get").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("3");
|
||||
@@ -110,11 +106,11 @@ public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void retryFilterPost() {
|
||||
public void retryFilterPost(CapturedOutput output) {
|
||||
testClient.post().uri("/retrypost?key=postconfig&expectedbody=HelloConfig")
|
||||
.header(HttpHeaders.HOST, "www.retrypostconfig.org").bodyValue("HelloConfig").exchange().expectStatus()
|
||||
.isOk().expectBody(String.class).isEqualTo("3");
|
||||
assertThat(this.capture.toString()).contains("disposing response connection before next iteration");
|
||||
assertThat(output).contains("disposing response connection before next iteration");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,12 +120,12 @@ public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void retryFilterPostOneTime() {
|
||||
public void retryFilterPostOneTime(CapturedOutput output) {
|
||||
testClient.post().uri("/retrypost?key=retryFilterPostOneTime&expectedbody=HelloGateway&count=1")
|
||||
.header(HttpHeaders.HOST, "www.retrypostonceconfig.org").bodyValue("HelloGateway").exchange()
|
||||
.expectStatus().isOk();
|
||||
assertThat(this.capture.toString()).contains("setting new iteration in attr 0");
|
||||
assertThat(this.capture.toString()).doesNotContain("setting new iteration in attr 1");
|
||||
assertThat(output).contains("setting new iteration in attr 0");
|
||||
assertThat(output).doesNotContain("setting new iteration in attr 1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -25,11 +24,9 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RewriteLocationResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -25,11 +24,9 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RewritePathGatewayFilterFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -25,11 +24,9 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RewriteResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -34,7 +33,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.server.WebSession;
|
||||
import org.springframework.web.server.session.WebSessionManager;
|
||||
|
||||
@@ -47,7 +45,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
/**
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ActiveProfiles(profiles = "save-session-web-filter")
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -30,7 +29,6 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -45,7 +43,6 @@ import static org.springframework.cloud.gateway.filter.factory.SecureHeadersGate
|
||||
import static org.springframework.cloud.gateway.filter.factory.SecureHeadersGatewayFilterFactory.X_XSS_PROTECTION_HEADER;
|
||||
import static org.springframework.cloud.gateway.test.TestUtils.assertStatus;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SecureHeadersGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -25,11 +24,9 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SetPathGatewayFilterFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -33,7 +32,6 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -43,7 +41,6 @@ import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
* @author Spencer Gibb
|
||||
* @author Biju Kunjummen
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SetRequestHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -28,13 +27,11 @@ import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SetRequestHostHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -31,12 +30,10 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SetResponseHeaderGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -39,13 +38,11 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SetStatusGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -34,7 +33,6 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
|
||||
@@ -45,7 +43,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
properties = { "debug=true", "spring.cloud.circuitbreaker.hystrix.enabled=false" })
|
||||
@ContextConfiguration(classes = SpringCloudCircuitBreakerResilience4JFilterFactoryTests.Config.class)
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -25,14 +24,12 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class StripPrefixGatewayFilterFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@@ -63,7 +63,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"spring.main.allow-bean-definition-overriding=true" })
|
||||
@DirtiesContext
|
||||
@ActiveProfiles("single-cert-ssl")
|
||||
public class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWebClientTests {
|
||||
class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWebClientTests {
|
||||
|
||||
@Autowired
|
||||
AtomicInteger releaseCount;
|
||||
@@ -82,7 +82,7 @@ public class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWe
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modifyRequestBodySSLTimeout() {
|
||||
void modifyRequestBodySSLTimeout() {
|
||||
testClient.post().uri("/post").header("Host", "www.modifyrequestbodyssltimeout.org")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE)
|
||||
.body(BodyInserters.fromValue("request")).exchange().expectStatus()
|
||||
@@ -91,7 +91,7 @@ public class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWe
|
||||
}
|
||||
|
||||
@RetryingTest(3)
|
||||
public void modifyRequestBodyRelease() {
|
||||
void modifyRequestBodyRelease() {
|
||||
releaseCount.set(0);
|
||||
// long initialUsedDirectMemory = PlatformDependent.usedDirectMemory();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
@@ -107,7 +107,7 @@ public class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWe
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modifyRequestBodyHappenedError() {
|
||||
void modifyRequestBodyHappenedError() {
|
||||
testClient.post().uri("/post").header("Host", "www.modifyrequestbodyexception.org")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE)
|
||||
.body(BodyInserters.fromValue("request")).exchange().expectStatus()
|
||||
@@ -118,14 +118,14 @@ public class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWe
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration(proxyBeanMethods = false)
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
@Value("${test.uri}")
|
||||
String uri;
|
||||
|
||||
@Bean
|
||||
@DependsOn("testModifyRequestBodyGatewayFilterFactory")
|
||||
public RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
|
||||
RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
|
||||
return builder.routes()
|
||||
.route("test_modify_request_body_ssl_timeout",
|
||||
r -> r.order(-1).host("**.modifyrequestbodyssltimeout.org")
|
||||
@@ -146,13 +146,13 @@ public class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWe
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AtomicInteger count() {
|
||||
AtomicInteger count() {
|
||||
return new AtomicInteger();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public ModifyRequestBodyGatewayFilterFactory testModifyRequestBodyGatewayFilterFactory(
|
||||
ModifyRequestBodyGatewayFilterFactory testModifyRequestBodyGatewayFilterFactory(
|
||||
ServerCodecConfigurer codecConfigurer, AtomicInteger count) {
|
||||
return new ModifyRequestBodyGatewayFilterFactory(codecConfigurer.getReaders()) {
|
||||
@Override
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory.rewrite;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -33,7 +32,6 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -41,7 +39,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
/**
|
||||
* @author Junghoon Song
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = "spring.codec.max-in-memory-size=13")
|
||||
@DirtiesContext
|
||||
public class ModifyRequestBodyGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -35,18 +34,16 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class ModifyResponseBodyGatewayFilterFactoryGzipTests extends BaseWebClientTests {
|
||||
class ModifyResponseBodyGatewayFilterFactoryGzipTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void testModificationOfResponseBody() {
|
||||
void testModificationOfResponseBody() {
|
||||
URI uri = UriComponentsBuilder.fromUriString(this.baseUri + "/gzip").build(true).toUri();
|
||||
|
||||
testClient.get().uri(uri).header("Host", "www.modifyresponsebodyjava.org").accept(MediaType.APPLICATION_JSON)
|
||||
@@ -56,13 +53,13 @@ public class ModifyResponseBodyGatewayFilterFactoryGzipTests extends BaseWebClie
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
@Value("${test.uri}")
|
||||
String uri;
|
||||
|
||||
@Bean
|
||||
public RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
|
||||
RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
|
||||
return builder.routes().route("modify_response_java_test_gzip", r -> r.path("/gzip").and()
|
||||
.host("www.modifyresponsebodyjava.org")
|
||||
.filters(f -> f.modifyResponseBody(String.class, Map.class, (webExchange, originalResponse) -> {
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -37,13 +36,11 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = "spring.codec.max-in-memory-size=40")
|
||||
@DirtiesContext
|
||||
public class ModifyResponseBodyGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.headers;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -28,7 +27,6 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -37,7 +35,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class HttpStatusInResponseHeadersFilterTests extends BaseWebClientTests {
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.net.URI;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -37,14 +36,12 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = DEFINED_PORT, properties = { "server.port=62175" })
|
||||
@DirtiesContext
|
||||
public class NonStandardHeadersInResponseTests extends BaseWebClientTests {
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.handler;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -31,11 +30,9 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = {})
|
||||
@DirtiesContext
|
||||
public class RoutePredicateHandlerMappingEmptyPredicatesTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.gateway.handler;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -31,7 +30,6 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.SocketUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -39,20 +37,19 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = "management.server.port=${test.port}")
|
||||
@DirtiesContext
|
||||
public class RoutePredicateHandlerMappingIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
private static int managementPort;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
managementPort = SocketUtils.findAvailableTcpPort();
|
||||
System.setProperty("test.port", String.valueOf(managementPort));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClass() {
|
||||
System.clearProperty("test.port");
|
||||
}
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.gateway.handler;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -27,26 +26,24 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = DEFINED_PORT)
|
||||
@DirtiesContext
|
||||
public class RoutePredicateHandlerMappingSameManagementPortIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
private static int samePort;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
samePort = SocketUtils.findAvailableTcpPort();
|
||||
System.setProperty("server.port", String.valueOf(samePort));
|
||||
System.setProperty("management.server.port", String.valueOf(samePort));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClass() {
|
||||
System.clearProperty("server.port");
|
||||
System.clearProperty("management.server.port");
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -33,11 +32,9 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class BetweenRoutePredicateFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
package org.springframework.cloud.gateway.handler.predicate;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -30,7 +29,6 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -38,7 +36,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
/**
|
||||
* @author Toshiaki Maki
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class CloudFoundryRouteServiceRoutePredicateFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.gateway.handler.predicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -25,19 +24,17 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
public class CookieRoutePredicateFactoryIntegrationTests extends BaseWebClientTests {
|
||||
class CookieRoutePredicateFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void cookieRegexWorks() {
|
||||
void cookieRegexWorks() {
|
||||
assertCookieValue("helloaaaaa");
|
||||
|
||||
assertCookieValue("hello");
|
||||
@@ -53,10 +50,10 @@ public class CookieRoutePredicateFactoryIntegrationTests extends BaseWebClientTe
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
@RestController
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
@GetMapping("/httpbin/cookie")
|
||||
public String cookie(@CookieValue("mycookie") String mycookie) {
|
||||
String cookie(@CookieValue("mycookie") String mycookie) {
|
||||
return mycookie;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.gateway.handler.predicate.CookieRoutePredicateFactory.Config;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -33,12 +32,10 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class HeaderRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -34,12 +33,10 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class HostRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -35,12 +34,10 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class MethodRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -35,13 +34,11 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class PathRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@@ -18,15 +18,15 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.system.OutputCaptureRule;
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
import org.springframework.cloud.gateway.handler.predicate.QueryRoutePredicateFactory.Config;
|
||||
import org.springframework.cloud.gateway.route.RouteLocator;
|
||||
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
|
||||
@@ -34,26 +34,20 @@ import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
public class QueryRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@Rule
|
||||
public OutputCaptureRule output = new OutputCaptureRule();
|
||||
|
||||
@Test
|
||||
public void noQueryParamWorks() {
|
||||
public void noQueryParamWorks(CapturedOutput output) {
|
||||
testClient.get().uri("/get").exchange().expectStatus().isOk().expectHeader().valueEquals(ROUTE_ID_HEADER,
|
||||
"default_path_to_httpbin");
|
||||
output.expect(not(containsString("Error applying predicate for route: foo_query_param")));
|
||||
assertThat(output).doesNotContain("Error applying predicate for route: foo_query_param");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,10 +57,10 @@ public class QueryRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyQueryParamWorks() {
|
||||
public void emptyQueryParamWorks(CapturedOutput output) {
|
||||
testClient.get().uri("/get?foo").exchange().expectStatus().isOk().expectHeader().valueEquals(ROUTE_ID_HEADER,
|
||||
"default_path_to_httpbin");
|
||||
output.expect(not(containsString("Error applying predicate for route: foo_query_param")));
|
||||
assertThat(output).doesNotContain("Error applying predicate for route: foo_query_param");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
import java.time.Duration;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -38,14 +37,12 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
import static org.springframework.cloud.gateway.test.TestUtils.assertStatus;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ActiveProfiles({ "remote-address" })
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
import java.util.Random;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnJre;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -36,16 +36,16 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.condition.JRE.JAVA_17;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@DisabledOnJre(JAVA_17)
|
||||
public class WeightRoutePredicateFactoryIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.cloud.gateway.handler.predicate;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnJre;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -31,17 +31,17 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.jupiter.api.condition.JRE.JAVA_17;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@ActiveProfiles("weights-404")
|
||||
@DirtiesContext
|
||||
public class WeightRoutePredicateFactoryYaml404Tests extends BaseWebClientTests {
|
||||
@DisabledOnJre(JAVA_17)
|
||||
class WeightRoutePredicateFactoryYaml404Tests extends BaseWebClientTests {
|
||||
|
||||
@Autowired
|
||||
private WeightCalculatorWebFilter filter;
|
||||
@@ -53,7 +53,7 @@ public class WeightRoutePredicateFactoryYaml404Tests extends BaseWebClientTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void weightsFromYamlNot404() {
|
||||
void weightsFromYamlNot404() {
|
||||
filter.setRandom(getRandom(0.5));
|
||||
|
||||
testClient.get().uri("/get").header(HttpHeaders.HOST, "www.weight4041.org").exchange().expectStatus().isOk()
|
||||
@@ -63,9 +63,9 @@ public class WeightRoutePredicateFactoryYaml404Tests extends BaseWebClientTests
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
public TestConfig(WeightCalculatorWebFilter filter) {
|
||||
TestConfig(WeightCalculatorWebFilter filter) {
|
||||
Random random = getRandom(0.4);
|
||||
|
||||
filter.setRandom(random);
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.time.Duration;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -68,7 +68,7 @@ public class BaseWebClientTests {
|
||||
|
||||
protected String baseUri;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
setup(new ReactorClientHttpConnector(), "http://localhost:" + port);
|
||||
}
|
||||
|
||||
@@ -86,6 +86,11 @@ public class CustomBlockHoundIntegration implements BlockHoundIntegration {
|
||||
builder.allowBlockingCallsInside(
|
||||
"org.springframework.security.authentication.AbstractUserDetailsReactiveAuthenticationManager",
|
||||
"lambda$authenticate$4");
|
||||
|
||||
// Uses java.io.RandomAccessFile#readBytes
|
||||
builder.allowBlockingCallsInside("org.springframework.context.annotation.ConfigurationClassParser", "parse");
|
||||
builder.allowBlockingCallsInside(
|
||||
"org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader", "loadBeanDefinitions");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.cloud.gateway.test;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -34,7 +33,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.MultipartBodyBuilder;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
@@ -45,17 +43,16 @@ import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED;
|
||||
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FormIntegrationTests extends BaseWebClientTests {
|
||||
class FormIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
public static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType(APPLICATION_FORM_URLENCODED,
|
||||
StandardCharsets.UTF_8);
|
||||
|
||||
@Test
|
||||
public void formUrlencodedWorks() {
|
||||
void formUrlencodedWorks() {
|
||||
LinkedMultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
|
||||
formData.add("foo", "bar");
|
||||
formData.add("baz", "bam");
|
||||
@@ -75,7 +72,7 @@ public class FormIntegrationTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipartFormDataWorksWebClient() {
|
||||
void multipartFormDataWorksWebClient() {
|
||||
MultiValueMap<String, HttpEntity<?>> formData = createMultipartData();
|
||||
|
||||
// @formatter:off
|
||||
@@ -89,7 +86,7 @@ public class FormIntegrationTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipartFormDataWorksRestTemplate() {
|
||||
void multipartFormDataWorksRestTemplate() {
|
||||
MultiValueMap<String, HttpEntity<?>> formData = createMultipartData();
|
||||
TestRestTemplate rest = new TestRestTemplate();
|
||||
|
||||
@@ -116,7 +113,7 @@ public class FormIntegrationTests extends BaseWebClientTests {
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -50,7 +49,6 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
@@ -59,11 +57,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
import static org.springframework.cloud.gateway.test.TestUtils.getMap;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@SuppressWarnings("unchecked")
|
||||
public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@Autowired
|
||||
private GatewayProperties properties;
|
||||
@@ -72,7 +69,7 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void listenersInOrder() {
|
||||
void listenersInOrder() {
|
||||
assertThat(context).isInstanceOf(AbstractApplicationContext.class);
|
||||
AbstractApplicationContext ctxt = (AbstractApplicationContext) context;
|
||||
List<ApplicationListener<?>> applicationListeners = new ArrayList<>(ctxt.getApplicationListeners());
|
||||
@@ -84,7 +81,7 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void complexContentTypeWorks() {
|
||||
void complexContentTypeWorks() {
|
||||
testClient.post().uri("/headers").contentType(MediaType.APPLICATION_JSON).bodyValue("testdata")
|
||||
.header("Host", "www.complexcontenttype.org").exchange().expectStatus().isOk().expectBody(Map.class)
|
||||
.consumeWith(result -> {
|
||||
@@ -94,7 +91,7 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forwardedHeadersWork() {
|
||||
void forwardedHeadersWork() {
|
||||
testClient.get().uri("/headers").exchange().expectStatus().isOk().expectBody(Map.class).consumeWith(result -> {
|
||||
Map<String, Object> headers = getMap(result.getResponseBody(), "headers");
|
||||
assertThat(headers).containsKeys(ForwardedHeadersFilter.FORWARDED_HEADER,
|
||||
@@ -111,7 +108,7 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compositeRouteWorks() {
|
||||
void compositeRouteWorks() {
|
||||
testClient.get().uri("/headers?foo=bar&baz").header("Host", "www.foo.org").header("X-Request-Id", "123")
|
||||
.cookie("chocolate", "chip").exchange().expectStatus().isOk().expectHeader()
|
||||
.valueEquals(HANDLER_MAPPER_HEADER, RoutePredicateHandlerMapping.class.getSimpleName()).expectHeader()
|
||||
@@ -120,7 +117,7 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultFiltersWorks() {
|
||||
void defaultFiltersWorks() {
|
||||
assertThat(this.properties.getDefaultFilters()).isNotEmpty();
|
||||
|
||||
testClient.get().uri("/headers").header("Host", "www.addresponseheader.org").exchange().expectStatus().isOk()
|
||||
@@ -132,13 +129,13 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadBalancerFilterWorks() {
|
||||
void loadBalancerFilterWorks() {
|
||||
testClient.get().uri("/get").header("Host", "www.loadbalancerclient.org").exchange().expectStatus().isOk()
|
||||
.expectHeader().valueEquals(ROUTE_ID_HEADER, "load_balancer_client_test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadBalancerFilterNoClientWorks() {
|
||||
void loadBalancerFilterNoClientWorks() {
|
||||
testClient.get().uri("/get").header("Host", "www.loadbalancerclientempty.org").exchange().expectStatus()
|
||||
.value(new BaseMatcher<Integer>() {
|
||||
@Override
|
||||
@@ -159,7 +156,7 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
// gh-374 no content type/empty body causes NPR in NettyRoutingFilter
|
||||
public void noContentType() {
|
||||
void noContentType() {
|
||||
testClient.get().uri("/nocontenttype").exchange().expectStatus().is2xxSuccessful();
|
||||
}
|
||||
|
||||
@@ -167,7 +164,7 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
@RestController
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
private static final Log log = LogFactory.getLog(TestConfig.class);
|
||||
|
||||
@@ -178,13 +175,13 @@ public class GatewayIntegrationTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@RequestMapping("/httpbin/nocontenttype")
|
||||
public ResponseEntity<Void> nocontenttype() {
|
||||
ResponseEntity<Void> nocontenttype() {
|
||||
return ResponseEntity.status(204).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Order(-1)
|
||||
public GlobalFilter postFilter() {
|
||||
GlobalFilter postFilter() {
|
||||
return (exchange, chain) -> {
|
||||
log.info("postFilter start");
|
||||
return chain.filter(exchange).then(postFilterWork(exchange));
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -30,14 +29,12 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -48,13 +45,13 @@ public class HttpStatusTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notFoundResponseWorks() {
|
||||
void notFoundResponseWorks() {
|
||||
testClient.get().uri("/status/404").exchange().expectStatus().isEqualTo(HttpStatus.NOT_FOUND)
|
||||
.expectBody(String.class).isEqualTo("Failed with 404");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonStandardCodeWorks() {
|
||||
void nonStandardCodeWorks() {
|
||||
ResponseEntity<String> response = new TestRestTemplate().getForEntity(baseUri + "/status/432", String.class);
|
||||
assertThat(response.getStatusCodeValue()).isEqualTo(432);
|
||||
assertThat(response.getBody()).isEqualTo("Failed with 432");
|
||||
@@ -66,13 +63,13 @@ public class HttpStatusTests extends BaseWebClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serverErrorResponseWorks() {
|
||||
void serverErrorResponseWorks() {
|
||||
testClient.get().uri("/status/500").exchange().expectStatus().isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.expectBody(String.class).isEqualTo("Failed with 500");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void normalErrorPageWorks() {
|
||||
void normalErrorPageWorks() {
|
||||
testClient.get().uri("/exception").exchange().expectStatus().isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.expectBody(Map.class)
|
||||
.consumeWith(result -> assertThat(result.getResponseBody()).hasSizeGreaterThanOrEqualTo(5)
|
||||
@@ -83,10 +80,10 @@ public class HttpStatusTests extends BaseWebClientTests {
|
||||
@SpringBootConfiguration
|
||||
@RestController
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
@RequestMapping("/httpbin/exception")
|
||||
public String exception() {
|
||||
String exception() {
|
||||
throw new RuntimeException("an error");
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.cloud.gateway.test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -28,20 +27,18 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@SuppressWarnings("unchecked")
|
||||
// TODO: why does this have to be in a separate test?
|
||||
public class PostTests extends BaseWebClientTests {
|
||||
class PostTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void postWorks() {
|
||||
void postWorks() {
|
||||
Mono<Map> result = webClient.post().uri("/post").header("Host", "www.example.org").bodyValue("testdata")
|
||||
.retrieve().bodyToMono(Map.class);
|
||||
|
||||
@@ -52,7 +49,7 @@ public class PostTests extends BaseWebClientTests {
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
@Import(DefaultTestConfig.class)
|
||||
public static class TestConfig {
|
||||
static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,8 @@ import javax.net.ssl.SSLException;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -36,12 +35,10 @@ import org.springframework.boot.web.server.WebServerException;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ActiveProfiles("client-auth-ssl")
|
||||
@@ -56,7 +53,7 @@ public class ClientCertAuthSSLTests extends SingleCertSSLTests {
|
||||
@Value("${spring.cloud.gateway.httpclient.ssl.key-password}")
|
||||
private String keyPassword;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
KeyStore store = KeyStore.getInstance("JKS");
|
||||
|
||||
|
||||
@@ -16,16 +16,12 @@
|
||||
|
||||
package org.springframework.cloud.gateway.test.ssl;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ActiveProfiles("multi-cert-ssl")
|
||||
|
||||
@@ -16,19 +16,16 @@
|
||||
|
||||
package org.springframework.cloud.gateway.test.ssl;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.JsonPathAssertions;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
// this test works because it assumes TLS hand shake cannot be done in 1ms. It takes
|
||||
// closer to 80ms
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
|
||||
@@ -21,9 +21,8 @@ import javax.net.ssl.SSLException;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -35,19 +34,17 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@ActiveProfiles("single-cert-ssl")
|
||||
public class SingleCertSSLTests extends BaseWebClientTests {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
try {
|
||||
SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE)
|
||||
|
||||
Reference in New Issue
Block a user