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

Comparing jsr166/src/test/tck/PriorityBlockingQueueTest.java (file contents):
Revision 1.80 by jsr166, Sun May 6 22:29:24 2018 UTC vs.
Revision 1.83 by jsr166, Thu Sep 5 20:54:24 2019 UTC

# Line 319 | Line 319 | public class PriorityBlockingQueueTest e
319      }
320  
321      /**
322 <     * timed offer does not time out
322 >     * Queue is unbounded, so timed offer never times out
323       */
324      public void testTimedOffer() {
325          final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
# Line 370 | Line 370 | public class PriorityBlockingQueueTest e
370              }});
371  
372          await(pleaseInterrupt);
373 <        assertThreadBlocks(t, Thread.State.WAITING);
373 >        if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING);
374          t.interrupt();
375          awaitTermination(t);
376      }
# Line 428 | Line 428 | public class PriorityBlockingQueueTest e
428  
429                  Thread.currentThread().interrupt();
430                  try {
431 <                    q.poll(LONG_DELAY_MS, MILLISECONDS);
431 >                    q.poll(randomTimeout(), randomTimeUnit());
432                      shouldThrow();
433                  } catch (InterruptedException success) {}
434                  assertFalse(Thread.interrupted());
# Line 444 | Line 444 | public class PriorityBlockingQueueTest e
444              }});
445  
446          await(pleaseInterrupt);
447 <        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
447 >        if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING);
448          t.interrupt();
449          awaitTermination(t);
450      }
# Line 573 | Line 573 | public class PriorityBlockingQueueTest e
573       */
574      public void testToArray() throws InterruptedException {
575          PriorityBlockingQueue q = populatedQueue(SIZE);
576 <        Object[] o = q.toArray();
577 <        Arrays.sort(o);
578 <        for (int i = 0; i < o.length; i++)
579 <            assertSame(o[i], q.take());
576 >        Object[] a = q.toArray();
577 >        assertSame(Object[].class, a.getClass());
578 >        Arrays.sort(a);
579 >        for (Object o : a)
580 >            assertSame(o, q.take());
581 >        assertTrue(q.isEmpty());
582      }
583  
584      /**
# Line 588 | Line 590 | public class PriorityBlockingQueueTest e
590          Integer[] array = q.toArray(ints);
591          assertSame(ints, array);
592          Arrays.sort(ints);
593 <        for (int i = 0; i < ints.length; i++)
594 <            assertSame(ints[i], q.take());
593 >        for (Integer o : ints)
594 >            assertSame(o, q.take());
595 >        assertTrue(q.isEmpty());
596      }
597  
598      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines