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

Comparing jsr166/src/test/tck/BlockingQueueTest.java (file contents):
Revision 1.8 by jsr166, Mon May 30 22:43:20 2011 UTC vs.
Revision 1.11 by jsr166, Tue Jun 14 04:30:06 2011 UTC

# Line 8 | Line 8
8   */
9  
10   import junit.framework.*;
11 + import java.util.ArrayList;
12   import java.util.Arrays;
13   import java.util.Collection;
14   import java.util.Queue;
# Line 39 | Line 40 | public abstract class BlockingQueueTest
40      //----------------------------------------------------------------
41      // Configuration methods
42      //----------------------------------------------------------------
43 <    
43 >
44      /** Returns an empty instance of the implementation class. */
45      protected abstract BlockingQueue emptyCollection();
46  
# Line 54 | Line 55 | public abstract class BlockingQueueTest
55      //----------------------------------------------------------------
56      // Tests
57      //----------------------------------------------------------------
58 <    
58 >
59      /**
60       * offer(null) throws NullPointerException
61       */
# Line 180 | Line 181 | public abstract class BlockingQueueTest
181      }
182  
183      /**
184 +     * drainTo(c, n) returns 0 and does nothing when n <= 0
185 +     */
186 +    public void testDrainToNonPositiveMaxElements() {
187 +        final BlockingQueue q = emptyCollection();
188 +        final int[] ns = { 0, -1, -42, Integer.MIN_VALUE };
189 +        for (int n : ns)
190 +            assertEquals(0, q.drainTo(new ArrayList(), n));
191 +        if (q.remainingCapacity() > 0) {
192 +            // Not SynchronousQueue, that is
193 +            Object one = makeElement(1);
194 +            q.add(one);
195 +            ArrayList c = new ArrayList();
196 +            for (int n : ns)
197 +                assertEquals(0, q.drainTo(new ArrayList(), n));
198 +            assertEquals(1, q.size());
199 +            assertSame(one, q.poll());
200 +            assertTrue(c.isEmpty());
201 +        }
202 +    }
203 +
204 +    /**
205       * timed poll before a delayed offer times out; after offer succeeds;
206       * on interruption throws
207       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines