01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestCookieComparator.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.site;
09:
10: import javax.servlet.http.Cookie;
11: import junit.framework.TestCase;
12:
13: public class TestCookieComparator extends TestCase {
14: public TestCookieComparator(String name) {
15: super (name);
16: }
17:
18: public void testCompare() {
19: Cookie cookie1 = new Cookie("name1", "value1");
20: Cookie cookie2 = new Cookie("name2", "value2");
21: Cookie cookie3 = new Cookie("name2", "value1");
22:
23: CookieComparator comparator = new CookieComparator();
24: assertTrue(comparator.compare(cookie1, cookie1) == 0);
25: assertTrue(comparator.compare(cookie1, cookie2) < 0);
26: assertTrue(comparator.compare(cookie1, cookie3) < 0);
27: assertTrue(comparator.compare(cookie2, cookie1) > 0);
28: assertTrue(comparator.compare(cookie2, cookie2) == 0);
29: assertTrue(comparator.compare(cookie2, cookie3) == 0);
30: assertTrue(comparator.compare(cookie3, cookie1) > 0);
31: assertTrue(comparator.compare(cookie3, cookie2) == 0);
32: assertTrue(comparator.compare(cookie3, cookie3) == 0);
33: }
34: }
|