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

Comparing jsr166/src/test/tck/PriorityQueueTest.java (file contents):
Revision 1.1 by dl, Sun Aug 31 19:24:55 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 PriorityQueueTest extends TestCase {
14  
# Line 270 | Line 271 | public class PriorityQueueTest extends T
271              assertTrue(q.remove(new Integer(i)));
272              assertFalse(q.remove(new Integer(i+1)));
273          }
274 <        assert(q.isEmpty());
274 >        assertTrue(q.isEmpty());
275      }
276          
277      public void testContains(){
# Line 388 | Line 389 | public class PriorityQueueTest extends T
389          }
390      }        
391  
392 +    public void testSerialization() {
393 +        PriorityQueue q = fullQueue(N);
394 +        try {
395 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
396 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
397 +            out.writeObject(q);
398 +            out.close();
399 +
400 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
401 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
402 +            PriorityQueue r = (PriorityQueue)in.readObject();
403 +            assertEquals(q.size(), r.size());
404 +            while (!q.isEmpty())
405 +                assertEquals(q.remove(), r.remove());
406 +        } catch(Exception e){
407 +            fail("unexpected exception");
408 +        }
409 +    }
410   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines