Return-Path: Delivered-To: apmail-hc-commits-archive@www.apache.org Received: (qmail 18961 invoked from network); 21 Dec 2007 12:58:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Dec 2007 12:58:37 -0000 Received: (qmail 9908 invoked by uid 500); 21 Dec 2007 12:58:26 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 9882 invoked by uid 500); 21 Dec 2007 12:58:26 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 9873 invoked by uid 99); 21 Dec 2007 12:58:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Dec 2007 04:58:26 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Dec 2007 12:58:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9FF6C1A983A; Fri, 21 Dec 2007 04:58:11 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r606184 - in /httpcomponents/httpclient/trunk/module-client/src: main/java/org/apache/http/conn/ test/java/org/apache/http/conn/ Date: Fri, 21 Dec 2007 12:58:08 -0000 To: commits@hc.apache.org From: rolandw@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071221125811.9FF6C1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rolandw Date: Fri Dec 21 04:58:07 2007 New Revision: 606184 URL: http://svn.apache.org/viewvc?rev=606184&view=rev Log: HTTPCLIENT-712: removed deprecated proxy chain constructor, added testcase for null enums Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/HttpRoute.java httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/RouteTracker.java httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/HttpRoute.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/HttpRoute.java?rev=606184&r1=606183&r2=606184&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/HttpRoute.java (original) +++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/HttpRoute.java Fri Dec 21 04:58:07 2007 @@ -115,8 +115,10 @@ * null for a direct route * @param secure true if the route is (to be) secure, * false otherwise - * @param tunnelled the tunnel type of this route - * @param layered the layering type of this route + * @param tunnelled the tunnel type of this route, or + * null for PLAIN + * @param layered the layering type of this route, or + * null for PLAIN */ private HttpRoute(InetAddress local, HttpHost target, HttpHost[] proxies, @@ -131,6 +133,12 @@ ("Proxy required if tunnelled."); } + // tunnelled is already checked above, that is in line with the default + if (tunnelled == null) + tunnelled = TunnelType.PLAIN; + if (layered == null) + layered = LayerType.PLAIN; + this.targetHost = target; this.localAddress = local; this.proxyChain = proxies; @@ -156,33 +164,6 @@ public HttpRoute(HttpHost target, InetAddress local, HttpHost[] proxies, boolean secure, TunnelType tunnelled, LayerType layered) { this(local, target, toChain(proxies), secure, tunnelled, layered); - } - - - /** - * Creates a new route with all attributes specified explicitly. - * - * @param target the host to which to route - * @param local the local address to route from, or - * null for the default - * @param proxies the proxy chain to use, or - * null for a direct route - * @param secure true if the route is (to be) secure, - * false otherwise - * @param tunnelled true if the route is (to be) tunnelled - * end-to-end via the proxy chain, - * false otherwise - * @param layered true if the route includes a - * layered protocol, - * false otherwise - * - * @deprecated use enums instead of boolean for 'tunnelled' and 'layered' - */ - public HttpRoute(HttpHost target, InetAddress local, HttpHost[] proxies, - boolean secure, boolean tunnelled, boolean layered) { - this(local, target, toChain(proxies), secure, - tunnelled ? TunnelType.TUNNELLED : TunnelType.PLAIN, - layered ? LayerType.LAYERED : LayerType.PLAIN); } Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/RouteTracker.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/RouteTracker.java?rev=606184&r1=606183&r2=606184&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/RouteTracker.java (original) +++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/RouteTracker.java Fri Dec 21 04:58:07 2007 @@ -35,6 +35,8 @@ import org.apache.http.HttpHost; import org.apache.http.util.CharArrayBuffer; +import org.apache.http.conn.HttpRoute.TunnelType; +import org.apache.http.conn.HttpRoute.LayerType; /** @@ -69,10 +71,10 @@ private HttpHost[] proxyChain; /** Whether the the route is tunnelled end-to-end through proxies. */ - private boolean tunnelled; + private TunnelType tunnelled; /** Whether the route is layered over a tunnel. */ - private boolean layered; + private LayerType layered; /** Whether the route is secure. */ private boolean secure; @@ -90,8 +92,10 @@ if (target == null) { throw new IllegalArgumentException("Target host may not be null."); } - this.targetHost = target; + this.targetHost = target; this.localAddress = local; + this.tunnelled = TunnelType.PLAIN; + this.layered = LayerType.PLAIN; } @@ -155,7 +159,7 @@ if (this.proxyChain == null) { throw new IllegalStateException("No tunnel without proxy."); } - this.tunnelled = true; + this.tunnelled = TunnelType.TUNNELLED; this.secure = secure; } @@ -204,7 +208,7 @@ throw new IllegalStateException ("No layered protocol unless connected."); } - this.layered = true; + this.layered = LayerType.LAYERED; this.secure = secure; } @@ -307,24 +311,51 @@ /** + * Obtains the tunnel type of this route. + * If there is a proxy chain, only end-to-end tunnels are considered. + * + * @return the tunnelling type + */ + public final TunnelType getTunnelType() { + return this.tunnelled; + } + + + /** * Checks whether this route is tunnelled through a proxy. + * If there is a proxy chain, only end-to-end tunnels are considered. * - * @return true if tunnelled, + * @return true if tunnelled end-to-end through at least + * one proxy, * false otherwise */ public final boolean isTunnelled() { - return this.tunnelled; + return (this.tunnelled == TunnelType.TUNNELLED); + } + + + /** + * Obtains the layering type of this route. + * In the presence of proxies, only layering over an end-to-end tunnel + * is considered. + * + * @return the layering type + */ + public final LayerType getLayerType() { + return this.layered; } /** * Checks whether this route includes a layered protocol. + * In the presence of proxies, only layering over an end-to-end tunnel + * is considered. * * @return true if layered, * false otherwise */ public final boolean isLayered() { - return this.layered; + return (this.layered == LayerType.LAYERED); } @@ -421,10 +452,9 @@ hc ^= 0x11111111; if (this.secure) hc ^= 0x22222222; - if (this.tunnelled) - hc ^= 0x44444444; - if (this.layered) - hc ^= 0x88888888; + + hc ^= this.tunnelled.hashCode(); + hc ^= this.layered.hashCode(); return hc; } @@ -446,9 +476,9 @@ cab.append('{'); if (this.connected) cab.append('c'); - if (this.tunnelled) + if (this.tunnelled == TunnelType.TUNNELLED) cab.append('t'); - if (this.layered) + if (this.layered == LayerType.LAYERED) cab.append('l'); if (this.secure) cab.append('s'); Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java?rev=606184&r1=606183&r2=606184&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java (original) +++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestHttpRoute.java Fri Dec 21 04:58:07 2007 @@ -41,6 +41,8 @@ import junit.framework.TestSuite; import org.apache.http.HttpHost; +import org.apache.http.conn.HttpRoute.TunnelType; +import org.apache.http.conn.HttpRoute.LayerType; /** @@ -106,8 +108,8 @@ // create a route with all arguments and check the details HttpHost[] chain3 = { PROXY1, PROXY2, PROXY3 }; - HttpRoute route = new HttpRoute(TARGET1, LOCAL41, chain3, - false, false, false); + HttpRoute route = new HttpRoute(TARGET1, LOCAL41, chain3, false, + TunnelType.PLAIN, LayerType.PLAIN); assertEquals("wrong target", TARGET1, route.getTargetHost()); assertEquals("wrong local address", @@ -149,22 +151,30 @@ HttpHost[] chain3 = { PROXY1, PROXY2, PROXY3 }; - HttpRoute routefff = new HttpRoute(TARGET1, LOCAL41, chain3, - false, false, false); - HttpRoute routefft = new HttpRoute(TARGET1, LOCAL41, chain3, - false, false, true); - HttpRoute routeftf = new HttpRoute(TARGET1, LOCAL41, chain3, - false, true, false); - HttpRoute routeftt = new HttpRoute(TARGET1, LOCAL41, chain3, - false, true, true); - HttpRoute routetff = new HttpRoute(TARGET1, LOCAL41, chain3, - true, false, false); - HttpRoute routetft = new HttpRoute(TARGET1, LOCAL41, chain3, - true, false, true); - HttpRoute routettf = new HttpRoute(TARGET1, LOCAL41, chain3, - true, true, false); - HttpRoute routettt = new HttpRoute(TARGET1, LOCAL41, chain3, - true, true, true); + HttpRoute routefff = new HttpRoute + (TARGET1, LOCAL41, chain3, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute routefft = new HttpRoute + (TARGET1, LOCAL41, chain3, false, + TunnelType.PLAIN, LayerType.LAYERED); + HttpRoute routeftf = new HttpRoute + (TARGET1, LOCAL41, chain3, false, + TunnelType.TUNNELLED, LayerType.PLAIN); + HttpRoute routeftt = new HttpRoute + (TARGET1, LOCAL41, chain3, false, + TunnelType.TUNNELLED, LayerType.LAYERED); + HttpRoute routetff = new HttpRoute + (TARGET1, LOCAL41, chain3, true, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute routetft = new HttpRoute + (TARGET1, LOCAL41, chain3, true, + TunnelType.PLAIN, LayerType.LAYERED); + HttpRoute routettf = new HttpRoute + (TARGET1, LOCAL41, chain3, true, + TunnelType.TUNNELLED, LayerType.PLAIN); + HttpRoute routettt = new HttpRoute + (TARGET1, LOCAL41, chain3, true, + TunnelType.TUNNELLED, LayerType.LAYERED); assertFalse("routefff.secure", routefff.isSecure()); assertFalse("routefff.tunnel", routefff.isTunnelled()); @@ -244,21 +254,21 @@ HttpHost[] chain4 = { PROXY1, PROXY2, null, PROXY3 }; // for reference: this one should succeed - HttpRoute route = new HttpRoute(TARGET1, null, chain1, - false, true, false); + HttpRoute route = new HttpRoute(TARGET1, null, chain1, false, + TunnelType.TUNNELLED, LayerType.PLAIN); assertNotNull(route); try { - route = new HttpRoute(null, null, chain1, - false, true, false); + route = new HttpRoute(null, null, chain1, false, + TunnelType.TUNNELLED, LayerType.PLAIN); fail("missing target not detected"); } catch (IllegalArgumentException iax) { // expected } try { - route = new HttpRoute(TARGET1, null, (HttpHost[]) null, - false, true, false); + route = new HttpRoute(TARGET1, null, (HttpHost[]) null, false, + TunnelType.TUNNELLED, LayerType.PLAIN); fail("missing proxy for tunnel not detected"); } catch (IllegalArgumentException iax) { // expected @@ -266,16 +276,16 @@ // for the next two, we don't indicate a tunnel anymore try { - route = new HttpRoute(TARGET1, null, chain0, - false, false, false); + route = new HttpRoute(TARGET1, null, chain0, false, + TunnelType.PLAIN, LayerType.PLAIN); fail("invalid proxy chain (0) not detected"); } catch (IllegalArgumentException iax) { // expected } try { - route = new HttpRoute(TARGET1, null, chain4, - false, false, false); + route = new HttpRoute(TARGET1, null, chain4, false, + TunnelType.PLAIN, LayerType.PLAIN); fail("invalid proxy chain (4) not detected"); } catch (IllegalArgumentException iax) { // expected @@ -283,6 +293,22 @@ } + public void testNullEnums() { + + // tests the default values for the enum parameters + // also covers the accessors for the enum attributes + + HttpRoute route = new HttpRoute(TARGET1, null, PROXY1, false, + null, null); // here are defaults + + assertFalse("default tunnelling", route.isTunnelled()); + assertEquals("untunnelled", TunnelType.PLAIN, route.getTunnelType()); + + assertFalse("default layering", route.isLayered()); + assertEquals("unlayered", LayerType.PLAIN, route.getLayerType()); + } + + public void testEqualsHashcodeClone() throws CloneNotSupportedException { HttpHost[] chain0 = { }; HttpHost[] chain1 = { PROXY1 }; @@ -290,10 +316,10 @@ HttpHost[] chain4 = { PROXY1, PROXY3, PROXY2 }; // create some identical routes - HttpRoute route1a = new HttpRoute(TARGET1, LOCAL41, chain3, - false, false, false); - HttpRoute route1b = new HttpRoute(TARGET1, LOCAL41, chain3, - false, false, false); + HttpRoute route1a = new HttpRoute(TARGET1, LOCAL41, chain3, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route1b = new HttpRoute(TARGET1, LOCAL41, chain3, false, + TunnelType.PLAIN, LayerType.PLAIN); HttpRoute route1c = (HttpRoute) route1a.clone(); assertEquals("1a 1a", route1a, route1a); @@ -309,28 +335,29 @@ assertEquals("toString 1c", route1a.toString(), route1c.toString()); // now create some differing routes - HttpRoute route2a = new HttpRoute(TARGET2, LOCAL41, chain3, - false, false, false); - HttpRoute route2b = new HttpRoute(TARGET1, LOCAL42, chain3, - false, false, false); - HttpRoute route2c = new HttpRoute(TARGET1, LOCAL61, chain3, - false, false, false); - HttpRoute route2d = new HttpRoute(TARGET1, null, chain3, - false, false, false); + HttpRoute route2a = new HttpRoute(TARGET2, LOCAL41, chain3, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route2b = new HttpRoute(TARGET1, LOCAL42, chain3, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route2c = new HttpRoute(TARGET1, LOCAL61, chain3, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route2d = new HttpRoute(TARGET1, null, chain3, false, + TunnelType.PLAIN, LayerType.PLAIN); HttpRoute route2e = new HttpRoute(TARGET1, LOCAL41, (HttpHost[]) null, - false, false, false); - HttpRoute route2f = new HttpRoute(TARGET1, LOCAL41, chain0, - false, false, false); - HttpRoute route2g = new HttpRoute(TARGET1, LOCAL41, chain1, - false, false, false); - HttpRoute route2h = new HttpRoute(TARGET1, LOCAL41, chain4, - false, false, false); - HttpRoute route2i = new HttpRoute(TARGET1, LOCAL41, chain3, - true, false, false); - HttpRoute route2j = new HttpRoute(TARGET1, LOCAL41, chain3, - false, true, false); - HttpRoute route2k = new HttpRoute(TARGET1, LOCAL41, chain3, - false, false, true); + false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route2f = new HttpRoute(TARGET1, LOCAL41, chain0, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route2g = new HttpRoute(TARGET1, LOCAL41, chain1, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route2h = new HttpRoute(TARGET1, LOCAL41, chain4, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route2i = new HttpRoute(TARGET1, LOCAL41, chain3, true, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route2j = new HttpRoute(TARGET1, LOCAL41, chain3, false, + TunnelType.TUNNELLED, LayerType.PLAIN); + HttpRoute route2k = new HttpRoute(TARGET1, LOCAL41, chain3, false, + TunnelType.PLAIN, LayerType.LAYERED); // check a special case first: 2f should be the same as 2e assertEquals("2e 2f", route2e, route2f); @@ -441,8 +468,8 @@ public void testHopping() { // test getHopCount() and getHopTarget() with different proxy chains HttpHost[] proxies = null; - HttpRoute route = new HttpRoute(TARGET1, null, proxies, - true, false, false); + HttpRoute route = new HttpRoute(TARGET1, null, proxies, true, + TunnelType.PLAIN, LayerType.PLAIN); assertEquals("A: hop count", 1, route.getHopCount()); assertEquals("A: hop 0", TARGET1, route.getHopTarget(0)); try { @@ -460,8 +487,8 @@ proxies = new HttpHost[]{ PROXY3 }; - route = new HttpRoute(TARGET1, LOCAL62, proxies, - false, true, false); + route = new HttpRoute(TARGET1, LOCAL62, proxies, false, + TunnelType.TUNNELLED, LayerType.PLAIN); assertEquals("B: hop count", 2, route.getHopCount()); assertEquals("B: hop 0", PROXY3, route.getHopTarget(0)); assertEquals("B: hop 1", TARGET1, route.getHopTarget(1)); @@ -480,8 +507,8 @@ proxies = new HttpHost[]{ PROXY3, PROXY1, PROXY2 }; - route = new HttpRoute(TARGET1, LOCAL42, proxies, - false, false, true); + route = new HttpRoute(TARGET1, LOCAL42, proxies, false, + TunnelType.PLAIN, LayerType.LAYERED); assertEquals("C: hop count", 4, route.getHopCount()); assertEquals("C: hop 0", PROXY3 , route.getHopTarget(0)); assertEquals("C: hop 1", PROXY1 , route.getHopTarget(1)); @@ -504,8 +531,9 @@ public void testCstr1() { HttpRoute route = new HttpRoute(TARGET2); - HttpRoute should = new HttpRoute(TARGET2, null, (HttpHost[]) null, - false, false, false); + HttpRoute should = new HttpRoute + (TARGET2, null, (HttpHost[]) null, false, + TunnelType.PLAIN, LayerType.PLAIN); assertEquals("bad convenience route", route, should); } @@ -513,13 +541,14 @@ public void testCstr3() { // test convenience constructor with 3 arguments HttpRoute route = new HttpRoute(TARGET2, LOCAL61, false); - HttpRoute should = new HttpRoute(TARGET2, LOCAL61, (HttpHost[]) null, - false, false, false); + HttpRoute should = new HttpRoute + (TARGET2, LOCAL61, (HttpHost[]) null, false, + TunnelType.PLAIN, LayerType.PLAIN); assertEquals("bad convenience route 3/insecure", route, should); route = new HttpRoute(TARGET2, null, true); - should = new HttpRoute(TARGET2, null, (HttpHost[]) null, - true, false, false); + should = new HttpRoute(TARGET2, null, (HttpHost[]) null, true, + TunnelType.PLAIN, LayerType.PLAIN); assertEquals("bad convenience route 3/secure", route, should); } @@ -528,12 +557,14 @@ // test convenience constructor with 4 arguments HttpRoute route = new HttpRoute(TARGET2, null, PROXY2, false); HttpRoute should = new HttpRoute - (TARGET2, null, new HttpHost[]{ PROXY2 }, false, false, false); + (TARGET2, null, new HttpHost[]{ PROXY2 }, false, + TunnelType.PLAIN, LayerType.PLAIN); assertEquals("bad convenience route 4/insecure", route, should); route = new HttpRoute(TARGET2, LOCAL42, PROXY1, true); should = new HttpRoute - (TARGET2, LOCAL42, new HttpHost[]{ PROXY1 }, true, true, true); + (TARGET2, LOCAL42, new HttpHost[]{ PROXY1 }, true, + TunnelType.TUNNELLED, LayerType.LAYERED); assertEquals("bad convenience route 4/secure", route, should); // this constructor REQUIRES a proxy to be specified @@ -549,15 +580,19 @@ public void testCstr6() { // test convenience constructor with 6 arguments HttpRoute route = new HttpRoute - (TARGET2, null, PROXY2, true, true, false); + (TARGET2, null, PROXY2, true, + TunnelType.TUNNELLED, LayerType.PLAIN); HttpRoute should = new HttpRoute - (TARGET2, null, new HttpHost[]{ PROXY2 }, true, true, false); + (TARGET2, null, new HttpHost[]{ PROXY2 }, true, + TunnelType.TUNNELLED, LayerType.PLAIN); assertEquals("bad convenience route 6/proxied", route, should); route = new HttpRoute - (TARGET2, null, (HttpHost) null, true, false, true); + (TARGET2, null, (HttpHost) null, true, + TunnelType.PLAIN, LayerType.LAYERED); should = new HttpRoute - (TARGET2, null, (HttpHost[]) null, true, false, true); + (TARGET2, null, (HttpHost[]) null, true, + TunnelType.PLAIN, LayerType.LAYERED); assertEquals("bad convenience route 6/direct", route, should); // handling of null vs. empty chain is checked in the equals tests @@ -567,12 +602,12 @@ public void testImmutable() throws CloneNotSupportedException { HttpHost[] proxies = new HttpHost[]{ PROXY1, PROXY2, PROXY3 }; - HttpRoute route1 = new HttpRoute(TARGET1, null, proxies, - false, false, false); + HttpRoute route1 = new HttpRoute(TARGET1, null, proxies, false, + TunnelType.PLAIN, LayerType.PLAIN); HttpRoute route2 = (HttpRoute) route1.clone(); HttpRoute route3 = new HttpRoute(TARGET1, null, - (HttpHost[]) proxies.clone(), - false, false, false); + (HttpHost[]) proxies.clone(), false, + TunnelType.PLAIN, LayerType.PLAIN); // modify the array that was passed to the constructor of route1 proxies[1] = PROXY3; Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java?rev=606184&r1=606183&r2=606184&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java (original) +++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteDirector.java Fri Dec 21 04:58:07 2007 @@ -38,6 +38,8 @@ import junit.framework.TestSuite; import org.apache.http.HttpHost; +import org.apache.http.conn.HttpRoute.TunnelType; +import org.apache.http.conn.HttpRoute.LayerType; /** @@ -199,14 +201,14 @@ HttpHost[] chainC = { PROXY2, PROXY1 }; HttpRouteDirector rowdy = new BasicRouteDirector(); - HttpRoute route1cA = new HttpRoute(TARGET1, null, chainA, - false, false, false); - HttpRoute route1cB = new HttpRoute(TARGET1, null, chainB, - false, false, false); - HttpRoute route1cC = new HttpRoute(TARGET1, null, chainC, - false, false, false); - HttpRoute route1cD = new HttpRoute(TARGET1, null, chainC, - false, false, false); + HttpRoute route1cA = new HttpRoute(TARGET1, null, chainA, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route1cB = new HttpRoute(TARGET1, null, chainB, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route1cC = new HttpRoute(TARGET1, null, chainC, false, + TunnelType.PLAIN, LayerType.PLAIN); + HttpRoute route1cD = new HttpRoute(TARGET1, null, chainC, false, + TunnelType.PLAIN, LayerType.PLAIN); int step = rowdy.nextStep(route1cA, null); assertEquals("wrong step to route1cA", Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java?rev=606184&r1=606183&r2=606184&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java (original) +++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestRouteTracker.java Fri Dec 21 04:58:07 2007 @@ -40,6 +40,8 @@ import junit.framework.TestSuite; import org.apache.http.HttpHost; +import org.apache.http.conn.HttpRoute.TunnelType; +import org.apache.http.conn.HttpRoute.LayerType; /** @@ -330,13 +332,15 @@ assertTrue("incomplete route 1", complete); // tunnelled, but neither secure nor layered - r = new HttpRoute(TARGET1, LOCAL61, PROXY3, false, true, false); + r = new HttpRoute(TARGET1, LOCAL61, PROXY3, false, + TunnelType.TUNNELLED, LayerType.PLAIN); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 3); assertTrue("incomplete route 2", complete); // tunnelled, layered, but not secure - r = new HttpRoute(TARGET1, LOCAL61, PROXY3, false, true, true); + r = new HttpRoute(TARGET1, LOCAL61, PROXY3, false, + TunnelType.TUNNELLED, LayerType.LAYERED); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 4); assertTrue("incomplete route 3", complete); @@ -353,29 +357,32 @@ final HttpRouteDirector rd = new BasicRouteDirector(); HttpHost[] proxies = { PROXY1, PROXY2 }; - HttpRoute r = new HttpRoute(TARGET2, LOCAL42, proxies, - false, false, false); + HttpRoute r = new HttpRoute(TARGET2, LOCAL42, proxies, false, + TunnelType.PLAIN, LayerType.PLAIN); RouteTracker rt = new RouteTracker(r); boolean complete = checkVia(rt, r, rd, 3); assertTrue("incomplete route 1", complete); // tunnelled, but neither secure nor layered proxies = new HttpHost[]{ PROXY3, PROXY2 }; - r = new HttpRoute(TARGET1, null, proxies, false, true, false); + r = new HttpRoute(TARGET1, null, proxies, false, + TunnelType.TUNNELLED, LayerType.PLAIN); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 4); assertTrue("incomplete route 2", complete); // tunnelled, layered, but not secure proxies = new HttpHost[]{ PROXY3, PROXY2, PROXY1 }; - r = new HttpRoute(TARGET2, LOCAL61, proxies, false, true, true); + r = new HttpRoute(TARGET2, LOCAL61, proxies, false, + TunnelType.TUNNELLED, LayerType.LAYERED); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 6); assertTrue("incomplete route 3", complete); // tunnelled, layered, secure proxies = new HttpHost[]{ PROXY1, PROXY3 }; - r = new HttpRoute(TARGET1, LOCAL61, proxies, true, true, true); + r = new HttpRoute(TARGET1, LOCAL61, proxies, true, + TunnelType.TUNNELLED, LayerType.LAYERED); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 5); assertTrue("incomplete route 4", complete);