ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentHashMapTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentHashMapTest.java (file contents):
Revision 1.1 by dl, Sun Aug 31 19:24:54 2003 UTC vs.
Revision 1.2 by dl, Sun Sep 7 20:39:11 2003 UTC

# Line 9 | Line 9 | import junit.framework.*;
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) {
# Line 344 | Line 345 | public class ConcurrentHashMapTest exten
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines