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.46 by jsr166, Fri May 27 20:07:24 2011 UTC vs.
Revision 1.47 by jsr166, Mon May 30 22:43:20 2011 UTC

# Line 13 | Line 13 | import java.io.ObjectInputStream;
13   import java.io.ObjectOutputStream;
14   import java.util.ArrayList;
15   import java.util.Arrays;
16 + import java.util.Collection;
17   import java.util.Iterator;
18   import java.util.List;
19   import java.util.NoSuchElementException;
20 < import java.util.concurrent.*;
20 > import java.util.concurrent.BlockingQueue;
21 > import java.util.concurrent.CountDownLatch;
22 > import java.util.concurrent.Executors;
23 > import java.util.concurrent.ExecutorService;
24 > import java.util.concurrent.LinkedTransferQueue;
25   import static java.util.concurrent.TimeUnit.MILLISECONDS;
26   import static java.util.concurrent.TimeUnit.NANOSECONDS;
27   import junit.framework.Test;
# Line 65 | Line 70 | public class LinkedTransferQueueTest ext
70       * NullPointerException
71       */
72      public void testConstructor3() {
73 +        Collection<Integer> elements = Arrays.asList(new Integer[SIZE]);
74          try {
75 <            Integer[] ints = new Integer[SIZE];
70 <            new LinkedTransferQueue(Arrays.asList(ints));
75 >            new LinkedTransferQueue(elements);
76              shouldThrow();
77          } catch (NullPointerException success) {}
78      }
# Line 77 | Line 82 | public class LinkedTransferQueueTest ext
82       * throws NullPointerException
83       */
84      public void testConstructor4() {
85 +        Integer[] ints = new Integer[SIZE];
86 +        for (int i = 0; i < SIZE-1; ++i)
87 +            ints[i] = i;
88 +        Collection<Integer> elements = Arrays.asList(ints);
89          try {
90 <            Integer[] ints = new Integer[SIZE];
82 <            for (int i = 0; i < SIZE - 1; ++i) {
83 <                ints[i] = i;
84 <            }
85 <            new LinkedTransferQueue(Arrays.asList(ints));
90 >            new LinkedTransferQueue(elements);
91              shouldThrow();
92          } catch (NullPointerException success) {}
93      }
# Line 129 | Line 134 | public class LinkedTransferQueueTest ext
134      }
135  
136      /**
132     * offer(null) throws NullPointerException
133     */
134    public void testOfferNull() {
135        try {
136            LinkedTransferQueue q = new LinkedTransferQueue();
137            q.offer(null);
138            shouldThrow();
139        } catch (NullPointerException success) {}
140    }
141
142    /**
143     * add(null) throws NullPointerException
144     */
145    public void testAddNull() {
146        try {
147            LinkedTransferQueue q = new LinkedTransferQueue();
148            q.add(null);
149            shouldThrow();
150        } catch (NullPointerException success) {}
151    }
152
153    /**
154     * addAll(null) throws NullPointerException
155     */
156    public void testAddAll1() {
157        try {
158            LinkedTransferQueue q = new LinkedTransferQueue();
159            q.addAll(null);
160            shouldThrow();
161        } catch (NullPointerException success) {}
162    }
163
164    /**
137       * addAll(this) throws IllegalArgumentException
138       */
139      public void testAddAllSelf() {
# Line 173 | Line 145 | public class LinkedTransferQueueTest ext
145      }
146  
147      /**
176     * addAll of a collection with null elements throws NullPointerException
177     */
178    public void testAddAll2() {
179        try {
180            LinkedTransferQueue q = new LinkedTransferQueue();
181            Integer[] ints = new Integer[SIZE];
182            q.addAll(Arrays.asList(ints));
183            shouldThrow();
184        } catch (NullPointerException success) {}
185    }
186
187    /**
148       * addAll of a collection with any null elements throws
149       * NullPointerException after possibly adding some elements
150       */
# Line 218 | Line 178 | public class LinkedTransferQueueTest ext
178      }
179  
180      /**
221     * put(null) throws NullPointerException
222     */
223    public void testPutNull() throws InterruptedException {
224        try {
225            LinkedTransferQueue q = new LinkedTransferQueue();
226            q.put(null);
227            shouldThrow();
228        } catch (NullPointerException success) {}
229    }
230
231    /**
181       * all elements successfully put are contained
182       */
183      public void testPut() {
# Line 561 | Line 510 | public class LinkedTransferQueueTest ext
510      }
511  
512      /**
564     * toArray(null) throws NullPointerException
565     */
566    public void testToArray_NullArg() {
567        LinkedTransferQueue q = populatedQueue(SIZE);
568        try {
569            q.toArray(null);
570            shouldThrow();
571        } catch (NullPointerException success) {}
572    }
573
574    /**
513       * toArray(incompatible array type) throws ArrayStoreException
514       */
515      public void testToArray1_BadArg() {
# Line 734 | Line 672 | public class LinkedTransferQueueTest ext
672      }
673  
674      /**
737     * drainTo(null) throws NullPointerException
738     */
739    public void testDrainToNull() {
740        LinkedTransferQueue q = populatedQueue(SIZE);
741        try {
742            q.drainTo(null);
743            shouldThrow();
744        } catch (NullPointerException success) {}
745    }
746
747    /**
748     * drainTo(this) throws IllegalArgumentException
749     */
750    public void testDrainToSelf() {
751        LinkedTransferQueue q = populatedQueue(SIZE);
752        try {
753            q.drainTo(q);
754            shouldThrow();
755        } catch (IllegalArgumentException success) {}
756    }
757
758    /**
675       * drainTo(c) empties queue into another collection c
676       */
677      public void testDrainTo() {
# Line 801 | Line 717 | public class LinkedTransferQueueTest ext
717      }
718  
719      /**
804     * drainTo(null, n) throws NullPointerException
805     */
806    public void testDrainToNullN() {
807        LinkedTransferQueue q = populatedQueue(SIZE);
808        try {
809            q.drainTo(null, SIZE);
810            shouldThrow();
811        } catch (NullPointerException success) {}
812    }
813
814    /**
815     * drainTo(this, n) throws IllegalArgumentException
816     */
817    public void testDrainToSelfN() {
818        LinkedTransferQueue q = populatedQueue(SIZE);
819        try {
820            q.drainTo(q, SIZE);
821            shouldThrow();
822        } catch (IllegalArgumentException success) {}
823    }
824
825    /**
720       * drainTo(c, n) empties first min(n, size) elements of queue into c
721       */
722      public void testDrainToN() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines