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 TestPHashMap extends PMapTestCases { 35 static { 37 testClass = TestPHashMap.class.getName(); 38 logger = Logger.getLogger("test."+testClass); 39 } 40 41 45 public TestPHashMap(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 PHashMap pmap1 = null; 83 PHashMap pmap2 = null; 84 85 pmap1 = (PHashMap) this.getPMapInstance(); 87 pmap2 = (PHashMap) pmap1.clone(); 88 assertTrue("Cloned obj==source obj at 1", pmap1!=pmap2); 89 assertEquals("Clone check 1a failed", pmap1, pmap2); 90 assertEquals("Clone check 1b failed", pmap2, pmap1); 91 92 pmap1 = (PHashMap) this.getPMapInstance(); 94 pmap1.put("key1", "foo1"); 95 pmap1.put("key2", "foo2"); 96 pmap1.put("key3", "foo3"); 97 pmap1.put("key4", new Integer (99)); 98 pmap1.put("key5", null); 99 pmap2 = (PHashMap) pmap1.clone(); 100 assertTrue("Cloned obj==source obj at 2", pmap1!=pmap2); 101 assertEquals("Clone check 2a failed", pmap1, pmap2); 102 assertEquals("Clone check 2b failed", pmap2, pmap1); 103 104 pmap1 = (PHashMap) this.getPMapInstance(); 106 pmap1.put("key1", "foo1"); 107 PMap pmTmp = this.getPMapInstance(); 108 pmTmp.put("key2a", "blah 1"); 109 pmTmp.put("key2b", "blah 2"); 110 pmap1.put("key2", pmTmp); 111 pmap2 = (PHashMap) pmap1.clone(); 112 assertTrue("Cloned obj==source obj at 3", pmap1!=pmap2); 113 assertEquals("Clone check 3a failed", pmap1, pmap2); 114 assertEquals("Clone check 3b failed", pmap2, pmap1); 115 } 116 117 118 public StateMap getStateMap() { 120 return getPMapInstance(); 121 } 122 123 public PData getPDataInstance() { 124 return getPMapInstance(); 125 } 126 127 public PList getPListInstance() { 128 return new PArrayList(); 129 } 130 131 public PMap getPMapInstance() { 132 return new PHashMap(); 133 } 134 } 135 | Popular Tags |