tests for hierarchical unsetting of default proxy

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@618138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Roland Weber 2008-02-04 00:58:42 +00:00
parent b0dc5a5d6a
commit 55ffbe1b6c
1 changed files with 42 additions and 0 deletions

View File

@ -40,9 +40,14 @@ import junit.framework.TestSuite;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.params.HttpParams; import org.apache.http.params.HttpParams;
import org.apache.http.params.BasicHttpParams; import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.DefaultedHttpParams;
import org.apache.http.conn.params.HttpConnectionManagerParams; import org.apache.http.conn.params.HttpConnectionManagerParams;
import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoute;
// for hierarchy testing
import org.apache.http.impl.client.ClientParamsStack;
/** /**
* Unit tests for parameters. * Unit tests for parameters.
@ -127,6 +132,43 @@ public class TestRouteParams extends TestCase {
} }
public void testUnsetHierarchy() {
// hierarchical unsetting is only tested for the default proxy
HttpParams daddy = new BasicHttpParams();
HttpParams dummy = new BasicHttpParams();
HttpParams child = new BasicHttpParams();
HttpRouteParams.setDefaultProxy(daddy, TARGET1);
HttpRouteParams.setDefaultProxy(child, HttpRouteParams.NO_HOST);
HttpParams hierarchy =
new ClientParamsStack(null, daddy, child, null);
assertNull("1", HttpRouteParams.getDefaultProxy(hierarchy));
hierarchy = new ClientParamsStack
(null,
daddy,
new ClientParamsStack(null, child, dummy, null),
null);
assertNull("2", HttpRouteParams.getDefaultProxy(hierarchy));
hierarchy = new ClientParamsStack
(null, daddy, new DefaultedHttpParams(child, dummy), null);
assertNull("3", HttpRouteParams.getDefaultProxy(hierarchy));
hierarchy = new DefaultedHttpParams(child, daddy);
assertNull("4", HttpRouteParams.getDefaultProxy(hierarchy));
hierarchy = new DefaultedHttpParams
(new DefaultedHttpParams(child, dummy), daddy);
assertNull("5", HttpRouteParams.getDefaultProxy(hierarchy));
hierarchy = new DefaultedHttpParams
(child, new DefaultedHttpParams(dummy, daddy));
assertNull("6", HttpRouteParams.getDefaultProxy(hierarchy));
}
public void testBadArgs() { public void testBadArgs() {
try { try {