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

Comparing jsr166/src/test/tck/ConcurrentLinkedQueueTest.java (file contents):
Revision 1.4 by dl, Sat Sep 20 18:20:07 2003 UTC vs.
Revision 1.5 by dl, Sun Oct 5 23:00:40 2003 UTC

# Line 35 | Line 35 | public class ConcurrentLinkedQueueTest e
35      }
36  
37      /**
38 <     *
38 >     * new queue is empty
39       */
40      public void testConstructor1() {
41          assertEquals(0, new ConcurrentLinkedQueue().size());
42      }
43  
44      /**
45 <     *
45 >     *  Initializing from null Collection throws NPE
46       */
47      public void testConstructor3() {
48          try {
# Line 53 | Line 53 | public class ConcurrentLinkedQueueTest e
53      }
54  
55      /**
56 <     *
56 >     * Initializing from Collection of null elements throws NPE
57       */
58      public void testConstructor4() {
59          try {
# Line 65 | Line 65 | public class ConcurrentLinkedQueueTest e
65      }
66  
67      /**
68 <     *
68 >     * Initializing from Collection with some null elements throws NPE
69       */
70      public void testConstructor5() {
71          try {
# Line 79 | Line 79 | public class ConcurrentLinkedQueueTest e
79      }
80  
81      /**
82 <     *
82 >     * Queue contains all elements of collection used to initialize
83       */
84      public void testConstructor6() {
85          try {
# Line 94 | Line 94 | public class ConcurrentLinkedQueueTest e
94      }
95  
96      /**
97 <     *
97 >     * isEmpty is true before add, false after
98       */
99      public void testEmpty() {
100          ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
# Line 108 | Line 108 | public class ConcurrentLinkedQueueTest e
108      }
109  
110      /**
111 <     *
111 >     * size changes when elements added and removed
112       */
113      public void testSize() {
114          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 123 | Line 123 | public class ConcurrentLinkedQueueTest e
123      }
124  
125      /**
126 <     *
126 >     * offer(null) throws NPE
127       */
128      public void testOfferNull() {
129          try {
# Line 134 | Line 134 | public class ConcurrentLinkedQueueTest e
134      }
135  
136      /**
137 <     *
137 >     * add(null) throws NPE
138 >     */
139 >    public void testAddNull() {
140 >        try {
141 >            ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
142 >            q.add(null);
143 >            shouldThrow();
144 >        } catch (NullPointerException success) { }  
145 >    }
146 >
147 >
148 >    /**
149 >     * Offer returns true
150       */
151      public void testOffer() {
152          ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
# Line 143 | Line 155 | public class ConcurrentLinkedQueueTest e
155      }
156  
157      /**
158 <     *
158 >     * add returns true
159       */
160      public void testAdd() {
161          ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
# Line 154 | Line 166 | public class ConcurrentLinkedQueueTest e
166      }
167  
168      /**
169 <     *
169 >     * addAll(null) throws NPE
170       */
171      public void testAddAll1() {
172          try {
# Line 164 | Line 176 | public class ConcurrentLinkedQueueTest e
176          }
177          catch (NullPointerException success) {}
178      }
179 +
180 +    /**
181 +     * addAll(this) throws IAE
182 +     */
183 +    public void testAddAllSelf() {
184 +        try {
185 +            ConcurrentLinkedQueue q = populatedQueue(SIZE);
186 +            q.addAll(q);
187 +            shouldThrow();
188 +        }
189 +        catch (IllegalArgumentException success) {}
190 +    }
191 +
192      /**
193 <     *
193 >     * addAll of a collection with null elements throws NPE
194       */
195      public void testAddAll2() {
196          try {
# Line 177 | Line 202 | public class ConcurrentLinkedQueueTest e
202          catch (NullPointerException success) {}
203      }
204      /**
205 <     *
205 >     *  addAll of a collection with any null elements throws NPE after
206 >     * possibly adding some elements
207       */
208      public void testAddAll3() {
209          try {
# Line 192 | Line 218 | public class ConcurrentLinkedQueueTest e
218      }
219  
220      /**
221 <     *
221 >     * Queue contains all elements, in traversal order, of successful addAll
222       */
223      public void testAddAll5() {
224          try {
# Line 210 | Line 236 | public class ConcurrentLinkedQueueTest e
236      }
237  
238      /**
239 <     *
239 >     * poll succeeds unless empty
240       */
241      public void testPoll() {
242          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 221 | Line 247 | public class ConcurrentLinkedQueueTest e
247      }
248  
249      /**
250 <     *
250 >     * peek returns next element, or null if empty
251       */
252      public void testPeek() {
253          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 235 | Line 261 | public class ConcurrentLinkedQueueTest e
261      }
262  
263      /**
264 <     *
264 >     * element returns next element, or throws NSEE if empty
265       */
266      public void testElement() {
267          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 251 | Line 277 | public class ConcurrentLinkedQueueTest e
277      }
278  
279      /**
280 <     *
280 >     *  remove removes next element, or throws NSEE if empty
281       */
282      public void testRemove() {
283          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 266 | Line 292 | public class ConcurrentLinkedQueueTest e
292      }
293  
294      /**
295 <     *
295 >     * remove(x) removes x and returns true if present
296       */
297      public void testRemoveElement() {
298          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 281 | Line 307 | public class ConcurrentLinkedQueueTest e
307      }
308          
309      /**
310 <     *
310 >     * contains(x) reports true when elements added but not yet removed
311       */
312      public void testContains() {
313          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 293 | Line 319 | public class ConcurrentLinkedQueueTest e
319      }
320  
321      /**
322 <     *
322 >     * clear removes all elements
323       */
324      public void testClear() {
325          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 307 | Line 333 | public class ConcurrentLinkedQueueTest e
333      }
334  
335      /**
336 <     *
336 >     * containsAll(c) is true when c contains a subset of elements
337       */
338      public void testContainsAll() {
339          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 321 | Line 347 | public class ConcurrentLinkedQueueTest e
347      }
348  
349      /**
350 <     *
350 >     * retainAll(c) retains only those elements of c and reports true if change
351       */
352      public void testRetainAll() {
353          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 340 | Line 366 | public class ConcurrentLinkedQueueTest e
366      }
367  
368      /**
369 <     *
369 >     * removeAll(c) removes only those elements of c and reports true if changed
370       */
371      public void testRemoveAll() {
372          for (int i = 1; i < SIZE; ++i) {
# Line 356 | Line 382 | public class ConcurrentLinkedQueueTest e
382      }
383  
384      /**
385 <     *
385 >     * toArray contains all elements
386       */
387      public void testToArray() {
388          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 367 | Line 393 | public class ConcurrentLinkedQueueTest e
393      }
394  
395      /**
396 <     *
396 >     *  toArray(a) contains all elements
397       */
398      public void testToArray2() {
399          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 377 | Line 403 | public class ConcurrentLinkedQueueTest e
403          for(int i = 0; i < ints.length; i++)
404              assertEquals(ints[i], q.poll());
405      }
406 +
407 +    /**
408 +     * toArray(null) throws NPE
409 +     */
410 +    public void testToArray_BadArg() {
411 +        try {
412 +            ConcurrentLinkedQueue q = populatedQueue(SIZE);
413 +            Object o[] = q.toArray(null);
414 +            shouldThrow();
415 +        } catch(NullPointerException success){}
416 +    }
417 +
418 +    /**
419 +     * toArray with incompatable array type throws CCE
420 +     */
421 +    public void testToArray1_BadArg() {
422 +        try {
423 +            ConcurrentLinkedQueue q = populatedQueue(SIZE);
424 +            Object o[] = q.toArray(new String[10] );
425 +            shouldThrow();
426 +        } catch(ArrayStoreException  success){}
427 +    }
428      
429      /**
430 <     *
430 >     *  iterator iterates through all elements
431       */
432      public void testIterator() {
433          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 393 | Line 441 | public class ConcurrentLinkedQueueTest e
441      }
442  
443      /**
444 <     *
444 >     * iterator ordering is FIFO
445       */
446      public void testIteratorOrdering() {
447          final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
# Line 411 | Line 459 | public class ConcurrentLinkedQueueTest e
459      }
460  
461      /**
462 <     *
462 >     * Modifications do not cause iterators to fail
463       */
464      public void testWeaklyConsistentIteration () {
465          final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
# Line 433 | Line 481 | public class ConcurrentLinkedQueueTest e
481      }
482  
483      /**
484 <     *
484 >     * iterator.remove removes current element
485       */
486      public void testIteratorRemove () {
487          final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
# Line 451 | Line 499 | public class ConcurrentLinkedQueueTest e
499  
500  
501      /**
502 <     *
502 >     * toString contains toStrings of elements
503       */
504      public void testToString() {
505          ConcurrentLinkedQueue q = populatedQueue(SIZE);
# Line 462 | Line 510 | public class ConcurrentLinkedQueueTest e
510      }        
511  
512      /**
513 <     *
513 >     * A deserialized serialized queue has same elements in same order
514       */
515      public void testSerialization() {
516          ConcurrentLinkedQueue q = populatedQueue(SIZE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines