1 16 package org.apache.commons.collections.map; 17 18 import java.util.HashMap ; 19 import java.util.Map ; 20 21 import junit.framework.Test; 22 import junit.textui.TestRunner; 23 24 import org.apache.commons.collections.BoundedMap; 25 import org.apache.commons.collections.BulkTest; 26 import org.apache.commons.collections.KeyValue; 27 28 35 public class TestSingletonMap extends AbstractTestOrderedMap { 36 37 private static final Integer ONE = new Integer (1); 38 private static final Integer TWO = new Integer (2); 39 private static final String TEN = "10"; 40 private static final String TWENTY = "20"; 41 42 public TestSingletonMap(String testName) { 43 super(testName); 44 } 45 46 public static void main(String [] args) { 47 TestRunner.run(suite()); 48 } 49 50 public static Test suite() { 51 return BulkTest.makeSuite(TestSingletonMap.class); 52 } 53 54 public Map makeEmptyMap() { 56 return UnmodifiableOrderedMap.decorate(ListOrderedMap.decorate(new HashMap ())); 59 } 60 61 public String [] ignoredTests() { 62 return new String [] { 65 "TestSingletonMap.bulkTestMapIterator.testEmptyMapIterator", 66 "TestSingletonMap.bulkTestOrderedMapIterator.testEmptyMapIterator", 67 }; 68 } 69 70 71 public Map makeFullMap() { 72 return new SingletonMap(ONE, TWO); 73 } 74 75 public boolean isPutAddSupported() { 76 return false; 77 } 78 79 public boolean isRemoveSupported() { 80 return false; 81 } 82 83 public Object [] getSampleKeys() { 84 return new Object [] {ONE}; 85 } 86 87 public Object [] getSampleValues() { 88 return new Object [] {TWO}; 89 } 90 91 public Object [] getNewSampleValues() { 92 return new Object [] {TEN}; 93 } 94 95 public void testClone() { 97 SingletonMap map = new SingletonMap(ONE, TWO); 98 assertEquals(1, map.size()); 99 SingletonMap cloned = (SingletonMap) map.clone(); 100 assertEquals(1, cloned.size()); 101 assertEquals(true, cloned.containsKey(ONE)); 102 assertEquals(true, cloned.containsValue(TWO)); 103 } 104 105 public void testKeyValue() { 106 SingletonMap map = new SingletonMap(ONE, TWO); 107 assertEquals(1, map.size()); 108 assertEquals(ONE, map.getKey()); 109 assertEquals(TWO, map.getValue()); 110 assertTrue(map instanceof KeyValue); 111 } 112 113 public void testBoundedMap() { 114 SingletonMap map = new SingletonMap(ONE, TWO); 115 assertEquals(1, map.size()); 116 assertEquals(true, map.isFull()); 117 assertEquals(1, map.maxSize()); 118 assertTrue(map instanceof BoundedMap); 119 } 120 121 169 public String getCompatibilityVersion() { 170 return "3.1"; 171 } 172 173 } 184 | Popular Tags |