1 29 30 package org.apache.commons.httpclient.cookie; 31 32 import java.util.Comparator ; 33 34 import junit.framework.Test; 35 import junit.framework.TestSuite; 36 37 import org.apache.commons.httpclient.Cookie; 38 39 42 public class TestCookiePathComparator extends TestCookieBase { 43 44 45 47 public TestCookiePathComparator(String name) { 48 super(name); 49 } 50 51 53 public static Test suite() { 54 return new TestSuite(TestCookiePathComparator.class); 55 } 56 57 public void testUnequality1() { 58 Cookie cookie1 = new Cookie(".whatever.com", "name1", "value", "/a/b/", null, false); 59 Cookie cookie2 = new Cookie(".whatever.com", "name1", "value", "/a/", null, false); 60 Comparator comparator = new CookiePathComparator(); 61 assertTrue(comparator.compare(cookie1, cookie2) < 0); 62 assertTrue(comparator.compare(cookie2, cookie1) > 0); 63 } 64 65 public void testUnequality2() { 66 Cookie cookie1 = new Cookie(".whatever.com", "name1", "value", "/a/b", null, false); 67 Cookie cookie2 = new Cookie(".whatever.com", "name1", "value", "/a", null, false); 68 Comparator comparator = new CookiePathComparator(); 69 assertTrue(comparator.compare(cookie1, cookie2) < 0); 70 assertTrue(comparator.compare(cookie2, cookie1) > 0); 71 } 72 73 public void testEquality1() { 74 Cookie cookie1 = new Cookie(".whatever.com", "name1", "value", "/a", null, false); 75 Cookie cookie2 = new Cookie(".whatever.com", "name1", "value", "/a", null, false); 76 Comparator comparator = new CookiePathComparator(); 77 assertTrue(comparator.compare(cookie1, cookie2) == 0); 78 assertTrue(comparator.compare(cookie2, cookie1) == 0); 79 } 80 81 public void testEquality2() { 82 Cookie cookie1 = new Cookie(".whatever.com", "name1", "value", "/a/", null, false); 83 Cookie cookie2 = new Cookie(".whatever.com", "name1", "value", "/a", null, false); 84 Comparator comparator = new CookiePathComparator(); 85 assertTrue(comparator.compare(cookie1, cookie2) == 0); 86 assertTrue(comparator.compare(cookie2, cookie1) == 0); 87 } 88 89 public void testEquality3() { 90 Cookie cookie1 = new Cookie(".whatever.com", "name1", "value", null, null, false); 91 Cookie cookie2 = new Cookie(".whatever.com", "name1", "value", "/", null, false); 92 Comparator comparator = new CookiePathComparator(); 93 assertTrue(comparator.compare(cookie1, cookie2) == 0); 94 assertTrue(comparator.compare(cookie2, cookie1) == 0); 95 } 96 97 public void testEquality4() { 98 Cookie cookie1 = new Cookie(".whatever.com", "name1", "value", "/this", null, false); 99 Cookie cookie2 = new Cookie(".whatever.com", "name1", "value", "/that", null, false); 100 Comparator comparator = new CookiePathComparator(); 101 assertTrue(comparator.compare(cookie1, cookie2) == 0); 102 assertTrue(comparator.compare(cookie2, cookie1) == 0); 103 } 104 105 } 106 107 | Popular Tags |