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

Comparing jsr166/src/test/tck/LinkedTransferQueueTest.java (file contents):
Revision 1.86 by dl, Tue Jan 26 13:33:06 2021 UTC vs.
Revision 1.87 by jsr166, Wed Jan 27 01:57:24 2021 UTC

# Line 100 | Line 100 | public class LinkedTransferQueueTest ext
100      public void testConstructor5() {
101          Item[] items = defaultItems;
102          List<Item> intList = Arrays.asList(items);
103 <        LinkedTransferQueue<Item> q
104 <            = new LinkedTransferQueue<Item>(intList);
103 >        LinkedTransferQueue<Item> q = new LinkedTransferQueue<>(intList);
104          mustEqual(q.size(), intList.size());
105          mustEqual(q.toString(), intList.toString());
106          assertTrue(Arrays.equals(q.toArray(),
# Line 148 | Line 147 | public class LinkedTransferQueueTest ext
147       * NullPointerException after possibly adding some elements
148       */
149      public void testAddAll3() {
150 <        LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
150 >        LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
151          Item[] items = new Item[2]; items[0] = zero;
152          try {
153              q.addAll(Arrays.asList(items));
# Line 370 | Line 369 | public class LinkedTransferQueueTest ext
369       * An add following remove(x) succeeds
370       */
371      public void testRemoveElementAndAdd() throws InterruptedException {
372 <        LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
372 >        LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
373          mustAdd(q, one);
374          mustAdd(q, two);
375          mustRemove(q, one);
# Line 523 | Line 522 | public class LinkedTransferQueueTest ext
522       * iterator.remove() removes current element
523       */
524      public void testIteratorRemove() {
525 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
525 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
526          q.add(two);
527          q.add(one);
528          q.add(three);
# Line 559 | Line 558 | public class LinkedTransferQueueTest ext
558       * Modifications do not cause iterators to fail
559       */
560      public void testWeaklyConsistentIteration() {
561 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
561 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
562          q.add(one);
563          q.add(two);
564          q.add(three);
# Line 585 | Line 584 | public class LinkedTransferQueueTest ext
584       * offer transfers elements across Executor tasks
585       */
586      public void testOfferInExecutor() {
587 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
587 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
588          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
589          final ExecutorService executor = Executors.newFixedThreadPool(2);
590          try (PoolCleaner cleaner = cleaner(executor)) {
# Line 611 | Line 610 | public class LinkedTransferQueueTest ext
610       * timed poll retrieves elements across Executor threads
611       */
612      public void testPollInExecutor() {
613 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
613 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
614          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
615          final ExecutorService executor = Executors.newFixedThreadPool(2);
616          try (PoolCleaner cleaner = cleaner(executor)) {
# Line 700 | Line 699 | public class LinkedTransferQueueTest ext
699       * drainTo(c, n) empties first min(n, size) elements of queue into c
700       */
701      public void testDrainToN() {
702 <        LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
702 >        LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
703          for (int i = 0; i < SIZE + 2; ++i) {
704              for (int j = 0; j < SIZE; j++) {
705                  mustOffer(q, j);
# Line 721 | Line 720 | public class LinkedTransferQueueTest ext
720       * offer(e) decrements the waiting consumer count
721       */
722      public void testWaitingConsumer() throws InterruptedException {
723 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
723 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
724          mustEqual(0, q.getWaitingConsumerCount());
725          assertFalse(q.hasWaitingConsumer());
726          final CountDownLatch threadStarted = new CountDownLatch(1);
# Line 737 | Line 736 | public class LinkedTransferQueueTest ext
736              }});
737  
738          threadStarted.await();
739 <        Callable<Boolean> oneConsumer
740 <            = new Callable<Boolean>() { public Boolean call() {
739 >        Callable<Boolean> oneConsumer = new Callable<>() {
740 >            public Boolean call() {
741                  return q.hasWaitingConsumer()
742                  && q.getWaitingConsumerCount() == 1; }};
743          waitForThreadToEnterWaitState(t, oneConsumer);
# Line 755 | Line 754 | public class LinkedTransferQueueTest ext
754       */
755      public void testTransfer1() throws InterruptedException {
756          try {
757 <            LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
757 >            LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
758              q.transfer(null);
759              shouldThrow();
760          } catch (NullPointerException success) {}
# Line 777 | Line 776 | public class LinkedTransferQueueTest ext
776              }});
777  
778          threadStarted.await();
779 <        Callable<Boolean> oneElement
780 <            = new Callable<Boolean>() { public Boolean call() {
779 >        Callable<Boolean> oneElement = new Callable<>() {
780 >            public Boolean call() {
781                  return !q.isEmpty() && q.size() == 1; }};
782          waitForThreadToEnterWaitState(t, oneElement);
783  
# Line 824 | Line 823 | public class LinkedTransferQueueTest ext
823       * thread returns the element
824       */
825      public void testTransfer4() throws InterruptedException {
826 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
826 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
827  
828          Thread t = newStartedThread(new CheckedRunnable() {
829              public void realRun() throws InterruptedException {
# Line 868 | Line 867 | public class LinkedTransferQueueTest ext
867       * tryTransfer(null) throws NullPointerException
868       */
869      public void testTryTransfer1() {
870 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
870 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
871          try {
872              q.tryTransfer(null);
873              shouldThrow();
# Line 880 | Line 879 | public class LinkedTransferQueueTest ext
879       * consumers waiting to poll or take.
880       */
881      public void testTryTransfer2() throws InterruptedException {
882 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
882 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
883          assertFalse(q.tryTransfer(new Object()));
884          assertFalse(q.hasWaitingConsumer());
885          checkEmpty(q);
# Line 892 | Line 891 | public class LinkedTransferQueueTest ext
891       */
892      public void testTryTransfer3() throws InterruptedException {
893          final Object hotPotato = new Object();
894 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
894 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
895  
896          Thread t = newStartedThread(new CheckedRunnable() {
897              public void realRun() {
# Line 916 | Line 915 | public class LinkedTransferQueueTest ext
915       */
916      public void testTryTransfer4() throws InterruptedException {
917          final Object hotPotato = new Object();
918 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
918 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
919  
920          Thread t = newStartedThread(new CheckedRunnable() {
921              public void realRun() {
# Line 936 | Line 935 | public class LinkedTransferQueueTest ext
935       * tryTransfer blocks interruptibly if no takers
936       */
937      public void testTryTransfer5() throws InterruptedException {
938 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
938 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
939          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
940          assertTrue(q.isEmpty());
941  
# Line 968 | Line 967 | public class LinkedTransferQueueTest ext
967       * tryTransfer gives up after the timeout and returns false
968       */
969      public void testTryTransfer6() throws InterruptedException {
970 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
970 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
971  
972          Thread t = newStartedThread(new CheckedRunnable() {
973              public void realRun() throws InterruptedException {
# Line 988 | Line 987 | public class LinkedTransferQueueTest ext
987       * before transfering to a poll or take
988       */
989      public void testTryTransfer7() throws InterruptedException {
990 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
990 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
991          assertTrue(q.offer(four));
992  
993          Thread t = newStartedThread(new CheckedRunnable() {
# Line 1013 | Line 1012 | public class LinkedTransferQueueTest ext
1012       * returning false not enqueueing and the successive poll is null
1013       */
1014      public void testTryTransfer8() throws InterruptedException {
1015 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
1015 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
1016          assertTrue(q.offer(four));
1017          mustEqual(1, q.size());
1018          long startTime = System.nanoTime();
# Line 1042 | Line 1041 | public class LinkedTransferQueueTest ext
1041       */
1042      public void testNeverContainsNull() {
1043          Collection<?>[] qs = {
1044 <            new LinkedTransferQueue<Object>(),
1044 >            new LinkedTransferQueue<>(),
1045              populatedQueue(2),
1046          };
1047  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines