From 55ffbe1b6c28debc5e025de4bf76722dfdd0d803 Mon Sep 17 00:00:00 2001 From: Roland Weber Date: Mon, 4 Feb 2008 00:58:42 +0000 Subject: [PATCH] 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 --- .../http/conn/params/TestRouteParams.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/module-client/src/test/java/org/apache/http/conn/params/TestRouteParams.java b/module-client/src/test/java/org/apache/http/conn/params/TestRouteParams.java index 105bc55c0..75b42060c 100644 --- a/module-client/src/test/java/org/apache/http/conn/params/TestRouteParams.java +++ b/module-client/src/test/java/org/apache/http/conn/params/TestRouteParams.java @@ -40,9 +40,14 @@ import junit.framework.TestSuite; import org.apache.http.HttpHost; import org.apache.http.params.HttpParams; import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.DefaultedHttpParams; import org.apache.http.conn.params.HttpConnectionManagerParams; import org.apache.http.conn.routing.HttpRoute; +// for hierarchy testing +import org.apache.http.impl.client.ClientParamsStack; + + /** * 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() { try {