HTTPCLIENT-712: removed deprecated proxy chain constructor, added testcase for null enums

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@606184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Roland Weber 2007-12-21 12:58:07 +00:00
parent 52cb8d3def
commit 789bc843c0
5 changed files with 190 additions and 135 deletions

View File

@ -115,8 +115,10 @@ public final class HttpRoute implements Cloneable {
* <code>null</code> for a direct route
* @param secure <code>true</code> if the route is (to be) secure,
* <code>false</code> 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
* <code>null</code> for PLAIN
* @param layered the layering type of this route, or
* <code>null</code> for PLAIN
*/
private HttpRoute(InetAddress local,
HttpHost target, HttpHost[] proxies,
@ -131,6 +133,12 @@ public final class HttpRoute implements Cloneable {
("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;
@ -159,33 +167,6 @@ public final class HttpRoute implements Cloneable {
}
/**
* 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
* <code>null</code> for the default
* @param proxies the proxy chain to use, or
* <code>null</code> for a direct route
* @param secure <code>true</code> if the route is (to be) secure,
* <code>false</code> otherwise
* @param tunnelled <code>true</code> if the route is (to be) tunnelled
* end-to-end via the proxy chain,
* <code>false</code> otherwise
* @param layered <code>true</code> if the route includes a
* layered protocol,
* <code>false</code> 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);
}
/**
* Creates a new route with at most one proxy.
*

View File

@ -35,6 +35,8 @@ import java.net.InetAddress;
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 @@ public final class RouteTracker implements Cloneable {
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 @@ public final class RouteTracker implements Cloneable {
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 @@ public final class RouteTracker implements Cloneable {
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 @@ public final class RouteTracker implements Cloneable {
throw new IllegalStateException
("No layered protocol unless connected.");
}
this.layered = true;
this.layered = LayerType.LAYERED;
this.secure = secure;
}
@ -307,24 +311,51 @@ public final class RouteTracker implements Cloneable {
/**
* Checks whether this route is tunnelled through a proxy.
* Obtains the tunnel type of this route.
* If there is a proxy chain, only end-to-end tunnels are considered.
*
* @return <code>true</code> if tunnelled,
* <code>false</code> otherwise
* @return the tunnelling type
*/
public final boolean isTunnelled() {
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 <code>true</code> if tunnelled end-to-end through at least
* one proxy,
* <code>false</code> otherwise
*/
public final boolean isTunnelled() {
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 <code>true</code> if layered,
* <code>false</code> otherwise
*/
public final boolean isLayered() {
return this.layered;
return (this.layered == LayerType.LAYERED);
}
@ -421,10 +452,9 @@ public final class RouteTracker implements Cloneable {
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 @@ public final class RouteTracker implements Cloneable {
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');

View File

@ -41,6 +41,8 @@ import junit.framework.TestCase;
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 @@ public class TestHttpRoute extends TestCase {
// 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 @@ public class TestHttpRoute extends TestCase {
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 @@ public class TestHttpRoute extends TestCase {
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 @@ public class TestHttpRoute extends TestCase {
// 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 class TestHttpRoute extends TestCase {
}
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 @@ public class TestHttpRoute extends TestCase {
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 @@ public class TestHttpRoute extends TestCase {
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 class TestHttpRoute extends TestCase {
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 @@ public class TestHttpRoute extends TestCase {
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 @@ public class TestHttpRoute extends TestCase {
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 class TestHttpRoute extends TestCase {
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 class TestHttpRoute extends TestCase {
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 @@ public class TestHttpRoute extends TestCase {
// 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 class TestHttpRoute extends TestCase {
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 class TestHttpRoute extends TestCase {
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;

View File

@ -38,6 +38,8 @@ import junit.framework.TestCase;
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 @@ public class TestRouteDirector extends TestCase {
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",

View File

@ -40,6 +40,8 @@ import junit.framework.TestCase;
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 @@ public class TestRouteTracker extends TestCase {
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 @@ public class TestRouteTracker extends TestCase {
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);