Skip to content

Commit ec07cb8

Browse files
committed
Merge branch '4.2.x'
2 parents b883487 + ae2fcf2 commit ec07cb8

File tree

8 files changed

+25
-22
lines changed

8 files changed

+25
-22
lines changed

spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/route/builder/GatewayFilterSpec.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
import org.apache.commons.logging.Log;
3333
import org.apache.commons.logging.LogFactory;
34-
import org.springframework.core.ParameterizedTypeReference;
3534
import reactor.retry.Repeat;
3635
import reactor.retry.Retry;
3736

@@ -84,6 +83,7 @@
8483
import org.springframework.cloud.gateway.filter.ratelimit.RateLimiter;
8584
import org.springframework.cloud.gateway.route.Route;
8685
import org.springframework.core.Ordered;
86+
import org.springframework.core.ParameterizedTypeReference;
8787
import org.springframework.http.HttpStatus;
8888
import org.springframework.util.unit.DataSize;
8989
import org.springframework.web.server.ServerWebExchange;

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/actuate/GatewayControllerEndpointTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.stream.Collectors;
2727

2828
import org.assertj.core.util.Maps;
29-
import org.junit.jupiter.api.Assertions;
3029
import org.junit.jupiter.api.Test;
3130

3231
import org.springframework.beans.factory.annotation.Autowired;
@@ -200,7 +199,7 @@ public void testRouteDelete() {
200199
.expectBody(ResponseEntity.class)
201200
.consumeWith(result -> {
202201
HttpStatusCode httpStatus = result.getStatus();
203-
Assertions.assertEquals(HttpStatus.OK, httpStatus);
202+
assertThat(HttpStatus.OK).isEqualTo(httpStatus);
204203
});
205204
}
206205

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/RouteToRequestUrlFilterTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.net.URI;
2020

21-
import org.junit.jupiter.api.Assertions;
2221
import org.junit.jupiter.api.Test;
2322
import org.mockito.ArgumentCaptor;
2423
import reactor.core.publisher.Mono;
@@ -32,6 +31,7 @@
3231
import org.springframework.web.util.UriComponentsBuilder;
3332

3433
import static org.assertj.core.api.Assertions.assertThat;
34+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3535
import static org.junit.Assume.assumeTrue;
3636
import static org.mockito.Mockito.mock;
3737
import static org.mockito.Mockito.when;
@@ -64,7 +64,7 @@ public void happyPathLb() {
6464

6565
@Test
6666
public void invalidHost() {
67-
Assertions.assertThrows(IllegalStateException.class, () -> {
67+
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
6868
MockServerHttpRequest request = MockServerHttpRequest.get("http://localhost/getb").build();
6969
testFilter(request, "lb://my_host");
7070
});

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/RedisRateLimiterUnitTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import io.lettuce.core.RedisException;
2020
import org.junit.jupiter.api.AfterEach;
21-
import org.junit.jupiter.api.Assertions;
2221
import org.junit.jupiter.api.BeforeEach;
2322
import org.junit.jupiter.api.Test;
2423
import org.junit.jupiter.api.extension.ExtendWith;
@@ -32,6 +31,7 @@
3231
import org.springframework.data.redis.core.ReactiveStringRedisTemplate;
3332

3433
import static org.assertj.core.api.Assertions.assertThat;
34+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3535
import static org.assertj.core.data.MapEntry.entry;
3636
import static org.mockito.ArgumentMatchers.any;
3737
import static org.mockito.ArgumentMatchers.anyList;
@@ -78,7 +78,8 @@ public void tearDown() {
7878

7979
@Test
8080
public void shouldThrowWhenNotInitialized() {
81-
Assertions.assertThrows(IllegalStateException.class, () -> redisRateLimiter.isAllowed(ROUTE_ID, REQUEST_ID));
81+
assertThatExceptionOfType(IllegalStateException.class)
82+
.isThrownBy(() -> redisRateLimiter.isAllowed(ROUTE_ID, REQUEST_ID));
8283
}
8384

8485
@Test

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/AsyncPredicateTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818

1919
import java.util.function.Predicate;
2020

21-
import org.junit.jupiter.api.Assertions;
2221
import org.junit.jupiter.api.DisplayName;
2322
import org.junit.jupiter.api.Test;
2423
import org.reactivestreams.Publisher;
2524
import reactor.core.publisher.Mono;
2625
import reactor.test.StepVerifier;
2726

27+
import static org.assertj.core.api.Assertions.assertThat;
28+
2829
public class AsyncPredicateTest {
2930

3031
@Test
@@ -110,12 +111,12 @@ public Publisher<Boolean> apply(T t) {
110111

111112
@DisplayName("predicate must have been tested")
112113
public void assertTested() {
113-
Assertions.assertTrue(tested);
114+
assertThat(tested).isTrue();
114115
}
115116

116117
@DisplayName("predicate must not have been tested")
117118
public void assertUntested() {
118-
Assertions.assertFalse(tested);
119+
assertThat(tested).isFalse();
119120
}
120121

121122
}

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMappingTests.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.cloud.gateway.handler;
1818

19-
import org.junit.jupiter.api.Assertions;
2019
import org.junit.jupiter.api.Test;
2120
import org.junit.jupiter.api.extension.ExtendWith;
2221
import org.mockito.Mockito;
@@ -32,6 +31,8 @@
3231
import org.springframework.mock.env.MockEnvironment;
3332
import org.springframework.web.server.ServerWebExchange;
3433

34+
import static org.assertj.core.api.Assertions.assertThat;
35+
3536
/**
3637
* @author Simon Baslé
3738
*/
@@ -57,8 +58,8 @@ public Flux<Route> getRoutes() {
5758
final Mono<Route> routeMono = mapping.lookupRoute(Mockito.mock(ServerWebExchange.class));
5859

5960
StepVerifier.create(routeMono.map(Route::getId)).expectNext("routeTrue").verifyComplete();
60-
Assertions.assertTrue(capturedOutput.getOut().contains("Error applying predicate for route: routeFail"));
61-
Assertions.assertTrue(capturedOutput.getOut().contains("java.lang.IllegalStateException: boom"));
61+
assertThat(capturedOutput.getOut().contains("Error applying predicate for route: routeFail")).isTrue();
62+
assertThat(capturedOutput.getOut().contains("java.lang.IllegalStateException: boom")).isTrue();
6263
}
6364

6465
@Test
@@ -89,11 +90,11 @@ public void lookupRouteFromAsyncPredicates(CapturedOutput capturedOutput) {
8990

9091
StepVerifier.create(routeMono.map(Route::getId)).expectNext("routeTrue").verifyComplete();
9192

92-
Assertions.assertTrue(capturedOutput.getOut().contains("Error applying predicate for route: routeError"));
93-
Assertions.assertTrue(capturedOutput.getOut().contains("java.lang.IllegalStateException: boom1"));
93+
assertThat(capturedOutput.getOut().contains("Error applying predicate for route: routeError")).isTrue();
94+
assertThat(capturedOutput.getOut().contains("java.lang.IllegalStateException: boom1")).isTrue();
9495

95-
Assertions.assertTrue(capturedOutput.getOut().contains("Error applying predicate for route: routeFail"));
96-
Assertions.assertTrue(capturedOutput.getOut().contains("java.lang.IllegalStateException: boom2"));
96+
assertThat(capturedOutput.getOut().contains("Error applying predicate for route: routeFail")).isTrue();
97+
assertThat(capturedOutput.getOut().contains("java.lang.IllegalStateException: boom2")).isTrue();
9798
}
9899

99100
boolean boom1() {

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ConfigurationServiceTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Map;
2121

2222
import jakarta.validation.constraints.Max;
23-
import org.junit.jupiter.api.Assertions;
2423
import org.junit.jupiter.api.Test;
2524

2625
import org.springframework.boot.context.properties.bind.BindException;
@@ -30,14 +29,15 @@
3029
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
3130

3231
import static org.assertj.core.api.Assertions.assertThat;
32+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3333

3434
public class ConfigurationServiceTests {
3535

3636
@Test
3737
public void validationOnCreateWorks() {
3838
Map<String, Object> map = Collections.singletonMap("config.value", 11);
3939

40-
Assertions.assertThrows(BindException.class, () -> ConfigurationService
40+
assertThatExceptionOfType(BindException.class).isThrownBy(() -> ConfigurationService
4141
.bindOrCreate(Bindable.of(ValidatedConfig.class), map, "config", getValidator(), null));
4242
}
4343

@@ -57,7 +57,7 @@ public void validationOnBindWorks() {
5757

5858
ValidatedConfig config = new ValidatedConfig();
5959

60-
Assertions.assertThrows(BindException.class, () -> ConfigurationService
60+
assertThatExceptionOfType(BindException.class).isThrownBy(() -> ConfigurationService
6161
.bindOrCreate(Bindable.ofInstance(config), map, "config", getValidator(), null));
6262

6363
}

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/CustomBlockHoundIntegrationTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616

1717
package org.springframework.cloud.gateway.test;
1818

19-
import org.junit.jupiter.api.Assertions;
2019
import org.junit.jupiter.api.Disabled;
2120
import org.junit.jupiter.api.Test;
2221
import org.junit.jupiter.api.condition.DisabledForJreRange;
2322
import org.junit.jupiter.api.condition.JRE;
2423
import reactor.core.publisher.Mono;
2524
import reactor.core.scheduler.Schedulers;
2625

26+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
27+
2728
/**
2829
* @author Tim Ysewyn
2930
*/
@@ -34,7 +35,7 @@ public class CustomBlockHoundIntegrationTest {
3435
// Disable this test for now flaky on GitHub Actions
3536
@Disabled
3637
public void shouldThrowErrorForBlockingCallWithCustomBlockHoundIntegration() {
37-
Assertions.assertThrows(RuntimeException.class, () -> Mono.fromCallable(() -> {
38+
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> Mono.fromCallable(() -> {
3839
Thread.sleep(1);
3940
return null;
4041
}).subscribeOn(Schedulers.parallel()).block());

0 commit comments

Comments
 (0)