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.CloneLibrary;
015: import org.vfny.geoserver.global.dto.EqualsLibrary;
016:
017: import com.vividsolutions.jts.geom.Envelope;
018:
019: /**
020: * CloneLibraryTest purpose.
021: *
022: * <p>
023: * Description of CloneLibraryTest ...
024: * </p>
025: *
026: * <p></p>
027: *
028: * @author dzwiers, Refractions Research, Inc.
029: * @version $Id: CloneLibraryTest.java 6326 2007-03-15 18:36:40Z jdeolive $
030: */
031: public class CloneLibraryTest extends TestCase {
032: /**
033: * Constructor for CloneLibraryTest.
034: *
035: * @param arg0
036: */
037: public CloneLibraryTest(String arg0) {
038: super (arg0);
039: }
040:
041: /*
042: * Test for List clone(List)
043: */
044: public void testCloneList() {
045: List a;
046: List b;
047: a = new LinkedList();
048: b = null;
049: a.add("a");
050: a.add("b");
051: a.add("c");
052:
053: try {
054: b = CloneLibrary.clone(a);
055: } catch (CloneNotSupportedException e) {
056: fail(e.toString());
057: }
058:
059: // requires EqualsLibrary tests to be completed
060: assertTrue(EqualsLibrary.equals(a, b));
061:
062: a.add("d");
063: assertTrue(!EqualsLibrary.equals(a, b));
064:
065: try {
066: b = CloneLibrary.clone(a);
067: } catch (CloneNotSupportedException e) {
068: fail(e.toString());
069: }
070:
071: assertTrue(EqualsLibrary.equals(a, b));
072:
073: a.remove("d");
074: a.add("d");
075: assertTrue(EqualsLibrary.equals(a, b));
076: }
077:
078: /*
079: * Test for Map clone(Map)
080: */
081: public void testCloneMap() {
082: Map a;
083: Map b;
084: a = new HashMap();
085: b = null;
086: a.put("a", new Integer(0));
087: a.put("b", new Integer(1));
088: a.put("c", new Integer(2));
089:
090: try {
091: b = CloneLibrary.clone(a);
092: } catch (CloneNotSupportedException e) {
093: fail(e.toString());
094: }
095:
096: // requires EqualsLibrary tests to be completed
097: assertTrue(EqualsLibrary.equals(a, b));
098:
099: a.put("d", new Integer(3));
100: assertTrue(!EqualsLibrary.equals(a, b));
101:
102: try {
103: b = CloneLibrary.clone(a);
104: } catch (CloneNotSupportedException e) {
105: fail(e.toString());
106: }
107:
108: assertTrue(EqualsLibrary.equals(a, b));
109:
110: a.remove("d");
111: a.put("d", new Integer(3));
112: assertTrue(EqualsLibrary.equals(a, b));
113: }
114:
115: /*
116: * Test for Envelope clone(Envelope)
117: */
118: public void testCloneEnvelope() {
119: Envelope a;
120: Envelope b;
121: a = new Envelope(1, 2, 3, 4);
122: b = CloneLibrary.clone(a);
123: assertTrue(a.equals(b));
124:
125: a.expandToInclude(5, 6);
126: assertTrue(!a.equals(b));
127:
128: b = CloneLibrary.clone(a);
129: assertTrue(a.equals(b));
130: }
131: }
|