diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/CookieValueArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/CookieValueArgumentResolverTests.java
index 0ff41756b0..744b98bf7e 100644
--- a/spring-web/src/test/java/org/springframework/web/service/invoker/CookieValueArgumentResolverTests.java
+++ b/spring-web/src/test/java/org/springframework/web/service/invoker/CookieValueArgumentResolverTests.java
@@ -17,125 +17,39 @@
package org.springframework.web.service.invoker;
import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import org.apache.groovy.util.Maps;
import org.junit.jupiter.api.Test;
-import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.service.annotation.GetExchange;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Unit tests for {@link RequestHeaderArgumentResolver}.
+ *
For base class functionality, see {@link NamedValueArgumentResolverTests}.
*
* @author Rossen Stoyanchev
*/
class CookieValueArgumentResolverTests {
- private final TestHttpClientAdapter clientAdapter = new TestHttpClientAdapter();
+ private final TestHttpClientAdapter client = new TestHttpClientAdapter();
- private final Service service = this.clientAdapter.createService(Service.class);
+ private final Service service = HttpServiceProxyFactory.builder(this.client).build().createClient(Service.class);
+ // Base class functionality should be tested in NamedValueArgumentResolverTests.
+
@Test
- void stringCookie() {
- this.service.executeString("test");
- assertCookie("cookie", "test");
- }
-
- @Test
- void objectCookie() {
- this.service.execute(Boolean.TRUE);
- assertCookie("cookie", "true");
- }
-
- @Test
- void listCookie() {
- this.service.executeList(List.of("test1", Boolean.TRUE, "test3"));
- assertCookie("multiValueCookie", "test1", "true", "test3");
- }
-
- @Test
- void arrayCookie() {
- this.service.executeArray("test1", Boolean.FALSE, "test3");
- assertCookie("multiValueCookie", "test1", "false", "test3");
- }
-
- @Test
- void namedCookie() {
- this.service.executeNamed("test");
- assertCookie("cookieRenamed", "test");
- }
-
- @SuppressWarnings("ConstantConditions")
- @Test
- void nullCookieRequired() {
- assertThatIllegalArgumentException().isThrownBy(() -> this.service.executeString(null));
- }
-
- @Test
- void nullCookieNotRequired() {
- this.service.executeNotRequired(null);
- assertCookie("cookie");
- }
-
- @Test
- void nullCookieWithDefaultValue() {
- this.service.executeWithDefaultValue(null);
- assertCookie("cookie", "default");
- }
-
- @Test
- void optionalStringCookie() {
- this.service.executeOptional(Optional.of("test"));
- assertCookie("cookie", "test");
- }
-
- @Test
- void optionalObjectCookie() {
- this.service.executeOptional(Optional.of(Boolean.TRUE));
- assertCookie("cookie", "true");
- }
-
- @Test
- void optionalEmpty() {
- this.service.executeOptional(Optional.empty());
- assertCookie("cookie");
- }
-
- @Test
- void optionalEmpthyWithDefaultValue() {
- this.service.executeOptionalWithDefaultValue(Optional.empty());
- assertCookie("cookie", "default");
- }
-
- @Test
- void mapOfCookies() {
- this.service.executeMap(Maps.of("cookie1", "true", "cookie2", "false"));
- assertCookie("cookie1", "true");
- assertCookie("cookie2", "false");
- }
-
- @Test
- void mapOfCookiesIsNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> this.service.executeMap(null));
- }
-
- @Test
- void mapOfCookiesHasOptionalValue() {
- this.service.executeMapWithOptionalValue(Map.of("cookie", Optional.of("test")));
+ void cookieValue() {
+ this.service.execute("test");
assertCookie("cookie", "test");
}
private void assertCookie(String key, String... values) {
- List actualValues = this.clientAdapter.getRequestValues().getCookies().get(key);
+ List actualValues = this.client.getRequestValues().getCookies().get(key);
if (ObjectUtils.isEmpty(values)) {
assertThat(actualValues).isNull();
}
@@ -145,41 +59,10 @@ class CookieValueArgumentResolverTests {
}
- @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private interface Service {
@GetExchange
- void executeString(@CookieValue String cookie);
-
- @GetExchange
- void execute(@CookieValue Object cookie);
-
- @GetExchange
- void executeList(@CookieValue List