001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.global;
006:
007: import java.util.HashMap;
008: import java.util.LinkedList;
009: import java.util.List;
010: import java.util.Map;
011:
012: import junit.framework.TestCase;
013:
014: import org.vfny.geoserver.global.dto.EqualsLibrary;
015:
016: /**
017: * EqualsLibraryTest purpose.
018: *
019: * <p>
020: * Description of EqualsLibraryTest ...
021: * </p>
022: *
023: * <p></p>
024: *
025: * @author dzwiers, Refractions Research, Inc.
026: * @version $Id: EqualsLibraryTest.java 6326 2007-03-15 18:36:40Z jdeolive $
027: */
028: public class EqualsLibraryTest extends TestCase {
029: /**
030: * Constructor for EqualsLibraryTest.
031: *
032: * @param arg0
033: */
034: public EqualsLibraryTest(String arg0) {
035: super (arg0);
036: }
037:
038: /*
039: * Test for boolean equals(List, List)
040: */
041: public void testEqualsListList() {
042: List a;
043: List b;
044: a = new LinkedList();
045: b = new LinkedList();
046: a.add("a");
047: b.add("a");
048: a.add("b");
049: b.add("b");
050: a.add("c");
051: b.add("c");
052:
053: assertTrue(EqualsLibrary.equals(a, b));
054:
055: a.add("d");
056: b.add("e");
057: a.add("e");
058: b.add("d");
059:
060: assertTrue(EqualsLibrary.equals(a, b));
061:
062: a.add("f");
063: b.add("a");
064: a.add("a");
065: b.add("f");
066:
067: assertTrue(EqualsLibrary.equals(a, b));
068:
069: a.add("g");
070:
071: assertTrue(!EqualsLibrary.equals(a, b));
072: }
073:
074: /*
075: * Test for boolean equals(Map, Map)
076: */
077: public void testEqualsMapMap() {
078: Map a;
079: Map b;
080: a = new HashMap();
081: b = new HashMap();
082: a.put("0", new Integer(0));
083: b.put("0", new Integer(0));
084: a.put("1", new Integer(1));
085: b.put("1", new Integer(1));
086: a.put("2", new Integer(2));
087: b.put("2", new Integer(2));
088:
089: assertTrue(EqualsLibrary.equals(a, b));
090:
091: a.put("3", new Integer(3));
092: b.put("4", new Integer(4));
093: a.put("4", new Integer(4));
094: b.put("3", new Integer(3));
095:
096: assertTrue(EqualsLibrary.equals(a, b));
097:
098: a.put("5", new Integer(5));
099: b.put("6", new Integer(5));
100:
101: assertTrue(!EqualsLibrary.equals(a, b));
102:
103: a.put("5", new Integer(5));
104: b.put("5", new Integer(5));
105: b.remove("6");
106:
107: assertTrue(EqualsLibrary.equals(a, b));
108:
109: a.put("5", new Integer(6));
110:
111: assertTrue(!EqualsLibrary.equals(a, b));
112:
113: a.put("5", new Integer(5));
114:
115: assertTrue(EqualsLibrary.equals(a, b));
116: }
117: }
|