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

Comparing jsr166/src/test/tck/LinkedBlockingDequeTest.java (file contents):
Revision 1.46 by jsr166, Tue Feb 21 01:54:04 2012 UTC vs.
Revision 1.52 by jsr166, Wed Dec 31 19:21:20 2014 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
8 < import java.util.Arrays;
7 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
8 >
9   import java.util.ArrayList;
10 + import java.util.Arrays;
11   import java.util.Collection;
12 + import java.util.Deque;
13   import java.util.Iterator;
14   import java.util.NoSuchElementException;
15   import java.util.Queue;
# Line 17 | Line 19 | import java.util.concurrent.CountDownLat
19   import java.util.concurrent.Executors;
20   import java.util.concurrent.ExecutorService;
21   import java.util.concurrent.LinkedBlockingDeque;
22 < import static java.util.concurrent.TimeUnit.MILLISECONDS;
22 >
23 > import junit.framework.Test;
24  
25   public class LinkedBlockingDequeTest extends JSR166TestCase {
26  
# Line 44 | Line 47 | public class LinkedBlockingDequeTest ext
47      }
48  
49      /**
50 <     * Creates a deque of given size containing consecutive
50 >     * Returns a new deque of given size containing consecutive
51       * Integers 0 ... n.
52       */
53      private LinkedBlockingDeque<Integer> populatedDeque(int n) {
# Line 1064 | Line 1067 | public class LinkedBlockingDequeTest ext
1067  
1068                  pleaseInterrupt.countDown();
1069                  try {
1070 <                    q.pollFirst(SMALL_DELAY_MS, MILLISECONDS);
1070 >                    q.pollFirst(LONG_DELAY_MS, MILLISECONDS);
1071                      shouldThrow();
1072                  } catch (InterruptedException success) {}
1073                  assertFalse(Thread.interrupted());
# Line 1700 | Line 1703 | public class LinkedBlockingDequeTest ext
1703          Queue x = populatedDeque(SIZE);
1704          Queue y = serialClone(x);
1705  
1706 <        assertTrue(x != y);
1706 >        assertNotSame(y, x);
1707          assertEquals(x.size(), y.size());
1708          assertEquals(x.toString(), y.toString());
1709          assertTrue(Arrays.equals(x.toArray(), y.toArray()));
# Line 1770 | Line 1773 | public class LinkedBlockingDequeTest ext
1773              assertEquals(SIZE-k, q.size());
1774              for (int j = 0; j < k; ++j)
1775                  assertEquals(l.get(j), new Integer(j));
1776 <            while (q.poll() != null) ;
1776 >            do {} while (q.poll() != null);
1777 >        }
1778 >    }
1779 >
1780 >    /**
1781 >     * remove(null), contains(null) always return false
1782 >     */
1783 >    public void testNeverContainsNull() {
1784 >        Deque<?>[] qs = {
1785 >            new LinkedBlockingDeque<Object>(),
1786 >            populatedDeque(2),
1787 >        };
1788 >
1789 >        for (Deque<?> q : qs) {
1790 >            assertFalse(q.contains(null));
1791 >            assertFalse(q.remove(null));
1792 >            assertFalse(q.removeFirstOccurrence(null));
1793 >            assertFalse(q.removeLastOccurrence(null));
1794          }
1795      }
1796  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines