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

Comparing jsr166/src/test/tck/ConcurrentLinkedDequeTest.java (file contents):
Revision 1.6 by jsr166, Thu Nov 18 20:21:53 2010 UTC vs.
Revision 1.11 by jsr166, Tue Feb 21 02:04:17 2012 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
8  
9   import junit.framework.*;
10 < import java.util.*;
11 < import java.util.concurrent.*;
12 < import java.io.*;
10 > import java.util.Arrays;
11 > import java.util.Collection;
12 > import java.util.Iterator;
13 > import java.util.NoSuchElementException;
14 > import java.util.Queue;
15 > import java.util.Random;
16 > import java.util.concurrent.ConcurrentLinkedDeque;
17  
18   public class ConcurrentLinkedDequeTest extends JSR166TestCase {
19  
# Line 22 | Line 26 | public class ConcurrentLinkedDequeTest e
26      }
27  
28      /**
29 <     * Create a deque of given size containing consecutive
29 >     * Returns a new deque of given size containing consecutive
30       * Integers 0 ... n.
31       */
32      private ConcurrentLinkedDeque<Integer> populatedDeque(int n) {
# Line 835 | Line 839 | public class ConcurrentLinkedDequeTest e
839          ConcurrentLinkedDeque q = populatedDeque(SIZE);
840          String s = q.toString();
841          for (int i = 0; i < SIZE; ++i) {
842 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
842 >            assertTrue(s.contains(String.valueOf(i)));
843          }
844      }
845  
# Line 843 | Line 847 | public class ConcurrentLinkedDequeTest e
847       * A deserialized serialized deque has same elements in same order
848       */
849      public void testSerialization() throws Exception {
850 <        ConcurrentLinkedDeque q = populatedDeque(SIZE);
851 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
852 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
853 <        out.writeObject(q);
854 <        out.close();
855 <
856 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
857 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
858 <        ConcurrentLinkedDeque r = (ConcurrentLinkedDeque)in.readObject();
859 <        assertEquals(q.size(), r.size());
860 <        while (!q.isEmpty())
861 <            assertEquals(q.remove(), r.remove());
850 >        Queue x = populatedDeque(SIZE);
851 >        Queue y = serialClone(x);
852 >
853 >        assertTrue(x != y);
854 >        assertEquals(x.size(), y.size());
855 >        assertEquals(x.toString(), y.toString());
856 >        assertTrue(Arrays.equals(x.toArray(), y.toArray()));
857 >        while (!x.isEmpty()) {
858 >            assertFalse(y.isEmpty());
859 >            assertEquals(x.remove(), y.remove());
860 >        }
861 >        assertTrue(y.isEmpty());
862      }
863  
864   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines