diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/cors/CorsTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/cors/CorsTests.java index 982a1b98..9d3bee78 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/cors/CorsTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/cors/CorsTests.java @@ -46,8 +46,7 @@ public class CorsTests extends BaseWebClientTests { @Test public void testPreFlightCorsRequest() { ClientResponse clientResponse = webClient.options().uri("/abc/123/function").header("Origin", "domain.com") - .header("Access-Control-Request-Method", "GET") - .exchangeToMono(Mono::just).block(); + .header("Access-Control-Request-Method", "GET").exchangeToMono(Mono::just).block(); HttpHeaders asHttpHeaders = clientResponse.headers().asHttpHeaders(); Mono bodyToMono = clientResponse.bodyToMono(String.class); // pre-flight request shouldn't return the response body @@ -63,10 +62,7 @@ public class CorsTests extends BaseWebClientTests { @Test public void testCorsRequest() { ResponseEntity response = webClient.get().uri("/abc/123/function").header("Origin", "domain.com") - .header(HttpHeaders.HOST, "www.path.org") - .retrieve() - .toEntity(String.class) - .block(); + .header(HttpHeaders.HOST, "www.path.org").retrieve().toEntity(String.class).block(); assertThat(response).isNotNull(); assertThat(response.getBody()).isNotNull(); assertThat(response.getHeaders().getAccessControlAllowOrigin()) diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java index 9f65379f..32253ea3 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java @@ -93,15 +93,13 @@ public class PathRoutePredicateFactoryTests extends BaseWebClientTests { @Test public void matchOptionalTrailingSeparatorCopiedToMatchTrailingSlash() { - Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB")) - .setMatchTrailingSlash(false); + Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB")).setMatchTrailingSlash(false); assertThat(config.isMatchTrailingSlash()).isEqualTo(false); } @Test public void toStringFormat() { - Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB")) - .setMatchTrailingSlash(false); + Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB")).setMatchTrailingSlash(false); Predicate predicate = new PathRoutePredicateFactory().apply(config); assertThat(predicate.toString()).contains("patternA").contains("patternB").contains("false"); } diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ConfigurationServiceTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ConfigurationServiceTests.java index b8947094..ebc41f37 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ConfigurationServiceTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ConfigurationServiceTests.java @@ -38,7 +38,8 @@ public class ConfigurationServiceTests { public void validationOnCreateWorks() { Map map = Collections.singletonMap("config.value", 11); - Assert.assertThrows(BindException.class, () -> ConfigurationService.bindOrCreate(Bindable.of(ValidatedConfig.class), map, "config", getValidator(), null)); + Assert.assertThrows(BindException.class, () -> ConfigurationService + .bindOrCreate(Bindable.of(ValidatedConfig.class), map, "config", getValidator(), null)); } @Test @@ -57,7 +58,8 @@ public class ConfigurationServiceTests { ValidatedConfig config = new ValidatedConfig(); - Assert.assertThrows(BindException.class, () -> ConfigurationService.bindOrCreate(Bindable.ofInstance(config), map, "config", getValidator(), null)); + Assert.assertThrows(BindException.class, () -> ConfigurationService.bindOrCreate(Bindable.ofInstance(config), + map, "config", getValidator(), null)); } diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/sse/SseIntegrationTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/sse/SseIntegrationTests.java index 476878d2..101a4b9e 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/sse/SseIntegrationTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/sse/SseIntegrationTests.java @@ -123,16 +123,16 @@ public class SseIntegrationTests { @Test public void sseAsString() { - Flux result = this.webClient.get().uri("/string").accept(TEXT_EVENT_STREAM) - .retrieve().bodyToFlux(String.class); + Flux result = this.webClient.get().uri("/string").accept(TEXT_EVENT_STREAM).retrieve() + .bodyToFlux(String.class); StepVerifier.create(result).expectNext("foo 0").expectNext("foo 1").thenCancel().verify(Duration.ofSeconds(5L)); } @Test public void sseAsPerson() { - Flux result = this.webClient.get().uri("/person").accept(TEXT_EVENT_STREAM) - .retrieve().bodyToFlux(Person.class); + Flux result = this.webClient.get().uri("/person").accept(TEXT_EVENT_STREAM).retrieve() + .bodyToFlux(Person.class); StepVerifier.create(result).expectNext(new Person("foo 0")).expectNext(new Person("foo 1")).thenCancel() .verify(Duration.ofSeconds(5L)); @@ -142,8 +142,9 @@ public class SseIntegrationTests { @SuppressWarnings("Duplicates") public void sseAsEvent() { ResolvableType type = forClassWithGenerics(ServerSentEvent.class, String.class); - Flux> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM) - .retrieve().bodyToFlux(new ParameterizedTypeReference>() { }); + Flux> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM).retrieve() + .bodyToFlux(new ParameterizedTypeReference>() { + }); StepVerifier.create(result).consumeNextWith(event -> { assertThat(event.id()).isEqualTo("0"); @@ -163,8 +164,9 @@ public class SseIntegrationTests { @Test @SuppressWarnings("Duplicates") public void sseAsEventWithoutAcceptHeader() { - Flux> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM) - .retrieve().bodyToFlux(new ParameterizedTypeReference>() { }); + Flux> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM).retrieve() + .bodyToFlux(new ParameterizedTypeReference>() { + }); StepVerifier.create(result).consumeNextWith(event -> { assertThat(event.id()).isEqualTo("0"); diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/support/ReactorHttpServer.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/support/ReactorHttpServer.java index ad6faee4..24d80198 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/support/ReactorHttpServer.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/support/ReactorHttpServer.java @@ -36,9 +36,7 @@ public class ReactorHttpServer extends AbstractHttpServer { @Override protected void initServer() { this.reactorHandler = createHttpHandlerAdapter(); - this.reactorServer = reactor.netty.http.server.HttpServer.create() - .host(getHost()) - .port(getPort()); + this.reactorServer = reactor.netty.http.server.HttpServer.create().host(getHost()).port(getPort()); }