split RouteDirector into interface and basic implementation

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@558315 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Roland Weber 2007-07-21 11:39:57 +00:00
parent c4a9583527
commit aee7161317
5 changed files with 192 additions and 126 deletions

View File

@ -34,9 +34,8 @@ package org.apache.http.conn;
/**
* Provides directions on establishing a route.
* Instances of this class compare a planned route with a tracked route
* and indicate the next step required.
* Basic implementation of an {@link HttpRouteDirector HttpRouteDirector}.
* This implementation is stateless and therefore thread-safe.
*
* @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
*
@ -46,29 +45,7 @@ package org.apache.http.conn;
*
* @since 4.0
*/
public class RouteDirector {
/** Indicates that the route can not be established at all. */
public final static int UNREACHABLE = -1;
/** Indicates that the route is complete. */
public final static int COMPLETE = 0;
/** Step: open connection to target. */
public final static int CONNECT_TARGET = 1;
/** Step: open connection to proxy. */
public final static int CONNECT_PROXY = 2;
/** Step: tunnel through proxy to target. */
public final static int TUNNEL_TARGET = 3;
/** Step: tunnel through proxy to other proxy. */
public final static int TUNNEL_PROXY = 4;
/** Step: layer protocol (over tunnel). */
public final static int LAYER_PROTOCOL = 5;
public class BasicRouteDirector implements HttpRouteDirector {
// public default constructor
@ -201,4 +178,4 @@ public class RouteDirector {
}
} // class RouteDirector
} // class BasicRouteDirector

View File

@ -0,0 +1,88 @@
/*
* $HeadURL$
* $Revision$
* $Date$
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.conn;
/**
* Provides directions on establishing a route.
* Implementations of this interface compare a planned route with
* a tracked route and indicate the next step required.
*
* @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$
*
* @since 4.0
*/
public interface HttpRouteDirector {
/** Indicates that the route can not be established at all. */
public final static int UNREACHABLE = -1;
/** Indicates that the route is complete. */
public final static int COMPLETE = 0;
/** Step: open connection to target. */
public final static int CONNECT_TARGET = 1;
/** Step: open connection to proxy. */
public final static int CONNECT_PROXY = 2;
/** Step: tunnel through proxy to target. */
public final static int TUNNEL_TARGET = 3;
/** Step: tunnel through proxy to other proxy. */
public final static int TUNNEL_PROXY = 4;
/** Step: layer protocol (over tunnel). */
public final static int LAYER_PROTOCOL = 5;
/**
* Provides the next step.
*
* @param plan the planned route
* @param fact the currently established route, or
* <code>null</code> if nothing is established
*
* @return one of the constants defined in this interface, indicating
* either the next step to perform, or success, or failure.
* 0 is for success, a negative value for failure.
*/
public int nextStep(HttpRoute plan, HttpRoute fact)
;
} // interface HttpRouteDirector

View File

@ -73,7 +73,8 @@ import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.HttpRoute;
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.conn.RouteDirector;
import org.apache.http.conn.HttpRouteDirector;
import org.apache.http.conn.BasicRouteDirector;
import org.apache.http.conn.Scheme;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.message.BasicHttpRequest;
@ -467,7 +468,7 @@ public class DefaultClientRequestDirector
//@@@ probably not, because the parent is replaced
//@@@ just make sure we don't link parameters to themselves
RouteDirector rowdy = new RouteDirector();
HttpRouteDirector rowdy = new BasicRouteDirector();
int step;
do {
HttpRoute fact = managedConn.getRoute();
@ -475,32 +476,32 @@ public class DefaultClientRequestDirector
switch (step) {
case RouteDirector.CONNECT_TARGET:
case RouteDirector.CONNECT_PROXY:
case HttpRouteDirector.CONNECT_TARGET:
case HttpRouteDirector.CONNECT_PROXY:
managedConn.open(route, context, this.params);
break;
case RouteDirector.TUNNEL_TARGET:
case HttpRouteDirector.TUNNEL_TARGET:
boolean secure = createTunnel(route, context);
LOG.debug("Tunnel created");
managedConn.tunnelCreated(secure, this.params);
break;
case RouteDirector.TUNNEL_PROXY:
case HttpRouteDirector.TUNNEL_PROXY:
throw new UnsupportedOperationException
("Proxy chains are not supported.");
case RouteDirector.LAYER_PROTOCOL:
case HttpRouteDirector.LAYER_PROTOCOL:
managedConn.layerProtocol(context, this.params);
break;
case RouteDirector.UNREACHABLE:
case HttpRouteDirector.UNREACHABLE:
throw new IllegalStateException
("Unable to establish route." +
"\nplanned = " + route +
"\ncurrent = " + fact);
case RouteDirector.COMPLETE:
case HttpRouteDirector.COMPLETE:
// do nothing
break;
@ -509,7 +510,7 @@ public class DefaultClientRequestDirector
("Unknown step indicator "+step+" from RouteDirector.");
} // switch
} while (step > RouteDirector.COMPLETE);
} while (step > HttpRouteDirector.COMPLETE);
} // establishConnection

View File

@ -41,7 +41,7 @@ import org.apache.http.HttpHost;
/**
* Tests for <code>RouteDirector</code>.
* Tests for <code>BasicRouteDirector</code>.
*/
public class TestRouteDirector extends TestCase {
@ -101,7 +101,7 @@ public class TestRouteDirector extends TestCase {
public void testIllegal() {
RouteDirector rowdy = new RouteDirector();
HttpRouteDirector rowdy = new BasicRouteDirector();
HttpRoute route = new HttpRoute(TARGET1);
try {
@ -115,40 +115,40 @@ public class TestRouteDirector extends TestCase {
public void testDirect() {
RouteDirector rowdy = new RouteDirector();
HttpRouteDirector rowdy = new BasicRouteDirector();
HttpRoute route1 = new HttpRoute(TARGET1);
HttpRoute route2 = new HttpRoute(TARGET2);
HttpRoute route1p1 = new HttpRoute(TARGET1, null, PROXY1, false);
int step = rowdy.nextStep(route1, null);
assertEquals("wrong step to route1",
RouteDirector.CONNECT_TARGET, step);
HttpRouteDirector.CONNECT_TARGET, step);
step = rowdy.nextStep(route2, null);
assertEquals("wrong step to route2",
RouteDirector.CONNECT_TARGET, step);
HttpRouteDirector.CONNECT_TARGET, step);
step = rowdy.nextStep(route1, route1);
assertEquals("complete route1 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route2, route2);
assertEquals("complete route2 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1, route2);
assertEquals("unreachable target not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1, route1p1);
assertEquals("invalid proxy not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
}
public void testProxy() {
RouteDirector rowdy = new RouteDirector();
HttpRouteDirector rowdy = new BasicRouteDirector();
HttpRoute route1p1 = new HttpRoute(TARGET1, null, PROXY1, false);
HttpRoute route1p2 = new HttpRoute(TARGET1, null, PROXY2, false);
HttpRoute route2p1 = new HttpRoute(TARGET2, null, PROXY1, false);
@ -157,39 +157,39 @@ public class TestRouteDirector extends TestCase {
int step = rowdy.nextStep(route1p1, null);
assertEquals("wrong step to route1p1",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1p2, null);
assertEquals("wrong step to route1p2",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1p1, route1p1);
assertEquals("complete route1p1 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1p2, route1p2);
assertEquals("complete route1p2 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route2p1, route2p1);
assertEquals("complete route2p1 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1p1, route1p2);
assertEquals("unreachable route1p1 via route1p2 not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1p1, route2p1);
assertEquals("unreachable route1p1 via route2p1 not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1p1, route0);
assertEquals("unreachable route1p1 via route0 not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1p1, route1);
assertEquals("unreachable route1p1 via route1 not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
}
@ -198,7 +198,7 @@ public class TestRouteDirector extends TestCase {
HttpHost[] chainB = { PROXY1, PROXY2 };
HttpHost[] chainC = { PROXY2, PROXY1 };
RouteDirector rowdy = new RouteDirector();
HttpRouteDirector rowdy = new BasicRouteDirector();
HttpRoute route1cA = new HttpRoute(TARGET1, null, chainA,
false, false, false);
HttpRoute route1cB = new HttpRoute(TARGET1, null, chainB,
@ -210,47 +210,47 @@ public class TestRouteDirector extends TestCase {
int step = rowdy.nextStep(route1cA, null);
assertEquals("wrong step to route1cA",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1cB, null);
assertEquals("wrong step to route1cB",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1cC, null);
assertEquals("wrong step to route1cC",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1cD, null);
assertEquals("wrong step to route1cD",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1cB, route1cA);
assertEquals("wrong step to route 1cB from 1cA",
RouteDirector.TUNNEL_PROXY, step);
HttpRouteDirector.TUNNEL_PROXY, step);
step = rowdy.nextStep(route1cB, route1cB);
assertEquals("complete route 1cB not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1cB, route1cC);
assertEquals("unreachable route 1cB from 1cC not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1cB, route1cD);
assertEquals("unreachable route 1cB from 1cD not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1cA, route1cB);
assertEquals("unreachable route 1cA from 1cB not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
}
public void testLocalDirect() {
RouteDirector rowdy = new RouteDirector();
HttpRouteDirector rowdy = new BasicRouteDirector();
HttpRoute route1l41 = new HttpRoute(TARGET1, LOCAL41, false);
HttpRoute route1l42 = new HttpRoute(TARGET1, LOCAL42, false);
HttpRoute route1l61 = new HttpRoute(TARGET1, LOCAL61, false);
@ -258,67 +258,67 @@ public class TestRouteDirector extends TestCase {
int step = rowdy.nextStep(route1l41, null);
assertEquals("wrong step to route1l41",
RouteDirector.CONNECT_TARGET, step);
HttpRouteDirector.CONNECT_TARGET, step);
step = rowdy.nextStep(route1l42, null);
assertEquals("wrong step to route1l42",
RouteDirector.CONNECT_TARGET, step);
HttpRouteDirector.CONNECT_TARGET, step);
step = rowdy.nextStep(route1l61, null);
assertEquals("wrong step to route1l61",
RouteDirector.CONNECT_TARGET, step);
HttpRouteDirector.CONNECT_TARGET, step);
step = rowdy.nextStep(route1l00, null);
assertEquals("wrong step to route1l00",
RouteDirector.CONNECT_TARGET, step);
HttpRouteDirector.CONNECT_TARGET, step);
step = rowdy.nextStep(route1l41, route1l41);
assertEquals("complete route1l41 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1l42, route1l42);
assertEquals("complete route1l42 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1l61, route1l61);
assertEquals("complete route1l61 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1l00, route1l00);
assertEquals("complete route1l00 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1l41, route1l42);
assertEquals("unreachable route1l41 via route1l42 not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1l41, route1l61);
assertEquals("unreachable route1l41 via route1l61 not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1l41, route1l00);
assertEquals("unreachable route1l41 via route1l00 not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1l00, route1l41);
assertEquals("complete route1l00 as route1l41 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1l00, route1l42);
assertEquals("complete route1l00 as route1l42 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1l00, route1l61);
assertEquals("complete route1l00 as route1l61 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
}
public void testDirectSecure() {
RouteDirector rowdy = new RouteDirector();
HttpRouteDirector rowdy = new BasicRouteDirector();
HttpRoute route1u = new HttpRoute(TARGET1, null, false);
HttpRoute route1s = new HttpRoute(TARGET1, null, true);
HttpRoute route1p1u = new HttpRoute(TARGET1, null, PROXY1, false);
@ -326,37 +326,37 @@ public class TestRouteDirector extends TestCase {
int step = rowdy.nextStep(route1u, null);
assertEquals("wrong step to route1u",
RouteDirector.CONNECT_TARGET, step);
HttpRouteDirector.CONNECT_TARGET, step);
step = rowdy.nextStep(route1s, null);
assertEquals("wrong step to route1s",
RouteDirector.CONNECT_TARGET, step);
HttpRouteDirector.CONNECT_TARGET, step);
// unrequested security is currently not tolerated
step = rowdy.nextStep(route1u, route1s);
assertEquals("unreachable route 1u from 1s not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
// secure layering of direct connections is currently not supported
step = rowdy.nextStep(route1s, route1u);
assertEquals("unreachable route 1s from 1u not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1s, route1p1u);
assertEquals("unreachable route 1s from 1p1u not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1s, route1p1s);
assertEquals("unreachable route 1s from 1p1s not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
}
public void testProxyTLS() {
RouteDirector rowdy = new RouteDirector();
HttpRouteDirector rowdy = new BasicRouteDirector();
HttpRoute route1 = new HttpRoute(TARGET1, null, PROXY1,
false, false, false);
HttpRoute route1t = new HttpRoute(TARGET1, null, PROXY1,
@ -374,118 +374,118 @@ public class TestRouteDirector extends TestCase {
int step = rowdy.nextStep(route1, null);
assertEquals("wrong step to route1",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1t, null);
assertEquals("wrong step to route1t",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1tl, null);
assertEquals("wrong step to route1tl",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1s, null);
assertEquals("wrong step to route1s",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1ts, null);
assertEquals("wrong step to route1ts",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1tls, null);
assertEquals("wrong step to route1tls",
RouteDirector.CONNECT_PROXY, step);
HttpRouteDirector.CONNECT_PROXY, step);
step = rowdy.nextStep(route1, route1);
assertEquals("complete route1 not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1t, route1t);
assertEquals("complete route1t not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1tl, route1tl);
assertEquals("complete route1tl not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1s, route1s);
assertEquals("complete route1s not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1ts, route1ts);
assertEquals("complete route1ts not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1tls, route1tls);
assertEquals("complete route1tls not detected",
RouteDirector.COMPLETE, step);
HttpRouteDirector.COMPLETE, step);
step = rowdy.nextStep(route1, route1t);
assertEquals("unreachable route1 from 1t not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1, route1tl);
assertEquals("unreachable route1 from 1tl not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
// unrequested security is currently not tolerated
step = rowdy.nextStep(route1, route1s);
assertEquals("unreachable route1 from 1s not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1, route1ts);
assertEquals("unreachable route1 from 1ts not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
step = rowdy.nextStep(route1, route1tls);
assertEquals("unreachable route1 from 1tls not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
// securing requires layering
step = rowdy.nextStep(route1s, route1);
assertEquals("unreachable route1s from 1 not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
// securing requires layering, and multiple layers are not supported
step = rowdy.nextStep(route1tls, route1tl);
assertEquals("unreachable route1tls from 1tl not detected",
RouteDirector.UNREACHABLE, step);
HttpRouteDirector.UNREACHABLE, step);
// cases where tunnelling to the target is required
step = rowdy.nextStep(route1t, route1);
assertEquals("wrong step to route1t from 1",
RouteDirector.TUNNEL_TARGET, step);
HttpRouteDirector.TUNNEL_TARGET, step);
step = rowdy.nextStep(route1tl, route1);
assertEquals("wrong step to route1tl from 1",
RouteDirector.TUNNEL_TARGET, step);
HttpRouteDirector.TUNNEL_TARGET, step);
step = rowdy.nextStep(route1tls, route1);
assertEquals("wrong step to route1tls from 1",
RouteDirector.TUNNEL_TARGET, step);
HttpRouteDirector.TUNNEL_TARGET, step);
// cases where layering on the tunnel is required
step = rowdy.nextStep(route1tl, route1t);
assertEquals("wrong step to route1tl from 1t",
RouteDirector.LAYER_PROTOCOL, step);
HttpRouteDirector.LAYER_PROTOCOL, step);
step = rowdy.nextStep(route1tl, route1ts);
assertEquals("wrong step to route1tl from 1ts",
RouteDirector.LAYER_PROTOCOL, step);
HttpRouteDirector.LAYER_PROTOCOL, step);
step = rowdy.nextStep(route1tls, route1t);
assertEquals("wrong step to route1tls from 1t",
RouteDirector.LAYER_PROTOCOL, step);
HttpRouteDirector.LAYER_PROTOCOL, step);
step = rowdy.nextStep(route1tls, route1ts);
assertEquals("wrong step to route1tls from 1ts",
RouteDirector.LAYER_PROTOCOL, step);
HttpRouteDirector.LAYER_PROTOCOL, step);
// There are some odd cases left over, like having a secure tunnel
// that becomes unsecure by layering, or a secure connection to a

View File

@ -308,7 +308,7 @@ public class TestRouteTracker extends TestCase {
public void testDirectRoutes() {
final RouteDirector rd = new RouteDirector();
final HttpRouteDirector rd = new BasicRouteDirector();
HttpRoute r = new HttpRoute(TARGET1, LOCAL41, false);
RouteTracker rt = new RouteTracker(r);
boolean complete = checkVia(rt, r, rd, 2);
@ -323,7 +323,7 @@ public class TestRouteTracker extends TestCase {
public void testProxyRoutes() {
final RouteDirector rd = new RouteDirector();
final HttpRouteDirector rd = new BasicRouteDirector();
HttpRoute r = new HttpRoute(TARGET2, null, PROXY1, false);
RouteTracker rt = new RouteTracker(r);
boolean complete = checkVia(rt, r, rd, 2);
@ -351,7 +351,7 @@ public class TestRouteTracker extends TestCase {
public void testProxyChainRoutes() {
final RouteDirector rd = new RouteDirector();
final HttpRouteDirector rd = new BasicRouteDirector();
HttpHost[] proxies = { PROXY1, PROXY2 };
HttpRoute r = new HttpRoute(TARGET2, LOCAL42, proxies,
false, false, false);
@ -566,7 +566,7 @@ public class TestRouteTracker extends TestCase {
/**
* Helper to check tracking of a route.
* This uses a {@link RouteDirector} to fake establishing the route,
* This uses a {@link HttpRouteDirector} to fake establishing the route,
* checking the intermediate steps.
*
* @param rt the tracker to check with
@ -577,7 +577,7 @@ public class TestRouteTracker extends TestCase {
* @return <code>true</code> iff the route is complete
*/
public final static boolean checkVia(RouteTracker rt, HttpRoute r,
RouteDirector rd, int steps) {
HttpRouteDirector rd, int steps) {
final String msg = r.toString() + " @ " + rt.toString();
@ -587,12 +587,12 @@ public class TestRouteTracker extends TestCase {
int action = rd.nextStep(r, rt.toRoute());
switch (action) {
case RouteDirector.COMPLETE:
case HttpRouteDirector.COMPLETE:
complete = true;
assertEquals(r, rt.toRoute());
break;
case RouteDirector.CONNECT_TARGET: {
case HttpRouteDirector.CONNECT_TARGET: {
final boolean sec = r.isSecure();
rt.connectTarget(sec);
checkCTLS(rt, true, false, false, sec);
@ -602,7 +602,7 @@ public class TestRouteTracker extends TestCase {
r.getTargetHost(), rt.getHopTarget(0));
} break;
case RouteDirector.CONNECT_PROXY: {
case HttpRouteDirector.CONNECT_PROXY: {
// we assume an insecure proxy connection
final boolean sec = false;
rt.connectProxy(r.getProxyHost(), sec);
@ -615,7 +615,7 @@ public class TestRouteTracker extends TestCase {
r.getTargetHost(), rt.getHopTarget(1));
} break;
case RouteDirector.TUNNEL_TARGET: {
case HttpRouteDirector.TUNNEL_TARGET: {
final int hops = rt.getHopCount();
// we assume an insecure tunnel
final boolean sec = false;
@ -629,7 +629,7 @@ public class TestRouteTracker extends TestCase {
r.getTargetHost(), rt.getHopTarget(hops-1));
} break;
case RouteDirector.TUNNEL_PROXY: {
case HttpRouteDirector.TUNNEL_PROXY: {
final int hops = rt.getHopCount(); // before tunnelling
// we assume an insecure tunnel
final boolean sec = false;
@ -648,7 +648,7 @@ public class TestRouteTracker extends TestCase {
r.getTargetHost(), rt.getHopTarget(hops));
} break;
case RouteDirector.LAYER_PROTOCOL: {
case HttpRouteDirector.LAYER_PROTOCOL: {
final int hops = rt.getHopCount();
final boolean tun = rt.isTunnelled();
final boolean sec = r.isSecure();