11 |
|
import java.util.Enumeration; |
12 |
|
import java.io.*; |
13 |
|
|
14 |
< |
public class ConcurrentHashMapTest extends TestCase{ |
14 |
> |
public class ConcurrentHashMapTest extends JSR166TestCase{ |
15 |
|
public static void main(String[] args) { |
16 |
|
junit.textui.TestRunner.run (suite()); |
17 |
|
} |
19 |
|
return new TestSuite(ConcurrentHashMapTest.class); |
20 |
|
} |
21 |
|
|
22 |
– |
static final Integer one = new Integer(1); |
23 |
– |
static final Integer two = new Integer(2); |
24 |
– |
static final Integer three = new Integer(3); |
25 |
– |
static final Integer four = new Integer(4); |
26 |
– |
static final Integer five = new Integer(5); |
27 |
– |
|
22 |
|
private static ConcurrentHashMap map5() { |
23 |
|
ConcurrentHashMap map = new ConcurrentHashMap(5); |
24 |
|
assertTrue(map.isEmpty()); |
33 |
|
} |
34 |
|
|
35 |
|
/** |
36 |
< |
* Test to verify clear correctly removes all key-element pairs from the map |
36 |
> |
* clear removes all key-element pairs from the map |
37 |
|
*/ |
38 |
|
public void testClear(){ |
39 |
|
ConcurrentHashMap map = map5(); |
42 |
|
} |
43 |
|
|
44 |
|
/** |
45 |
< |
* Test to verify contains gives the appropriate value |
45 |
> |
* contains gives the appropriate value |
46 |
|
*/ |
47 |
|
public void testContains(){ |
48 |
|
ConcurrentHashMap map = map5(); |
51 |
|
} |
52 |
|
|
53 |
|
/** |
54 |
< |
* Test to verify containsKey gives the appropriate value |
54 |
> |
* containsKey gives the appropriate value |
55 |
|
*/ |
56 |
|
public void testContainsKey(){ |
57 |
|
ConcurrentHashMap map = map5(); |
83 |
|
} |
84 |
|
|
85 |
|
/** |
86 |
< |
* Test to verify get returns the correct element at the given index |
86 |
> |
* get returns the correct element at the given index |
87 |
|
*/ |
88 |
|
public void testGet(){ |
89 |
|
ConcurrentHashMap map = map5(); |
91 |
|
} |
92 |
|
|
93 |
|
/** |
94 |
< |
* Test to verify get on a nonexistant key returns null |
94 |
> |
* get on a nonexistant key returns null |
95 |
|
*/ |
96 |
|
public void testGet2(){ |
97 |
|
ConcurrentHashMap empty = new ConcurrentHashMap(); |
109 |
|
} |
110 |
|
|
111 |
|
/** |
112 |
< |
* Test to verify keys returns an enumeration containing all the keys from the map |
112 |
> |
* keys returns an enumeration containing all the keys from the map |
113 |
|
*/ |
114 |
|
public void testKeys(){ |
115 |
|
ConcurrentHashMap map = map5(); |
123 |
|
} |
124 |
|
|
125 |
|
/** |
126 |
< |
* Test to verify keySet returns a Set containing all the keys |
126 |
> |
* keySet returns a Set containing all the keys |
127 |
|
*/ |
128 |
|
public void testKeySet(){ |
129 |
|
ConcurrentHashMap map = map5(); |
164 |
|
} |
165 |
|
|
166 |
|
/** |
167 |
< |
* Test to verify putAll correctly adds all key-value pairs from the given map |
167 |
> |
* putAll adds all key-value pairs from the given map |
168 |
|
*/ |
169 |
|
public void testPutAll(){ |
170 |
|
ConcurrentHashMap empty = new ConcurrentHashMap(); |
179 |
|
} |
180 |
|
|
181 |
|
/** |
182 |
< |
* Test to verify putIfAbsent works when the given key is not present |
182 |
> |
* putIfAbsent works when the given key is not present |
183 |
|
*/ |
184 |
|
public void testPutIfAbsent(){ |
185 |
|
ConcurrentHashMap map = map5(); |
188 |
|
} |
189 |
|
|
190 |
|
/** |
191 |
< |
* Test to verify putIfAbsent does not add the pair if the key is already present |
191 |
> |
* putIfAbsent does not add the pair if the key is already present |
192 |
|
*/ |
193 |
|
public void testPutIfAbsent2(){ |
194 |
|
ConcurrentHashMap map = map5(); |
196 |
|
} |
197 |
|
|
198 |
|
/** |
199 |
< |
* Test to verify remove removes the correct key-value pair from the map |
199 |
> |
* remove removes the correct key-value pair from the map |
200 |
|
*/ |
201 |
|
public void testRemove(){ |
202 |
|
ConcurrentHashMap map = map5(); |
217 |
|
} |
218 |
|
|
219 |
|
/** |
220 |
< |
* Simple test to verify size returns the correct values |
220 |
> |
* size returns the correct values |
221 |
|
*/ |
222 |
|
public void testSize(){ |
223 |
|
ConcurrentHashMap map = map5(); |