@Test public void testUnequality1() { BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/a/b/"); BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); cookie2.setPath("/a/"); Comparator<Cookie> comparator = new CookiePathComparator(); Assert.assertTrue(comparator.compare(cookie1, cookie2) < 0); Assert.assertTrue(comparator.compare(cookie2, cookie1) > 0); }
public int compare(final Cookie c1, final Cookie c2) { String path1 = normalizePath(c1); String path2 = normalizePath(c2); if (path1.equals(path2)) { return 0; } else if (path1.startsWith(path2)) { return -1; } else if (path2.startsWith(path1)) { return 1; } else { return 0; } }
CookiePathComparator implements Serializable, Comparator<Cookie> { public int compare(final Cookie c1, final Cookie c2) { String path1 = normalizePath(c1); String path2 = normalizePath(c2); if (path1.equals(path2)) { return 0; } else if (path1.startsWith(path2)) { return -1; } else if (path2.startsWith(path1)) { return 1; } else { return 0; } } }
CookiePathComparator implements Serializable, Comparator<Cookie> { public int compare(final Cookie c1, final Cookie c2) { String path1 = normalizePath(c1); String path2 = normalizePath(c2); if (path1.equals(path2)) { return 0; } else if (path1.startsWith(path2)) { return -1; } else if (path2.startsWith(path1)) { return 1; } else { return 0; } }  }
CookiePathComparator implements Serializable, Comparator<Cookie> { public int compare(final Cookie c1, final Cookie c2) { String path1 = normalizePath(c1); String path2 = normalizePath(c2); if (path1.equals(path2)) { return 0; } else if (path1.startsWith(path2)) { return -1; } else if (path2.startsWith(path1)) { return 1; } else { return 0; } }  int compare(final Cookie c1, final Cookie c2); }
CookiePathComparator implements Serializable, Comparator<Cookie> { public int compare(final Cookie c1, final Cookie c2) { String path1 = normalizePath(c1); String path2 = normalizePath(c2); if (path1.equals(path2)) { return 0; } else if (path1.startsWith(path2)) { return -1; } else if (path2.startsWith(path1)) { return 1; } else { return 0; } }  int compare(final Cookie c1, final Cookie c2);  }