@Test public void testCompatibleClientPolicies() { ClientPolicyCalculator calc = new ClientPolicyCalculator(); HTTPClientPolicy p1 = new HTTPClientPolicy(); assertTrue("Policy is not compatible with itself.", calc.compatible(p1, p1)); HTTPClientPolicy p2 = new HTTPClientPolicy(); assertTrue("Policies are not compatible.", calc.compatible(p1, p2)); p1.setBrowserType("browser"); assertTrue("Policies are not compatible.", calc.compatible(p1, p2)); p1.setBrowserType(null); p1.setConnectionTimeout(10000); assertTrue("Policies are not compatible.", calc.compatible(p1, p2)); p1.setAllowChunking(false); assertTrue("Policies are compatible.", !calc.compatible(p1, p2)); p2.setAllowChunking(false); assertTrue("Policies are compatible.", calc.compatible(p1, p2)); }
@Test public void testIntersectClientPolicies() { ClientPolicyCalculator calc = new ClientPolicyCalculator(); HTTPClientPolicy p1 = new HTTPClientPolicy(); HTTPClientPolicy p2 = new HTTPClientPolicy(); HTTPClientPolicy p = null; p1.setBrowserType("browser"); p = calc.intersect(p1, p2); assertEquals("browser", p.getBrowserType()); p1.setBrowserType(null); p1.setConnectionTimeout(10000L); p = calc.intersect(p1, p2); assertEquals(10000L, p.getConnectionTimeout()); p1.setAllowChunking(false); p2.setAllowChunking(false); p = calc.intersect(p1, p2); assertTrue(!p.isAllowChunking()); }