1 package gate.util;
2
3 import junit.framework.*;
4
5
12
13 public class TestFeatureMap extends TestCase {
14
15
16 private static final boolean DEBUG = false;
17
18
19 public TestFeatureMap(String name) { super(name); }
20
21
22 public void testPutAndGet() throws Exception {
23 assertTrue(true);
24 SimpleFeatureMapImpl map = new SimpleFeatureMapImpl();
25 map.put("1", "bala");
26 map.put("1", "bala2");
27 map.put("2", "20");
28 map.put("3", null);
29 map.put(null, "5");
30
31 Object value = null;
32
36 value = map.get("1");
37 assertSame(value, "bala2");
38
42 value = map.get("2");
43 assertSame(value, "20");
44
48 value = map.get("3");
49 assertSame(value, null);
50
54 value = map.get(null);
55 assertSame(value, "5");
56 }
58 public void testSubsume() throws Exception {
59 assertTrue(true);
60 SimpleFeatureMapImpl map = new SimpleFeatureMapImpl();
61 SimpleFeatureMapImpl map2 = new SimpleFeatureMapImpl();
62 map.put("1", "bala");
63 map2.put("1", map.get("1"));
64
65 map.put("2", "20");
66
70 assertTrue(map.subsumes(map2));
71
75 assertTrue(!map2.subsumes(map));
76
80 assertTrue(map.subsumes(map2, map2.keySet()));
81
85 assertTrue(map2.subsumes(map, map2.keySet()));
86
87
92 map.put("3", null);
93 map2.put("3", "not null");
94
95 assertTrue(!map.subsumes(map2));
96 assertTrue(!map2.subsumes(map));
97 assertTrue(!map.subsumes(map2, map2.keySet()));
98 assertTrue(!map2.subsumes(map, map2.keySet()));
99
100
104 map2.put("3", null);
105
106 assertTrue(map.subsumes(map2));
107 assertTrue(!map2.subsumes(map));
108 assertTrue(map.subsumes(map2, map2.keySet()));
109 assertTrue(map2.subsumes(map, map2.keySet()));
110
111
114 map.put(null, "5");
115 map2.put(null, "5");
116
117 assertTrue(map.subsumes(map2));
118 assertTrue(!map2.subsumes(map));
119 assertTrue(map.subsumes(map2, map2.keySet()));
120 assertTrue(map2.subsumes(map, map2.keySet()));
121 }
123
124 public static Test suite() {
125 return new TestSuite(TestFeatureMap.class);
126 }
128 public static void main(String args[]){
129 TestFeatureMap app = new TestFeatureMap("TestFeatureMap");
130 try {
131 app.testPutAndGet();
132 app.testSubsume();
133 } catch (Exception e) {
134 e.printStackTrace (Err.getPrintWriter());
135 }
136 } }