Merge branch '6.2.x'

This commit is contained in:
rstoyanchev
2025-04-25 21:33:03 +01:00
9 changed files with 176 additions and 31 deletions
@@ -22,7 +22,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.net.URI;
import java.util.LinkedHashSet;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.stream.Stream;
@@ -284,6 +286,19 @@ class RestClientAdapterTests {
assertThat(request.getHeader("X-API-Version")).isEqualTo("1.2");
}
@ParameterizedAdapterTest // gh-34793
void postSet(MockWebServer server, Service service) throws InterruptedException {
Set<Person> persons = new LinkedHashSet<>();
persons.add(new Person("John"));
persons.add(new Person("Richard"));
service.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\"}]");
}
private static MockWebServer anotherServer() {
MockWebServer server = new MockWebServer();
@@ -317,6 +332,9 @@ class RestClientAdapterTests {
@PostExchange
void postMultipart(MultipartFile file, @RequestPart String anotherPart);
@PostExchange(url = "/persons", contentType = MediaType.APPLICATION_JSON_VALUE)
void postPersonSet(@RequestBody Set<Person> set);
@PutExchange
void putWithCookies(@CookieValue String firstCookie, @CookieValue String secondCookie);
@@ -335,4 +353,19 @@ class RestClientAdapterTests {
ResponseEntity<String> getWithIgnoredUriBuilderFactory(URI uri, UriBuilderFactory uriBuilderFactory);
}
static final class Person {
private final String name;
Person(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
}
@@ -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");
* you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@ class RequestBodyArgumentResolverTests {
this.service.execute(body);
assertThat(getBodyValue()).isEqualTo(body);
assertThat(getBodyValueType()).isEqualTo(new ParameterizedTypeReference<String>() {});
assertThat(getPublisherBody()).isNull();
}
@@ -172,6 +173,10 @@ class RequestBodyArgumentResolverTests {
return getReactiveRequestValues().getBodyValue();
}
private @Nullable ParameterizedTypeReference<?> getBodyValueType() {
return getReactiveRequestValues().getBodyValueType();
}
private @Nullable Publisher<?> getPublisherBody() {
return getReactiveRequestValues().getBodyPublisher();
}