1 20 package org.enhydra.barracuda.plankton.data; 21 22 import java.util.*; 23 24 import junit.framework.*; 25 26 import org.apache.log4j.*; 28 import org.enhydra.barracuda.testbed.*; 29 30 31 34 public class TestPArrayList extends PListTestCases { 35 static { 37 testClass = TestPArrayList.class.getName(); 38 logger = Logger.getLogger("test."+testClass); 39 } 40 41 45 public TestPArrayList(String name) { 46 super(name); 47 } 48 49 56 public static void main(String args[]) { 57 TestUtil.parseParams(args); 59 60 if (TestUtil.BATCH_MODE) junit.textui.TestRunner.main(new String [] {testClass}); 62 else junit.swingui.TestRunner.main(new String [] {testClass}); 63 } 64 65 66 72 75 80 public void testClone() { 81 if (logger.isInfoEnabled()) logger.info("testing clone()"); 82 83 PArrayList plist1 = (PArrayList) this.getPListInstance(); 85 PArrayList plist2 = (PArrayList) plist1.clone(); 86 assertTrue("Cloned obj==source obj at 1", plist1!=plist2); 87 assertEquals("Clone check 1a failed", plist1, plist2); 88 assertEquals("Clone check 1b failed", plist2, plist1); 89 90 plist1 = (PArrayList) this.getPListInstance(); 92 plist1.add("foo1"); 93 plist1.add("foo2"); 94 plist1.add("foo3"); 95 plist1.add(new Integer (99)); 96 plist1.add(null); 97 plist2 = (PArrayList) plist1.clone(); 98 assertTrue("Cloned obj==source obj at 2", plist1!=plist2); 99 assertEquals("Clone check 2a failed", plist1, plist2); 100 assertEquals("Clone check 2b failed", plist2, plist1); 101 102 plist1 = (PArrayList) this.getPListInstance(); 104 plist1.add("foo1"); 105 PList plTmp = this.getPListInstance(); 106 plTmp.add("blah 1"); 107 plTmp.add("blah 2"); 108 plist1.add(plTmp); 109 plist2 = (PArrayList) plist1.clone(); 110 assertTrue("Cloned obj==source obj at 3", plist1!=plist2); 111 assertEquals("Clone check 3a failed", plist1, plist2); 112 assertEquals("Clone check 3b failed", plist2, plist1); 113 } 114 115 public StateMap getStateMap() { 117 return getPListInstance(); 118 } 119 120 public PData getPDataInstance() { 121 return getPListInstance(); 122 } 123 124 public PList getPListInstance() { 125 return new PArrayList(); 126 } 127 128 public PMap getPMapInstance() { 129 return new PHashMap(); 130 } 131 } 132 | Popular Tags |