public void testCookieOrdering2() throws Exception {
   URL url = new URL("http://order.now/sub1/moo.html");
   man.addCookieFromHeader("test1=moo1;", url);
   man.addCookieFromHeader("test2=moo2;path=/sub1", url);
   man.addCookieFromHeader("test2=moo3;path=/", url);
   assertEquals(3, man.getCookieCount());
   assertEquals("/sub1", man.get(0).getPath()); // Defaults to caller URL
   assertEquals("/sub1", man.get(1).getPath());
   assertEquals("/", man.get(2).getPath());
   String s = man.getCookieHeaderForURL(url);
   assertNotNull(s);
   org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
   assertEquals("/sub1", c[0].getPath());
   assertFalse(c[0].isPathAttributeSpecified());
   assertEquals("/sub1", c[1].getPath());
   assertTrue(c[1].isPathAttributeSpecified());
   assertEquals("/", c[2].getPath());
   assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
 }
 public void testCookiePolicyNetscape() throws Exception {
   man.setCookiePolicy(CookiePolicy.NETSCAPE);
   man.testStarted(); // ensure policy is picked up
   URL url = new URL("http://www.order.now/sub1/moo.html");
   man.addCookieFromHeader("test1=moo1;", url);
   man.addCookieFromHeader("test2=moo2;path=/sub1", url);
   man.addCookieFromHeader("test2=moo3;path=/", url);
   assertEquals(3, man.getCookieCount());
   assertEquals("/sub1", man.get(0).getPath());
   assertEquals("/sub1", man.get(1).getPath());
   assertEquals("/", man.get(2).getPath());
   String s = man.getCookieHeaderForURL(url);
   assertNotNull(s);
   org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
   assertEquals("/sub1", c[0].getPath());
   assertFalse(c[0].isPathAttributeSpecified());
   assertEquals("/sub1", c[1].getPath());
   assertTrue(c[1].isPathAttributeSpecified());
   assertEquals("/", c[2].getPath());
   assertTrue(c[2].isPathAttributeSpecified());
   assertEquals("test1=moo1; test2=moo2; test2=moo3", s);
 }
 public void testCookiePolicyIgnore() throws Exception {
   man.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
   man.testStarted(); // ensure policy is picked up
   URL url = new URL("http://order.now/sub1/moo.html");
   man.addCookieFromHeader("test1=moo1;", url);
   man.addCookieFromHeader("test2=moo2;path=/sub1", url);
   man.addCookieFromHeader("test2=moo3;path=/", url);
   assertEquals(0, man.getCookieCount()); // Cookies are ignored
   Cookie cc;
   cc = new Cookie("test1", "moo1", null, "/sub1", false, 0, false, false);
   man.add(cc);
   cc = new Cookie("test2", "moo2", null, "/sub1", false, 0, true, false);
   man.add(cc);
   cc = new Cookie("test3", "moo3", null, "/", false, 0, false, false);
   man.add(cc);
   assertEquals(3, man.getCookieCount());
   assertEquals("/sub1", man.get(0).getPath());
   assertEquals("/sub1", man.get(1).getPath());
   assertEquals("/", man.get(2).getPath());
   String s = man.getCookieHeaderForURL(url);
   assertNull(s);
   org.apache.commons.httpclient.Cookie[] c = man.getCookiesForUrl(url);
   assertEquals(0, c.length); // Cookies again ignored
 }