Browse Source

polish

pull/252/head
Spencer Gibb 7 years ago
parent
commit
c44c28dcad
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 9
      spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientConnectionManagerFactoryTests.java

9
spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientConnectionManagerFactoryTests.java

@ -2,6 +2,7 @@ package org.springframework.cloud.commons.httpclient; @@ -2,6 +2,7 @@ package org.springframework.cloud.commons.httpclient;
import java.lang.reflect.Field;
import java.util.concurrent.TimeUnit;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.junit.Test;
@ -9,7 +10,6 @@ import org.springframework.util.ReflectionUtils; @@ -9,7 +10,6 @@ import org.springframework.util.ReflectionUtils;
import static org.junit.Assert.assertEquals;
/**
* @author Ryan Baxter
*/
@ -22,8 +22,7 @@ public class DefaultApacheHttpClientConnectionManagerFactoryTests { @@ -22,8 +22,7 @@ public class DefaultApacheHttpClientConnectionManagerFactoryTests {
.getDefaultMaxPerRoute());
assertEquals(2,
((PoolingHttpClientConnectionManager) connectionManager).getMaxTotal());
Object pool = getField(((PoolingHttpClientConnectionManager) connectionManager),
"pool");
Object pool = getField((connectionManager), "pool");
assertEquals(-1l, ((Long)getField(pool, "timeToLive")).longValue());
TimeUnit timeUnit = getField(pool, "tunit");
assertEquals(TimeUnit.MILLISECONDS, timeUnit);
@ -37,13 +36,13 @@ public class DefaultApacheHttpClientConnectionManagerFactoryTests { @@ -37,13 +36,13 @@ public class DefaultApacheHttpClientConnectionManagerFactoryTests {
.getDefaultMaxPerRoute());
assertEquals(2,
((PoolingHttpClientConnectionManager) connectionManager).getMaxTotal());
Object pool = getField(((PoolingHttpClientConnectionManager) connectionManager),
"pool");
Object pool = getField((connectionManager), "pool");
assertEquals(56l, ((Long)getField(pool, "timeToLive")).longValue());
TimeUnit timeUnit = getField(pool, "tunit");
assertEquals(TimeUnit.DAYS, timeUnit);
}
@SuppressWarnings("unchecked")
protected <T> T getField(Object target, String name) {
Field field = ReflectionUtils.findField(target.getClass(), name);
ReflectionUtils.makeAccessible(field);

Loading…
Cancel
Save