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.framework.TestSuite; 23 24 import org.apache.commons.collections.Unmodifiable; 25 26 35 public class TestUnmodifiableMap extends AbstractTestIterableMap{ 36 37 public TestUnmodifiableMap(String testName) { 38 super(testName); 39 } 40 41 public static Test suite() { 42 return new TestSuite(TestUnmodifiableMap.class); 43 } 44 45 public static void main(String args[]) { 46 String [] testCaseName = { TestUnmodifiableMap.class.getName()}; 47 junit.textui.TestRunner.main(testCaseName); 48 } 49 50 52 public Map makeEmptyMap() { 53 return UnmodifiableMap.decorate(new HashMap ()); 54 } 55 56 public boolean isPutChangeSupported() { 57 return false; 58 } 59 60 public boolean isPutAddSupported() { 61 return false; 62 } 63 64 public boolean isRemoveSupported() { 65 return false; 66 } 67 68 public Map makeFullMap() { 69 Map m = new HashMap (); 70 addSampleMappings(m); 71 return UnmodifiableMap.decorate(m); 72 } 73 74 public void testUnmodifiable() { 76 assertTrue(makeEmptyMap() instanceof Unmodifiable); 77 assertTrue(makeFullMap() instanceof Unmodifiable); 78 } 79 80 public void testDecorateFactory() { 81 Map map = makeFullMap(); 82 assertSame(map, UnmodifiableMap.decorate(map)); 83 84 try { 85 UnmodifiableMap.decorate(null); 86 fail(); 87 } catch (IllegalArgumentException ex) {} 88 } 89 90 public String getCompatibilityVersion() { 91 return "3.1"; 92 } 93 94 } | Popular Tags |