Polishing
Closes gh-31413
This commit is contained in:
@@ -172,8 +172,7 @@ public class WebClientAdapterTests {
|
||||
void uriBuilderFactory() throws Exception {
|
||||
String ignoredResponseBody = "hello";
|
||||
prepareResponse(response -> response.setResponseCode(200).setBody(ignoredResponseBody));
|
||||
UriBuilderFactory factory = new DefaultUriBuilderFactory(this.anotherServer.url("/")
|
||||
.toString());
|
||||
UriBuilderFactory factory = new DefaultUriBuilderFactory(this.anotherServer.url("/").toString());
|
||||
|
||||
String actualBody = initService().getWithUriBuilderFactory(factory);
|
||||
|
||||
@@ -186,14 +185,12 @@ public class WebClientAdapterTests {
|
||||
void uriBuilderFactoryWithPathVariableAndRequestParam() throws Exception {
|
||||
String ignoredResponseBody = "hello";
|
||||
prepareResponse(response -> response.setResponseCode(200).setBody(ignoredResponseBody));
|
||||
UriBuilderFactory factory = new DefaultUriBuilderFactory(this.anotherServer.url("/")
|
||||
.toString());
|
||||
UriBuilderFactory factory = new DefaultUriBuilderFactory(this.anotherServer.url("/").toString());
|
||||
|
||||
String actualBody = initService().getWithUriBuilderFactory(factory, "123", "test");
|
||||
|
||||
assertThat(actualBody).isEqualTo(ANOTHER_SERVER_RESPONSE_BODY);
|
||||
assertThat(this.anotherServer.takeRequest().getPath())
|
||||
.isEqualTo("/greeting/123?param=test");
|
||||
assertThat(this.anotherServer.takeRequest().getPath()).isEqualTo("/greeting/123?param=test");
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@@ -202,8 +199,7 @@ public class WebClientAdapterTests {
|
||||
String expectedResponseBody = "hello";
|
||||
prepareResponse(response -> response.setResponseCode(200).setBody(expectedResponseBody));
|
||||
URI dynamicUri = this.server.url("/greeting/123").uri();
|
||||
UriBuilderFactory factory = new DefaultUriBuilderFactory(this.anotherServer.url("/")
|
||||
.toString());
|
||||
UriBuilderFactory factory = new DefaultUriBuilderFactory(this.anotherServer.url("/").toString());
|
||||
|
||||
String actualBody = initService().getWithIgnoredUriBuilderFactory(dynamicUri, factory);
|
||||
|
||||
@@ -216,8 +212,7 @@ public class WebClientAdapterTests {
|
||||
private static MockWebServer anotherServer() {
|
||||
MockWebServer anotherServer = new MockWebServer();
|
||||
MockResponse response = new MockResponse();
|
||||
response.setHeader("Content-Type", "text/plain")
|
||||
.setBody(ANOTHER_SERVER_RESPONSE_BODY);
|
||||
response.setHeader("Content-Type", "text/plain").setBody(ANOTHER_SERVER_RESPONSE_BODY);
|
||||
anotherServer.enqueue(response);
|
||||
return anotherServer;
|
||||
}
|
||||
|
||||
@@ -135,17 +135,12 @@ class KotlinWebClientHttpServiceProxyTests {
|
||||
@Throws(InterruptedException::class)
|
||||
fun getWithFactoryPathVariableAndRequestParam() {
|
||||
prepareResponse { response: MockResponse ->
|
||||
response.setHeader(
|
||||
"Content-Type",
|
||||
"text/plain"
|
||||
).setBody("Hello Spring!")
|
||||
response.setHeader("Content-Type", "text/plain").setBody("Hello Spring!")
|
||||
}
|
||||
val factory: UriBuilderFactory = DefaultUriBuilderFactory(anotherServer.url("/")
|
||||
.toString())
|
||||
val factory: UriBuilderFactory = DefaultUriBuilderFactory(anotherServer.url("/").toString())
|
||||
|
||||
val actualResponse: ResponseEntity<String> = initHttpService()
|
||||
.getWithUriBuilderFactory(factory, "123",
|
||||
"test")
|
||||
val actualResponse: ResponseEntity<String> =
|
||||
initHttpService().getWithUriBuilderFactory(factory, "123", "test")
|
||||
|
||||
val request = anotherServer.takeRequest()
|
||||
assertThat(actualResponse.statusCode).isEqualTo(HttpStatus.OK)
|
||||
@@ -159,17 +154,13 @@ class KotlinWebClientHttpServiceProxyTests {
|
||||
@Throws(InterruptedException::class)
|
||||
fun getWithIgnoredUriBuilderFactory() {
|
||||
prepareResponse { response: MockResponse ->
|
||||
response.setHeader(
|
||||
"Content-Type",
|
||||
"text/plain"
|
||||
).setBody("Hello Spring!")
|
||||
response.setHeader("Content-Type", "text/plain").setBody("Hello Spring!")
|
||||
}
|
||||
val dynamicUri = server.url("/greeting/123").uri()
|
||||
val factory: UriBuilderFactory = DefaultUriBuilderFactory(anotherServer.url("/")
|
||||
.toString())
|
||||
val factory: UriBuilderFactory = DefaultUriBuilderFactory(anotherServer.url("/").toString())
|
||||
|
||||
val actualResponse: ResponseEntity<String> = initHttpService()
|
||||
.getWithIgnoredUriBuilderFactory(dynamicUri, factory)
|
||||
val actualResponse: ResponseEntity<String> =
|
||||
initHttpService().getWithIgnoredUriBuilderFactory(dynamicUri, factory)
|
||||
|
||||
val request = server.takeRequest()
|
||||
assertThat(actualResponse.statusCode).isEqualTo(HttpStatus.OK)
|
||||
@@ -181,9 +172,7 @@ class KotlinWebClientHttpServiceProxyTests {
|
||||
|
||||
|
||||
private fun initHttpService(): TestHttpService {
|
||||
val webClient = WebClient.builder().baseUrl(
|
||||
server.url("/").toString()
|
||||
).build()
|
||||
val webClient = WebClient.builder().baseUrl(server.url("/").toString()).build()
|
||||
return initHttpService(webClient)
|
||||
}
|
||||
|
||||
@@ -220,8 +209,8 @@ class KotlinWebClientHttpServiceProxyTests {
|
||||
suspend fun getGreetingSuspendingWithAttribute(@RequestAttribute myAttribute: String): String
|
||||
|
||||
@GetExchange("/greeting/{id}")
|
||||
fun getWithUriBuilderFactory(uriBuilderFactory: UriBuilderFactory?,
|
||||
@PathVariable id: String?, @RequestParam param: String?): ResponseEntity<String>
|
||||
fun getWithUriBuilderFactory(
|
||||
uriBuilderFactory: UriBuilderFactory?, @PathVariable id: String?, @RequestParam param: String?): ResponseEntity<String>
|
||||
|
||||
@GetExchange("/greeting")
|
||||
fun getWithIgnoredUriBuilderFactory(uri: URI?, uriBuilderFactory: UriBuilderFactory?): ResponseEntity<String>
|
||||
|
||||
Reference in New Issue
Block a user