9 |
|
import java.util.*; |
10 |
|
import java.util.concurrent.*; |
11 |
|
import java.util.Enumeration; |
12 |
+ |
import java.io.*; |
13 |
|
|
14 |
|
public class ConcurrentHashMapTest extends TestCase{ |
15 |
|
public static void main(String[] args) { |
345 |
|
fail("ConcurrentHashMap - Object remove(Object, Object) should throw Null pointer exceptione"); |
346 |
|
}catch(NullPointerException e){} |
347 |
|
} |
348 |
+ |
|
349 |
+ |
public void testSerialization() { |
350 |
+ |
ConcurrentHashMap q = map5(); |
351 |
+ |
|
352 |
+ |
try { |
353 |
+ |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
354 |
+ |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
355 |
+ |
out.writeObject(q); |
356 |
+ |
out.close(); |
357 |
+ |
|
358 |
+ |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
359 |
+ |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
360 |
+ |
ConcurrentHashMap r = (ConcurrentHashMap)in.readObject(); |
361 |
+ |
assertEquals(q.size(), r.size()); |
362 |
+ |
assertTrue(q.equals(r)); |
363 |
+ |
assertTrue(r.equals(q)); |
364 |
+ |
} catch(Exception e){ |
365 |
+ |
e.printStackTrace(); |
366 |
+ |
fail("unexpected exception"); |
367 |
+ |
} |
368 |
+ |
} |
369 |
+ |
|
370 |
|
|
371 |
|
} |