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.88 by jsr166, Wed Jan 27 02:55:18 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 485 | Line 484 | public class LinkedTransferQueueTest ext
484      /**
485       * toArray(incompatible array type) throws ArrayStoreException
486       */
487 <    public void testToArray1_BadArg() {
487 >    @SuppressWarnings("CollectionToArraySafeParameter")
488 >    public void testToArray_incompatibleArrayType() {
489          LinkedTransferQueue<Item> q = populatedQueue(SIZE);
490          try {
491              q.toArray(new String[10]);
# Line 523 | Line 523 | public class LinkedTransferQueueTest ext
523       * iterator.remove() removes current element
524       */
525      public void testIteratorRemove() {
526 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
526 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
527          q.add(two);
528          q.add(one);
529          q.add(three);
# Line 559 | Line 559 | public class LinkedTransferQueueTest ext
559       * Modifications do not cause iterators to fail
560       */
561      public void testWeaklyConsistentIteration() {
562 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
562 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
563          q.add(one);
564          q.add(two);
565          q.add(three);
# Line 585 | Line 585 | public class LinkedTransferQueueTest ext
585       * offer transfers elements across Executor tasks
586       */
587      public void testOfferInExecutor() {
588 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
588 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
589          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
590          final ExecutorService executor = Executors.newFixedThreadPool(2);
591          try (PoolCleaner cleaner = cleaner(executor)) {
# Line 611 | Line 611 | public class LinkedTransferQueueTest ext
611       * timed poll retrieves elements across Executor threads
612       */
613      public void testPollInExecutor() {
614 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
614 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
615          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
616          final ExecutorService executor = Executors.newFixedThreadPool(2);
617          try (PoolCleaner cleaner = cleaner(executor)) {
# Line 700 | Line 700 | public class LinkedTransferQueueTest ext
700       * drainTo(c, n) empties first min(n, size) elements of queue into c
701       */
702      public void testDrainToN() {
703 <        LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
703 >        LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
704          for (int i = 0; i < SIZE + 2; ++i) {
705              for (int j = 0; j < SIZE; j++) {
706                  mustOffer(q, j);
# Line 721 | Line 721 | public class LinkedTransferQueueTest ext
721       * offer(e) decrements the waiting consumer count
722       */
723      public void testWaitingConsumer() throws InterruptedException {
724 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
724 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
725          mustEqual(0, q.getWaitingConsumerCount());
726          assertFalse(q.hasWaitingConsumer());
727          final CountDownLatch threadStarted = new CountDownLatch(1);
# Line 737 | Line 737 | public class LinkedTransferQueueTest ext
737              }});
738  
739          threadStarted.await();
740 <        Callable<Boolean> oneConsumer
741 <            = new Callable<Boolean>() { public Boolean call() {
740 >        Callable<Boolean> oneConsumer = new Callable<>() {
741 >            public Boolean call() {
742                  return q.hasWaitingConsumer()
743                  && q.getWaitingConsumerCount() == 1; }};
744          waitForThreadToEnterWaitState(t, oneConsumer);
# Line 755 | Line 755 | public class LinkedTransferQueueTest ext
755       */
756      public void testTransfer1() throws InterruptedException {
757          try {
758 <            LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
758 >            LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
759              q.transfer(null);
760              shouldThrow();
761          } catch (NullPointerException success) {}
# Line 777 | Line 777 | public class LinkedTransferQueueTest ext
777              }});
778  
779          threadStarted.await();
780 <        Callable<Boolean> oneElement
781 <            = new Callable<Boolean>() { public Boolean call() {
780 >        Callable<Boolean> oneElement = new Callable<>() {
781 >            public Boolean call() {
782                  return !q.isEmpty() && q.size() == 1; }};
783          waitForThreadToEnterWaitState(t, oneElement);
784  
# Line 824 | Line 824 | public class LinkedTransferQueueTest ext
824       * thread returns the element
825       */
826      public void testTransfer4() throws InterruptedException {
827 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
827 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
828  
829          Thread t = newStartedThread(new CheckedRunnable() {
830              public void realRun() throws InterruptedException {
# Line 868 | Line 868 | public class LinkedTransferQueueTest ext
868       * tryTransfer(null) throws NullPointerException
869       */
870      public void testTryTransfer1() {
871 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
871 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
872          try {
873              q.tryTransfer(null);
874              shouldThrow();
# Line 880 | Line 880 | public class LinkedTransferQueueTest ext
880       * consumers waiting to poll or take.
881       */
882      public void testTryTransfer2() throws InterruptedException {
883 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
883 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
884          assertFalse(q.tryTransfer(new Object()));
885          assertFalse(q.hasWaitingConsumer());
886          checkEmpty(q);
# Line 892 | Line 892 | public class LinkedTransferQueueTest ext
892       */
893      public void testTryTransfer3() throws InterruptedException {
894          final Object hotPotato = new Object();
895 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
895 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
896  
897          Thread t = newStartedThread(new CheckedRunnable() {
898              public void realRun() {
# Line 916 | Line 916 | public class LinkedTransferQueueTest ext
916       */
917      public void testTryTransfer4() throws InterruptedException {
918          final Object hotPotato = new Object();
919 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
919 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
920  
921          Thread t = newStartedThread(new CheckedRunnable() {
922              public void realRun() {
# Line 936 | Line 936 | public class LinkedTransferQueueTest ext
936       * tryTransfer blocks interruptibly if no takers
937       */
938      public void testTryTransfer5() throws InterruptedException {
939 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
939 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
940          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
941          assertTrue(q.isEmpty());
942  
# Line 968 | Line 968 | public class LinkedTransferQueueTest ext
968       * tryTransfer gives up after the timeout and returns false
969       */
970      public void testTryTransfer6() throws InterruptedException {
971 <        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<Object>();
971 >        final LinkedTransferQueue<Object> q = new LinkedTransferQueue<>();
972  
973          Thread t = newStartedThread(new CheckedRunnable() {
974              public void realRun() throws InterruptedException {
# Line 988 | Line 988 | public class LinkedTransferQueueTest ext
988       * before transfering to a poll or take
989       */
990      public void testTryTransfer7() throws InterruptedException {
991 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
991 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
992          assertTrue(q.offer(four));
993  
994          Thread t = newStartedThread(new CheckedRunnable() {
# Line 1013 | Line 1013 | public class LinkedTransferQueueTest ext
1013       * returning false not enqueueing and the successive poll is null
1014       */
1015      public void testTryTransfer8() throws InterruptedException {
1016 <        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<Item>();
1016 >        final LinkedTransferQueue<Item> q = new LinkedTransferQueue<>();
1017          assertTrue(q.offer(four));
1018          mustEqual(1, q.size());
1019          long startTime = System.nanoTime();
# Line 1042 | Line 1042 | public class LinkedTransferQueueTest ext
1042       */
1043      public void testNeverContainsNull() {
1044          Collection<?>[] qs = {
1045 <            new LinkedTransferQueue<Object>(),
1045 >            new LinkedTransferQueue<>(),
1046              populatedQueue(2),
1047          };
1048  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines