Adapt to API change in Spring Framework 5.3.0 snapshots
See gh-23534
This commit is contained in:
@@ -67,7 +67,6 @@ import org.springframework.security.web.server.WebFilterChainProxy;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -270,7 +269,7 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
||||
"cloudFoundrySecurityService");
|
||||
WebClient webClient = (WebClient) ReflectionTestUtils.getField(interceptorSecurityService,
|
||||
"webClient");
|
||||
webClient.get().uri("https://self-signed.badssl.com/").exchangeToMono(ClientResponse::releaseBody)
|
||||
webClient.get().uri("https://self-signed.badssl.com/").retrieve().toBodilessEntity()
|
||||
.block(Duration.ofSeconds(30));
|
||||
});
|
||||
}
|
||||
@@ -288,8 +287,8 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
||||
WebClient webClient = (WebClient) ReflectionTestUtils.getField(interceptorSecurityService,
|
||||
"webClient");
|
||||
assertThatExceptionOfType(RuntimeException.class)
|
||||
.isThrownBy(() -> webClient.get().uri("https://self-signed.badssl.com/")
|
||||
.exchangeToMono(ClientResponse::releaseBody).block(Duration.ofSeconds(30)))
|
||||
.isThrownBy(() -> webClient.get().uri("https://self-signed.badssl.com/").retrieve()
|
||||
.toBodilessEntity().block(Duration.ofSeconds(30)))
|
||||
.withCauseInstanceOf(SSLException.class);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.client.reactive.ClientHttpConnector;
|
||||
import org.springframework.mock.http.client.reactive.MockClientHttpResponse;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -112,7 +111,7 @@ class WebClientMetricsConfigurationTests {
|
||||
WebClient webClient = mockWebClient(context.getBean(WebClient.Builder.class));
|
||||
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
webClient.get().uri("https://example.org/projects/" + i).exchangeToMono(ClientResponse::releaseBody)
|
||||
webClient.get().uri("https://example.org/projects/" + i).retrieve().toBodilessEntity()
|
||||
.block(Duration.ofSeconds(30));
|
||||
}
|
||||
return registry;
|
||||
@@ -121,8 +120,8 @@ class WebClientMetricsConfigurationTests {
|
||||
private void validateWebClient(WebClient.Builder builder, MeterRegistry registry) {
|
||||
WebClient webClient = mockWebClient(builder);
|
||||
assertThat(registry.find("http.client.requests").meter()).isNull();
|
||||
webClient.get().uri("https://example.org/projects/{project}", "spring-boot")
|
||||
.exchangeToMono(ClientResponse::releaseBody).block(Duration.ofSeconds(30));
|
||||
webClient.get().uri("https://example.org/projects/{project}", "spring-boot").retrieve().toBodilessEntity()
|
||||
.block(Duration.ofSeconds(30));
|
||||
assertThat(registry.find("http.client.requests").tags("uri", "/projects/{project}").meter()).isNotNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.util.SocketUtils;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
||||
|
||||
@@ -282,16 +281,14 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||
@Test
|
||||
protected void compressionOfResponseToGetRequest() {
|
||||
WebClient client = prepareCompressionTest();
|
||||
ResponseEntity<Void> response = client.get().exchangeToMono(ClientResponse::toBodilessEntity)
|
||||
.block(Duration.ofSeconds(30));
|
||||
ResponseEntity<Void> response = client.get().retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
assertResponseIsCompressed(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
protected void compressionOfResponseToPostRequest() {
|
||||
WebClient client = prepareCompressionTest();
|
||||
ResponseEntity<Void> response = client.post().exchangeToMono(ClientResponse::toBodilessEntity)
|
||||
.block(Duration.ofSeconds(30));
|
||||
ResponseEntity<Void> response = client.post().retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
assertResponseIsCompressed(response);
|
||||
}
|
||||
|
||||
@@ -301,8 +298,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||
compression.setEnabled(true);
|
||||
compression.setMinResponseSize(DataSize.ofBytes(3001));
|
||||
WebClient client = prepareCompressionTest(compression);
|
||||
ResponseEntity<Void> response = client.get().exchangeToMono(ClientResponse::toBodilessEntity)
|
||||
.block(Duration.ofSeconds(30));
|
||||
ResponseEntity<Void> response = client.get().retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
assertResponseIsNotCompressed(response);
|
||||
}
|
||||
|
||||
@@ -312,8 +308,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||
compression.setEnabled(true);
|
||||
compression.setMimeTypes(new String[] { "application/json" });
|
||||
WebClient client = prepareCompressionTest(compression);
|
||||
ResponseEntity<Void> response = client.get().exchangeToMono(ClientResponse::toBodilessEntity)
|
||||
.block(Duration.ofSeconds(30));
|
||||
ResponseEntity<Void> response = client.get().retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
assertResponseIsNotCompressed(response);
|
||||
}
|
||||
|
||||
@@ -323,8 +318,8 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||
compression.setEnabled(true);
|
||||
compression.setExcludedUserAgents(new String[] { "testUserAgent" });
|
||||
WebClient client = prepareCompressionTest(compression);
|
||||
ResponseEntity<Void> response = client.get().header("User-Agent", "testUserAgent")
|
||||
.exchangeToMono(ClientResponse::toBodilessEntity).block(Duration.ofSeconds(30));
|
||||
ResponseEntity<Void> response = client.get().header("User-Agent", "testUserAgent").retrieve().toBodilessEntity()
|
||||
.block(Duration.ofSeconds(30));
|
||||
assertResponseIsNotCompressed(response);
|
||||
}
|
||||
|
||||
@@ -334,8 +329,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||
compression.setEnabled(true);
|
||||
compression.setMimeTypes(new String[] { "application/json" });
|
||||
WebClient client = prepareCompressionTest(compression, "test~plain");
|
||||
ResponseEntity<Void> response = client.get().exchangeToMono(ClientResponse::toBodilessEntity)
|
||||
.block(Duration.ofSeconds(30));
|
||||
ResponseEntity<Void> response = client.get().retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
assertResponseIsNotCompressed(response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user