|
|
|
@ -32,12 +32,15 @@ import org.springframework.context.annotation.Configuration;
@@ -32,12 +32,15 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.test.annotation.DirtiesContext; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
import static org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.DEFAULT_CONNECTION_REQUEST_TIMEOUT; |
|
|
|
|
import static org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.DEFAULT_CONNECTION_REQUEST_TIMEOUT_UNIT; |
|
|
|
|
import static org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.DEFAULT_SOCKET_TIMEOUT; |
|
|
|
|
import static org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.DEFAULT_SOCKET_TIMEOUT_UNIT; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author Ryan Baxter |
|
|
|
|
* @author Nguyen Ky Thanh |
|
|
|
|
* @author changjin wei(魏昌进) |
|
|
|
|
*/ |
|
|
|
|
@DirtiesContext |
|
|
|
|
class FeignHttpClientPropertiesTests { |
|
|
|
@ -67,22 +70,30 @@ class FeignHttpClientPropertiesTests {
@@ -67,22 +70,30 @@ class FeignHttpClientPropertiesTests {
|
|
|
|
|
assertThat(getProperties().getHc5().getPoolReusePolicy()).isEqualTo(PoolReusePolicy.FIFO); |
|
|
|
|
assertThat(getProperties().getHc5().getSocketTimeout()).isEqualTo(DEFAULT_SOCKET_TIMEOUT); |
|
|
|
|
assertThat(getProperties().getHc5().getSocketTimeoutUnit()).isEqualTo(DEFAULT_SOCKET_TIMEOUT_UNIT); |
|
|
|
|
assertThat(getProperties().getHc5().getConnectionRequestTimeout()) |
|
|
|
|
.isEqualTo(DEFAULT_CONNECTION_REQUEST_TIMEOUT); |
|
|
|
|
assertThat(getProperties().getHc5().getConnectionRequestTimeoutUnit()) |
|
|
|
|
.isEqualTo(DEFAULT_CONNECTION_REQUEST_TIMEOUT_UNIT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void testCustomization() { |
|
|
|
|
TestPropertyValues.of("spring.cloud.openfeign.httpclient.maxConnections=2", |
|
|
|
|
"spring.cloud.openfeign.httpclient.connectionTimeout=2", |
|
|
|
|
"spring.cloud.openfeign.httpclient.maxConnectionsPerRoute=2", |
|
|
|
|
"spring.cloud.openfeign.httpclient.timeToLive=2", |
|
|
|
|
"spring.cloud.openfeign.httpclient.disableSslValidation=true", |
|
|
|
|
"spring.cloud.openfeign.httpclient.followRedirects=false", |
|
|
|
|
"spring.cloud.openfeign.httpclient.disableSslValidation=true", |
|
|
|
|
"spring.cloud.openfeign.httpclient.followRedirects=false", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.poolConcurrencyPolicy=lax", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.poolReusePolicy=lifo", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.socketTimeout=200", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.socketTimeoutUnit=milliseconds").applyTo(this.context); |
|
|
|
|
TestPropertyValues |
|
|
|
|
.of("spring.cloud.openfeign.httpclient.maxConnections=2", |
|
|
|
|
"spring.cloud.openfeign.httpclient.connectionTimeout=2", |
|
|
|
|
"spring.cloud.openfeign.httpclient.maxConnectionsPerRoute=2", |
|
|
|
|
"spring.cloud.openfeign.httpclient.timeToLive=2", |
|
|
|
|
"spring.cloud.openfeign.httpclient.disableSslValidation=true", |
|
|
|
|
"spring.cloud.openfeign.httpclient.followRedirects=false", |
|
|
|
|
"spring.cloud.openfeign.httpclient.disableSslValidation=true", |
|
|
|
|
"spring.cloud.openfeign.httpclient.followRedirects=false", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.poolConcurrencyPolicy=lax", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.poolReusePolicy=lifo", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.socketTimeout=200", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.socketTimeoutUnit=milliseconds", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.connectionRequestTimeout=200", |
|
|
|
|
"spring.cloud.openfeign.httpclient.hc5.connectionRequestTimeoutUnit=milliseconds") |
|
|
|
|
.applyTo(this.context); |
|
|
|
|
setupContext(); |
|
|
|
|
assertThat(getProperties().getMaxConnections()).isEqualTo(2); |
|
|
|
|
assertThat(getProperties().getConnectionTimeout()).isEqualTo(2); |
|
|
|
@ -94,6 +105,8 @@ class FeignHttpClientPropertiesTests {
@@ -94,6 +105,8 @@ class FeignHttpClientPropertiesTests {
|
|
|
|
|
assertThat(getProperties().getHc5().getPoolReusePolicy()).isEqualTo(PoolReusePolicy.LIFO); |
|
|
|
|
assertThat(getProperties().getHc5().getSocketTimeout()).isEqualTo(200); |
|
|
|
|
assertThat(getProperties().getHc5().getSocketTimeoutUnit()).isEqualTo(TimeUnit.MILLISECONDS); |
|
|
|
|
assertThat(getProperties().getHc5().getConnectionRequestTimeout()).isEqualTo(200); |
|
|
|
|
assertThat(getProperties().getHc5().getConnectionRequestTimeoutUnit()).isEqualTo(TimeUnit.MILLISECONDS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setupContext() { |
|
|
|
|