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

Comparing jsr166/src/test/tck/CopyOnWriteArraySetTest.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 8 | Line 8
8   import junit.framework.*;
9   import java.util.*;
10   import java.util.concurrent.*;
11 + import java.io.*;
12  
13   public class CopyOnWriteArraySetTest extends TestCase{
14      
# Line 236 | Line 237 | public class CopyOnWriteArraySetTest ext
237          }catch(ArrayStoreException e){}
238      }
239  
240 +    public void testSerialization() {
241 +        CopyOnWriteArraySet q = fullSet(10);
242 +
243 +        try {
244 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
245 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
246 +            out.writeObject(q);
247 +            out.close();
248 +
249 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
250 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
251 +            CopyOnWriteArraySet r = (CopyOnWriteArraySet)in.readObject();
252 +            assertEquals(q.size(), r.size());
253 +            assertTrue(q.equals(r));
254 +            assertTrue(r.equals(q));
255 +        } catch(Exception e){
256 +            e.printStackTrace();
257 +            fail("unexpected exception");
258 +        }
259 +    }
260 +
261   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines