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.14 by jsr166, Sat Nov 21 10:29:50 2009 UTC vs.
Revision 1.20 by jsr166, Wed Nov 3 07:54:52 2010 UTC

# Line 14 | Line 14 | import java.io.*;
14   public class ConcurrentLinkedQueueTest extends JSR166TestCase {
15  
16      public static void main(String[] args) {
17 <        junit.textui.TestRunner.run (suite());
17 >        junit.textui.TestRunner.run(suite());
18      }
19  
20      public static Test suite() {
# Line 43 | Line 43 | public class ConcurrentLinkedQueueTest e
43      }
44  
45      /**
46 <     *  Initializing from null Collection throws NPE
46 >     * Initializing from null Collection throws NPE
47       */
48      public void testConstructor3() {
49          try {
# Line 73 | Line 73 | public class ConcurrentLinkedQueueTest e
73                  ints[i] = new Integer(i);
74              ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints));
75              shouldThrow();
76 <        }
77 <        catch (NullPointerException success) {}
76 >        } catch (NullPointerException success) {}
77      }
78  
79      /**
# Line 194 | Line 193 | public class ConcurrentLinkedQueueTest e
193              shouldThrow();
194          } catch (NullPointerException success) {}
195      }
196 +
197      /**
198 <     *  addAll of a collection with any null elements throws NPE after
198 >     * addAll of a collection with any null elements throws NPE after
199       * possibly adding some elements
200       */
201      public void testAddAll3() {
# Line 230 | Line 230 | public class ConcurrentLinkedQueueTest e
230      public void testPoll() {
231          ConcurrentLinkedQueue q = populatedQueue(SIZE);
232          for (int i = 0; i < SIZE; ++i) {
233 <            assertEquals(i, ((Integer)q.poll()).intValue());
233 >            assertEquals(i, q.poll());
234          }
235          assertNull(q.poll());
236      }
# Line 241 | Line 241 | public class ConcurrentLinkedQueueTest e
241      public void testPeek() {
242          ConcurrentLinkedQueue q = populatedQueue(SIZE);
243          for (int i = 0; i < SIZE; ++i) {
244 <            assertEquals(i, ((Integer)q.peek()).intValue());
245 <            q.poll();
244 >            assertEquals(i, q.peek());
245 >            assertEquals(i, q.poll());
246              assertTrue(q.peek() == null ||
247 <                       i != ((Integer)q.peek()).intValue());
247 >                       !q.peek().equals(i));
248          }
249          assertNull(q.peek());
250      }
# Line 255 | Line 255 | public class ConcurrentLinkedQueueTest e
255      public void testElement() {
256          ConcurrentLinkedQueue q = populatedQueue(SIZE);
257          for (int i = 0; i < SIZE; ++i) {
258 <            assertEquals(i, ((Integer)q.element()).intValue());
259 <            q.poll();
258 >            assertEquals(i, q.element());
259 >            assertEquals(i, q.poll());
260          }
261          try {
262              q.element();
# Line 265 | Line 265 | public class ConcurrentLinkedQueueTest e
265      }
266  
267      /**
268 <     *  remove removes next element, or throws NSEE if empty
268 >     * remove removes next element, or throws NSEE if empty
269       */
270      public void testRemove() {
271          ConcurrentLinkedQueue q = populatedQueue(SIZE);
272          for (int i = 0; i < SIZE; ++i) {
273 <            assertEquals(i, ((Integer)q.remove()).intValue());
273 >            assertEquals(i, q.remove());
274          }
275          try {
276              q.remove();
# Line 380 | Line 380 | public class ConcurrentLinkedQueueTest e
380      }
381  
382      /**
383 <     *  toArray(a) contains all elements
383 >     * toArray(a) contains all elements
384       */
385      public void testToArray2() {
386          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 395 | Line 395 | public class ConcurrentLinkedQueueTest e
395       * toArray(null) throws NPE
396       */
397      public void testToArray_BadArg() {
398 +        ConcurrentLinkedQueue q = populatedQueue(SIZE);
399          try {
399            ConcurrentLinkedQueue q = populatedQueue(SIZE);
400              Object o[] = q.toArray(null);
401              shouldThrow();
402          } catch (NullPointerException success) {}
403      }
404  
405      /**
406 <     * toArray with incompatible array type throws ArrayStoreException
406 >     * toArray(incompatible array type) throws ArrayStoreException
407       */
408      public void testToArray1_BadArg() {
409 +        ConcurrentLinkedQueue q = populatedQueue(SIZE);
410          try {
411 <            ConcurrentLinkedQueue q = populatedQueue(SIZE);
411 <            Object o[] = q.toArray(new String[10] );
411 >            q.toArray(new String[10]);
412              shouldThrow();
413          } catch (ArrayStoreException success) {}
414      }
415  
416      /**
417 <     *  iterator iterates through all elements
417 >     * iterator iterates through all elements
418       */
419      public void testIterator() {
420          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 438 | Line 438 | public class ConcurrentLinkedQueueTest e
438  
439          int k = 0;
440          for (Iterator it = q.iterator(); it.hasNext();) {
441 <            int i = ((Integer)(it.next())).intValue();
442 <            assertEquals(++k, i);
441 >            assertEquals(++k, it.next());
442          }
443  
444          assertEquals(3, k);
# Line 448 | Line 447 | public class ConcurrentLinkedQueueTest e
447      /**
448       * Modifications do not cause iterators to fail
449       */
450 <    public void testWeaklyConsistentIteration () {
450 >    public void testWeaklyConsistentIteration() {
451          final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
452          q.add(one);
453          q.add(two);
# Line 465 | Line 464 | public class ConcurrentLinkedQueueTest e
464      /**
465       * iterator.remove removes current element
466       */
467 <    public void testIteratorRemove () {
467 >    public void testIteratorRemove() {
468          final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
469          q.add(one);
470          q.add(two);
# Line 474 | Line 473 | public class ConcurrentLinkedQueueTest e
473          it.next();
474          it.remove();
475          it = q.iterator();
476 <        assertEquals(it.next(), two);
477 <        assertEquals(it.next(), three);
476 >        assertSame(it.next(), two);
477 >        assertSame(it.next(), three);
478          assertFalse(it.hasNext());
479      }
480  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines