Polishing, suppression of deprecation warnings, copyright headers, etc.

This commit is contained in:
Sam Brannen
2022-12-05 13:51:00 -05:00
parent 93ea2e1df9
commit de07ad47f1
14 changed files with 51 additions and 112 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -48,15 +48,15 @@ abstract class AbstractHttpRequestFactoryTests extends AbstractMockWebServerTest
@BeforeEach
final void createFactory() throws Exception {
factory = createRequestFactory();
if (factory instanceof InitializingBean) {
((InitializingBean) factory).afterPropertiesSet();
if (factory instanceof InitializingBean initializingBean) {
initializingBean.afterPropertiesSet();
}
}
@AfterEach
final void destroyFactory() throws Exception {
if (factory instanceof DisposableBean) {
((DisposableBean) factory).destroy();
if (factory instanceof DisposableBean disposableBean) {
disposableBean.destroy();
}
}

View File

@@ -38,7 +38,7 @@ import static org.mockito.Mockito.withSettings;
/**
* @author Stephane Nicoll
*/
public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
@Override
protected ClientHttpRequestFactory createRequestFactory() {
@@ -47,13 +47,14 @@ public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpReq
@Override
@Test
public void httpMethods() throws Exception {
void httpMethods() throws Exception {
super.httpMethods();
assertHttpMethod("patch", HttpMethod.PATCH);
}
@Test
public void assertCustomConfig() throws Exception {
@SuppressWarnings("deprecation")
void assertCustomConfig() throws Exception {
HttpClient httpClient = HttpClientBuilder.create().build();
HttpComponentsClientHttpRequestFactory hrf = new HttpComponentsClientHttpRequestFactory(httpClient);
hrf.setConnectTimeout(1234);
@@ -71,7 +72,9 @@ public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpReq
}
@Test
public void defaultSettingsOfHttpClientMergedOnExecutorCustomization() throws Exception {
@SuppressWarnings("deprecation")
void defaultSettingsOfHttpClientMergedOnExecutorCustomization() throws Exception {
@SuppressWarnings("deprecation")
RequestConfig defaultConfig = RequestConfig.custom().setConnectTimeout(1234, MILLISECONDS).build();
CloseableHttpClient client = mock(CloseableHttpClient.class,
withSettings().extraInterfaces(Configurable.class));
@@ -90,7 +93,8 @@ public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpReq
}
@Test
public void localSettingsOverrideClientDefaultSettings() throws Exception {
@SuppressWarnings("deprecation")
void localSettingsOverrideClientDefaultSettings() throws Exception {
RequestConfig defaultConfig = RequestConfig.custom()
.setConnectTimeout(1234, MILLISECONDS)
.setConnectionRequestTimeout(6789, MILLISECONDS)
@@ -109,11 +113,12 @@ public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpReq
}
@Test
public void mergeBasedOnCurrentHttpClient() throws Exception {
@SuppressWarnings("deprecation")
void mergeBasedOnCurrentHttpClient() throws Exception {
RequestConfig defaultConfig = RequestConfig.custom()
.setConnectionRequestTimeout(1234, MILLISECONDS)
.build();
final CloseableHttpClient client = mock(CloseableHttpClient.class,
CloseableHttpClient client = mock(CloseableHttpClient.class,
withSettings().extraInterfaces(Configurable.class));
Configurable configurable = (Configurable) client;
given(configurable.getConfig()).willReturn(defaultConfig);

View File

@@ -18,7 +18,6 @@ package org.springframework.web.service.invoker;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.util.ObjectUtils;
@@ -29,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link CookieValueArgumentResolver}.
*
* <p>For base class functionality, see {@link NamedValueArgumentResolverTests}.
*
* @author Rossen Stoyanchev
@@ -37,18 +37,9 @@ class CookieValueArgumentResolverTests {
private final TestHttpClientAdapter client = new TestHttpClientAdapter();
private Service service;
private final Service service = HttpServiceProxyFactory.builder(this.client).build().createClient(Service.class);
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}
// Base class functionality should be tested in NamedValueArgumentResolverTests.
@Test
void cookieValue() {
this.service.execute("test");

View File

@@ -16,7 +16,6 @@
package org.springframework.web.service.invoker;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpMethod;
@@ -34,18 +33,11 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Olga Maciaszek-Sharma
* @author Rossen Stoyanchev
*/
public class HttpMethodArgumentResolverTests {
class HttpMethodArgumentResolverTests {
private final TestHttpClientAdapter client = new TestHttpClientAdapter();
private Service service;
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}
private final Service service = HttpServiceProxyFactory.builder(this.client).build().createClient(Service.class);
@Test

View File

@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class HttpRequestValuesTests {
class HttpRequestValuesTests {
@Test
void defaultUri() {
@@ -49,6 +49,7 @@ public class HttpRequestValuesTests {
@ParameterizedTest
@ValueSource(strings = {"POST", "PUT", "PATCH"})
@SuppressWarnings("unchecked")
void requestParamAsFormData(String httpMethod) {
HttpRequestValues requestValues = HttpRequestValues.builder().setHttpMethod(HttpMethod.valueOf(httpMethod))

View File

@@ -21,7 +21,6 @@ import java.util.Optional;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Single;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -52,20 +51,13 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
*
* @author Rossen Stoyanchev
*/
public class HttpServiceMethodTests {
class HttpServiceMethodTests {
private static final ParameterizedTypeReference<String> BODY_TYPE = new ParameterizedTypeReference<>() {};
private final TestHttpClientAdapter client = new TestHttpClientAdapter();
private HttpServiceProxyFactory proxyFactory;
@BeforeEach
void setUp() throws Exception {
this.proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
}
private final HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
@Test

View File

@@ -16,7 +16,6 @@
package org.springframework.web.service.invoker;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.lang.Nullable;
@@ -27,6 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link PathVariableArgumentResolver}.
*
* <p>For base class functionality, see {@link NamedValueArgumentResolverTests}.
*
* @author Olga Maciaszek-Sharma
@@ -36,18 +36,9 @@ class PathVariableArgumentResolverTests {
private final TestHttpClientAdapter client = new TestHttpClientAdapter();
private Service service;
private final Service service = HttpServiceProxyFactory.builder(this.client).build().createClient(Service.class);
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}
// Base class functionality should be tested in NamedValueArgumentResolverTests.
@Test
void pathVariable() {
this.service.execute("test");

View File

@@ -16,7 +16,6 @@
package org.springframework.web.service.invoker;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.lang.Nullable;
@@ -35,18 +34,9 @@ class RequestAttributeArgumentResolverTests {
private final TestHttpClientAdapter client = new TestHttpClientAdapter();
private Service service;
private final Service service = HttpServiceProxyFactory.builder(this.client).build().createClient(Service.class);
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}
// Base class functionality should be tested in NamedValueArgumentResolverTests.
@Test
void cookieValue() {
this.service.execute("test");

View File

@@ -18,7 +18,6 @@ package org.springframework.web.service.invoker;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Single;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;
@@ -36,18 +35,11 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
*
* @author Rossen Stoyanchev
*/
public class RequestBodyArgumentResolverTests {
class RequestBodyArgumentResolverTests {
private final TestHttpClientAdapter client = new TestHttpClientAdapter();
private Service service;
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}
private final Service service = HttpServiceProxyFactory.builder(this.client).build().createClient(Service.class);
@Test

View File

@@ -18,7 +18,6 @@ package org.springframework.web.service.invoker;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.util.MultiValueMap;
@@ -38,24 +37,15 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class RequestParamArgumentResolverTests {
class RequestParamArgumentResolverTests {
private final TestHttpClientAdapter client = new TestHttpClientAdapter();
private Service service;
private final Service service = HttpServiceProxyFactory.builder(this.client).build().createClient(Service.class);
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}
// Base class functionality should be tested in NamedValueArgumentResolverTests.
// Form data vs query params tested in HttpRequestValuesTests.
@Test
@SuppressWarnings("unchecked")
void requestParam() {
this.service.postForm("value 1", "value 2");

View File

@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class RequestPartArgumentResolverTests {
class RequestPartArgumentResolverTests {
private final TestHttpClientAdapter client = new TestHttpClientAdapter();

View File

@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
*
* @author Rossen Stoyanchev
*/
public class UrlArgumentResolverTests {
class UrlArgumentResolverTests {
private final TestHttpClientAdapter client = new TestHttpClientAdapter();