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

Comparing jsr166/src/test/tck/ConcurrentLinkedQueueTest.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 ConcurrentLinkedQueueTest extends TestCase {
14      private static final int N = 10;
# Line 223 | Line 224 | public class ConcurrentLinkedQueueTest e
224              assertTrue(q.remove(new Integer(i)));
225              assertFalse(q.remove(new Integer(i+1)));
226          }
227 <        assert(q.isEmpty());
227 >        assertTrue(q.isEmpty());
228      }
229          
230      public void testContains(){
# Line 379 | Line 380 | public class ConcurrentLinkedQueueTest e
380          }
381      }        
382  
383 +    public void testSerialization() {
384 +        ConcurrentLinkedQueue q = fullQueue(N);
385 +        try {
386 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
387 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
388 +            out.writeObject(q);
389 +            out.close();
390 +
391 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
392 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
393 +            ConcurrentLinkedQueue r = (ConcurrentLinkedQueue)in.readObject();
394 +            assertEquals(q.size(), r.size());
395 +            while (!q.isEmpty())
396 +                assertEquals(q.remove(), r.remove());
397 +        } catch(Exception e){
398 +            e.printStackTrace();
399 +            fail("unexpected exception");
400 +        }
401 +    }
402 +
403   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines