1 16 package org.apache.commons.collections.keyvalue; 17 18 import java.util.HashMap ; 19 import java.util.Map ; 20 21 import junit.framework.Test; 22 import junit.framework.TestSuite; 23 24 32 public class TestTiedMapEntry extends AbstractTestMapEntry { 33 34 public TestTiedMapEntry(String testName) { 35 super(testName); 36 37 } 38 39 public static void main(String [] args) { 40 junit.textui.TestRunner.run(TestTiedMapEntry.class); 41 } 42 43 public static Test suite() { 44 return new TestSuite(TestTiedMapEntry.class); 45 } 46 47 51 public Map.Entry makeMapEntry(Object key, Object value) { 52 Map map = new HashMap (); 53 map.put(key, value); 54 return new TiedMapEntry(map, key); 55 } 56 57 61 public void testConstructors() { 62 } 64 65 68 public void testSetValue() { 69 Map map = new HashMap (); 70 map.put("A", "a"); 71 map.put("B", "b"); 72 map.put("C", "c"); 73 Map.Entry entry = new TiedMapEntry(map, "A"); 74 assertSame("A", entry.getKey()); 75 assertSame("a", entry.getValue()); 76 assertSame("a", entry.setValue("x")); 77 assertSame("A", entry.getKey()); 78 assertSame("x", entry.getValue()); 79 80 entry = new TiedMapEntry(map, "B"); 81 assertSame("B", entry.getKey()); 82 assertSame("b", entry.getValue()); 83 assertSame("b", entry.setValue("y")); 84 assertSame("B", entry.getKey()); 85 assertSame("y", entry.getValue()); 86 87 entry = new TiedMapEntry(map, "C"); 88 assertSame("C", entry.getKey()); 89 assertSame("c", entry.getValue()); 90 assertSame("c", entry.setValue("z")); 91 assertSame("C", entry.getKey()); 92 assertSame("z", entry.getValue()); 93 } 94 95 } 96 | Popular Tags |