|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2024 the original author or authors. |
|
|
|
* Copyright 2002-2025 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -21,7 +21,9 @@ import java.io.IOException; |
|
|
|
import java.net.URI; |
|
|
|
import java.net.URI; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.Duration; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
import java.util.function.Consumer; |
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
|
|
import okhttp3.mockwebserver.MockResponse; |
|
|
|
import okhttp3.mockwebserver.MockResponse; |
|
|
|
@ -39,6 +41,7 @@ import org.springframework.util.LinkedMultiValueMap; |
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
import org.springframework.web.bind.annotation.RequestAttribute; |
|
|
|
import org.springframework.web.bind.annotation.RequestAttribute; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RequestPart; |
|
|
|
import org.springframework.web.bind.annotation.RequestPart; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
@ -168,6 +171,22 @@ class WebClientAdapterTests { |
|
|
|
"Content-Type: text/plain;charset=UTF-8", "Content-Length: 5", "test2"); |
|
|
|
"Content-Type: text/plain;charset=UTF-8", "Content-Length: 5", "test2"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test // gh-34793
|
|
|
|
|
|
|
|
void postSet() throws InterruptedException { |
|
|
|
|
|
|
|
prepareResponse(response -> response.setResponseCode(201)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set<Person> persons = new LinkedHashSet<>(); |
|
|
|
|
|
|
|
persons.add(new Person("John")); |
|
|
|
|
|
|
|
persons.add(new Person("Richard")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initService().postPersonSet(persons); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecordedRequest request = server.takeRequest(); |
|
|
|
|
|
|
|
assertThat(request.getMethod()).isEqualTo("POST"); |
|
|
|
|
|
|
|
assertThat(request.getPath()).isEqualTo("/persons"); |
|
|
|
|
|
|
|
assertThat(request.getBody().readUtf8()).isEqualTo("[{\"name\":\"John\"},{\"name\":\"Richard\"}]"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void uriBuilderFactory() throws Exception { |
|
|
|
void uriBuilderFactory() throws Exception { |
|
|
|
String ignoredResponseBody = "hello"; |
|
|
|
String ignoredResponseBody = "hello"; |
|
|
|
@ -251,6 +270,9 @@ class WebClientAdapterTests { |
|
|
|
@PostExchange |
|
|
|
@PostExchange |
|
|
|
void postMultipart(MultipartFile file, @RequestPart String anotherPart); |
|
|
|
void postMultipart(MultipartFile file, @RequestPart String anotherPart); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostExchange("/persons") |
|
|
|
|
|
|
|
void postPersonSet(@RequestBody Set<Person> set); |
|
|
|
|
|
|
|
|
|
|
|
@GetExchange("/greeting") |
|
|
|
@GetExchange("/greeting") |
|
|
|
String getWithUriBuilderFactory(UriBuilderFactory uriBuilderFactory); |
|
|
|
String getWithUriBuilderFactory(UriBuilderFactory uriBuilderFactory); |
|
|
|
|
|
|
|
|
|
|
|
@ -263,4 +285,19 @@ class WebClientAdapterTests { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static final class Person { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final String name; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Person(String name) { |
|
|
|
|
|
|
|
this.name = name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getName() { |
|
|
|
|
|
|
|
return this.name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|