@Test public void testLongTimeouts() { ClientPolicyCalculator calc = new ClientPolicyCalculator(); HTTPClientPolicy p1 = new HTTPClientPolicy(); HTTPClientPolicy p2 = new HTTPClientPolicy(); p2.setReceiveTimeout(120000); p2.setConnectionTimeout(60000); HTTPClientPolicy p = calc.intersect(p1, p2); assertEquals(120000, p.getReceiveTimeout()); assertEquals(60000, p.getConnectionTimeout()); p1 = new HTTPClientPolicy(); p2 = new HTTPClientPolicy(); p1.setReceiveTimeout(120000); p1.setConnectionTimeout(60000); p = calc.intersect(p1, p2); assertEquals(120000, p.getReceiveTimeout()); assertEquals(60000, p.getConnectionTimeout()); p2.setReceiveTimeout(50000); p2.setConnectionTimeout(20000); p = calc.intersect(p1, p2); // p1 should have priority assertEquals(120000, p.getReceiveTimeout()); assertEquals(60000, p.getConnectionTimeout()); // reverse intersect p = calc.intersect(p2, p1); // p2 should have priority assertEquals(50000, p.getReceiveTimeout()); assertEquals(20000, p.getConnectionTimeout()); }
@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()); }