Browse Source

Updates to new RetryingTest annotation

pull/1878/head
spencergibb 4 years ago
parent
commit
4d1bc43c1d
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 10
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/route/builder/PredicateSpec.java
  2. 4
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyRequestBodyGatewayFilterFactorySslTimeoutTests.java
  3. 4
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/RedisRateLimiterTests.java
  4. 6
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java

10
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/route/builder/PredicateSpec.java

@ -185,14 +185,14 @@ public class PredicateSpec extends UriSpec { @@ -185,14 +185,14 @@ public class PredicateSpec extends UriSpec {
* A predicate that checks if the path of the request matches the given pattern
* @param patterns the pattern to check the path against. The pattern is a
* {@link org.springframework.util.PathMatcher} pattern
* @param matchTrailingSlash set to false if you do not want this path to
* match when there is a trailing <code>/</code>
* @param matchTrailingSlash set to false if you do not want this path to match when
* there is a trailing <code>/</code>
* @return a {@link BooleanSpec} to be used to add logical operators
*/
public BooleanSpec path(boolean matchTrailingSlash, String... patterns) {
return asyncPredicate(getBean(PathRoutePredicateFactory.class).applyAsync(c -> c
.setPatterns(Arrays.asList(patterns))
.setMatchTrailingSlash(matchTrailingSlash)));
return asyncPredicate(getBean(PathRoutePredicateFactory.class)
.applyAsync(c -> c.setPatterns(Arrays.asList(patterns))
.setMatchTrailingSlash(matchTrailingSlash)));
}
/**

4
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyRequestBodyGatewayFilterFactorySslTimeoutTests.java

@ -26,7 +26,7 @@ import io.netty.handler.ssl.util.InsecureTrustManagerFactory; @@ -26,7 +26,7 @@ import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.util.internal.PlatformDependent;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.RepeatFailedTest;
import org.junitpioneer.jupiter.RetryingTest;
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClient;
@ -94,7 +94,7 @@ public class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests @@ -94,7 +94,7 @@ public class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests
.jsonPath("message").isEqualTo("handshake timed out after 1ms");
}
@RepeatFailedTest(3)
@RetryingTest(3)
public void modifyRequestBodyRelease() {
releaseCount.set(0);
// long initialUsedDirectMemory = PlatformDependent.usedDirectMemory();

4
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/RedisRateLimiterTests.java

@ -21,7 +21,7 @@ import java.util.UUID; @@ -21,7 +21,7 @@ import java.util.UUID;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.RepeatFailedTest;
import org.junitpioneer.jupiter.RetryingTest;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
@ -71,7 +71,7 @@ public class RedisRateLimiterTests extends BaseWebClientTests { @@ -71,7 +71,7 @@ public class RedisRateLimiterTests extends BaseWebClientTests {
rateLimiter.setIncludeHeaders(true);
}
@RepeatFailedTest(3)
@RetryingTest(3)
public void redisRateLimiterWorks() throws Exception {
String id = UUID.randomUUID().toString();

6
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java

@ -105,7 +105,7 @@ public class PathRoutePredicateFactoryTests extends BaseWebClientTests { @@ -105,7 +105,7 @@ public class PathRoutePredicateFactoryTests extends BaseWebClientTests {
.setMatchOptionalTrailingSeparator(false);
assertThat(config.isMatchTrailingSlash()).isEqualTo(false);
}
@Test
public void toStringFormat() {
Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB"))
@ -119,12 +119,12 @@ public class PathRoutePredicateFactoryTests extends BaseWebClientTests { @@ -119,12 +119,12 @@ public class PathRoutePredicateFactoryTests extends BaseWebClientTests {
public void toStringFormatMatchTrailingSlashTrue() {
Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB"))
.setMatchTrailingSlash(true);
Predicate<ServerWebExchange> predicate = new PathRoutePredicateFactory().apply(config);
Predicate<ServerWebExchange> predicate = new PathRoutePredicateFactory()
.apply(config);
assertThat(predicate.toString()).contains("patternA").contains("patternB")
.contains("true");
}
@EnableAutoConfiguration
@SpringBootConfiguration
@Import(DefaultTestConfig.class)

Loading…
Cancel
Save