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

Comparing jsr166/src/test/tck/DelayQueueTest.java (file contents):
Revision 1.94 by dl, Tue Jan 26 13:33:05 2021 UTC vs.
Revision 1.95 by jsr166, Wed Jan 27 01:57:24 2021 UTC

# Line 176 | Line 176 | public class DelayQueueTest extends JSR1
176          PDelay[] items = new PDelay[SIZE];
177          for (int i = 0; i < SIZE; ++i)
178              items[i] = new PDelay(i);
179 <        DelayQueue<PDelay> q = new DelayQueue<PDelay>(Arrays.asList(items));
179 >        DelayQueue<PDelay> q = new DelayQueue<>(Arrays.asList(items));
180          for (int i = 0; i < SIZE; ++i)
181              mustEqual(items[i], q.poll());
182      }
# Line 185 | Line 185 | public class DelayQueueTest extends JSR1
185       * isEmpty is true before add, false after
186       */
187      public void testEmpty() {
188 <        DelayQueue<PDelay> q = new DelayQueue<PDelay>();
188 >        DelayQueue<PDelay> q = new DelayQueue<>();
189          assertTrue(q.isEmpty());
190          mustEqual(Integer.MAX_VALUE, q.remainingCapacity());
191          q.add(new PDelay(1));
# Line 217 | Line 217 | public class DelayQueueTest extends JSR1
217       * offer non-null succeeds
218       */
219      public void testOffer() {
220 <        DelayQueue<PDelay> q = new DelayQueue<PDelay>();
220 >        DelayQueue<PDelay> q = new DelayQueue<>();
221          assertTrue(q.offer(new PDelay(0)));
222          assertTrue(q.offer(new PDelay(1)));
223      }
# Line 226 | Line 226 | public class DelayQueueTest extends JSR1
226       * add succeeds
227       */
228      public void testAdd() {
229 <        DelayQueue<PDelay> q = new DelayQueue<PDelay>();
229 >        DelayQueue<PDelay> q = new DelayQueue<>();
230          for (int i = 0; i < SIZE; ++i) {
231              mustEqual(i, q.size());
232              assertTrue(q.add(new PDelay(i)));
# Line 249 | Line 249 | public class DelayQueueTest extends JSR1
249       * possibly adding some elements
250       */
251      public void testAddAll3() {
252 <        DelayQueue<PDelay> q = new DelayQueue<PDelay>();
252 >        DelayQueue<PDelay> q = new DelayQueue<>();
253          PDelay[] a = new PDelay[SIZE];
254          for (int i = 0; i < SIZE - 1; ++i)
255              a[i] = new PDelay(i);
# Line 267 | Line 267 | public class DelayQueueTest extends JSR1
267          PDelay[] items = new PDelay[SIZE];
268          for (int i = SIZE - 1; i >= 0; --i)
269              items[i] = new PDelay(i);
270 <        DelayQueue<PDelay> q = new DelayQueue<PDelay>();
270 >        DelayQueue<PDelay> q = new DelayQueue<>();
271          assertFalse(q.addAll(Arrays.asList(empty)));
272          assertTrue(q.addAll(Arrays.asList(items)));
273          for (int i = 0; i < SIZE; ++i)
# Line 278 | Line 278 | public class DelayQueueTest extends JSR1
278       * all elements successfully put are contained
279       */
280      public void testPut() {
281 <        DelayQueue<PDelay> q = new DelayQueue<PDelay>();
281 >        DelayQueue<PDelay> q = new DelayQueue<>();
282          for (int i = 0; i < SIZE; ++i) {
283              PDelay x = new PDelay(i);
284              q.put(x);
# Line 291 | Line 291 | public class DelayQueueTest extends JSR1
291       * put doesn't block waiting for take
292       */
293      public void testPutWithTake() throws InterruptedException {
294 <        final DelayQueue<PDelay> q = new DelayQueue<PDelay>();
294 >        final DelayQueue<PDelay> q = new DelayQueue<>();
295          Thread t = newStartedThread(new CheckedRunnable() {
296              public void realRun() {
297                  q.put(new PDelay(0));
# Line 308 | Line 308 | public class DelayQueueTest extends JSR1
308       * Queue is unbounded, so timed offer never times out
309       */
310      public void testTimedOffer() throws InterruptedException {
311 <        final DelayQueue<PDelay> q = new DelayQueue<PDelay>();
311 >        final DelayQueue<PDelay> q = new DelayQueue<>();
312          Thread t = newStartedThread(new CheckedRunnable() {
313              public void realRun() throws InterruptedException {
314                  q.put(new PDelay(0));
# Line 514 | Line 514 | public class DelayQueueTest extends JSR1
514       */
515      public void testContainsAll() {
516          DelayQueue<PDelay> q = populatedQueue(SIZE);
517 <        DelayQueue<PDelay> p = new DelayQueue<PDelay>();
517 >        DelayQueue<PDelay> p = new DelayQueue<>();
518          for (int i = 0; i < SIZE; ++i) {
519              assertTrue(q.containsAll(p));
520              assertFalse(p.containsAll(q));
# Line 621 | Line 621 | public class DelayQueueTest extends JSR1
621       * iterator.remove removes current element
622       */
623      public void testIteratorRemove() {
624 <        final DelayQueue<PDelay> q = new DelayQueue<PDelay>();
624 >        final DelayQueue<PDelay> q = new DelayQueue<>();
625          q.add(new PDelay(2));
626          q.add(new PDelay(1));
627          q.add(new PDelay(3));
# Line 648 | Line 648 | public class DelayQueueTest extends JSR1
648       * timed poll transfers elements across Executor tasks
649       */
650      public void testPollInExecutor() {
651 <        final DelayQueue<PDelay> q = new DelayQueue<PDelay>();
651 >        final DelayQueue<PDelay> q = new DelayQueue<>();
652          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
653          final ExecutorService executor = Executors.newFixedThreadPool(2);
654          try (PoolCleaner cleaner = cleaner(executor)) {
# Line 692 | Line 692 | public class DelayQueueTest extends JSR1
692       * peek of a non-empty queue returns non-null even if not expired
693       */
694      public void testPeekDelayed() {
695 <        DelayQueue<NanoDelay> q = new DelayQueue<NanoDelay>();
695 >        DelayQueue<NanoDelay> q = new DelayQueue<>();
696          q.add(new NanoDelay(Long.MAX_VALUE));
697          assertNotNull(q.peek());
698      }
# Line 701 | Line 701 | public class DelayQueueTest extends JSR1
701       * poll of a non-empty queue returns null if no expired elements.
702       */
703      public void testPollDelayed() {
704 <        DelayQueue<NanoDelay> q = new DelayQueue<NanoDelay>();
704 >        DelayQueue<NanoDelay> q = new DelayQueue<>();
705          q.add(new NanoDelay(Long.MAX_VALUE));
706          assertNull(q.poll());
707      }
# Line 710 | Line 710 | public class DelayQueueTest extends JSR1
710       * timed poll of a non-empty queue returns null if no expired elements.
711       */
712      public void testTimedPollDelayed() throws InterruptedException {
713 <        DelayQueue<NanoDelay> q = new DelayQueue<NanoDelay>();
713 >        DelayQueue<NanoDelay> q = new DelayQueue<>();
714          q.add(new NanoDelay(LONG_DELAY_MS * 1000000L));
715          long startTime = System.nanoTime();
716          assertNull(q.poll(timeoutMillis(), MILLISECONDS));
# Line 721 | Line 721 | public class DelayQueueTest extends JSR1
721       * drainTo(c) empties queue into another collection c
722       */
723      public void testDrainTo() {
724 <        DelayQueue<PDelay> q = new DelayQueue<PDelay>();
724 >        DelayQueue<PDelay> q = new DelayQueue<>();
725          PDelay[] elems = new PDelay[SIZE];
726          for (int i = 0; i < SIZE; ++i) {
727              elems[i] = new PDelay(i);
728              q.add(elems[i]);
729          }
730 <        ArrayList<PDelay> l = new ArrayList<PDelay>();
730 >        ArrayList<PDelay> l = new ArrayList<>();
731          q.drainTo(l);
732          mustEqual(0, q.size());
733          for (int i = 0; i < SIZE; ++i)
# Line 756 | Line 756 | public class DelayQueueTest extends JSR1
756              }});
757  
758          t.start();
759 <        ArrayList<PDelay> l = new ArrayList<PDelay>();
759 >        ArrayList<PDelay> l = new ArrayList<>();
760          q.drainTo(l);
761          assertTrue(l.size() >= SIZE);
762          t.join();
# Line 769 | Line 769 | public class DelayQueueTest extends JSR1
769      public void testDrainToN() {
770          for (int i = 0; i < SIZE + 2; ++i) {
771              DelayQueue<PDelay> q = populatedQueue(SIZE);
772 <            ArrayList<PDelay> l = new ArrayList<PDelay>();
772 >            ArrayList<PDelay> l = new ArrayList<>();
773              q.drainTo(l, i);
774              int k = (i < SIZE) ? i : SIZE;
775              mustEqual(SIZE - k, q.size());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines