25 |
|
private LinkedBlockingDeque populatedDeque(int n) { |
26 |
|
LinkedBlockingDeque q = new LinkedBlockingDeque(n); |
27 |
|
assertTrue(q.isEmpty()); |
28 |
< |
for(int i = 0; i < n; i++) |
28 |
> |
for (int i = 0; i < n; i++) |
29 |
|
assertTrue(q.offer(new Integer(i))); |
30 |
|
assertFalse(q.isEmpty()); |
31 |
|
assertEquals(0, q.remainingCapacity()); |
1509 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1510 |
|
Object[] o = q.toArray(); |
1511 |
|
try { |
1512 |
< |
for(int i = 0; i < o.length; i++) |
1512 |
> |
for (int i = 0; i < o.length; i++) |
1513 |
|
assertEquals(o[i], q.take()); |
1514 |
|
} catch (InterruptedException e){ |
1515 |
|
unexpectedException(); |
1524 |
|
Integer[] ints = new Integer[SIZE]; |
1525 |
|
ints = (Integer[])q.toArray(ints); |
1526 |
|
try { |
1527 |
< |
for(int i = 0; i < ints.length; i++) |
1527 |
> |
for (int i = 0; i < ints.length; i++) |
1528 |
|
assertEquals(ints[i], q.take()); |
1529 |
|
} catch (InterruptedException e){ |
1530 |
|
unexpectedException(); |
1539 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1540 |
|
Object o[] = q.toArray(null); |
1541 |
|
shouldThrow(); |
1542 |
< |
} catch(NullPointerException success){} |
1542 |
> |
} catch (NullPointerException success){} |
1543 |
|
} |
1544 |
|
|
1545 |
|
/** |
1550 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1551 |
|
Object o[] = q.toArray(new String[10] ); |
1552 |
|
shouldThrow(); |
1553 |
< |
} catch(ArrayStoreException success){} |
1553 |
> |
} catch (ArrayStoreException success){} |
1554 |
|
} |
1555 |
|
|
1556 |
|
|
1561 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1562 |
|
Iterator it = q.iterator(); |
1563 |
|
try { |
1564 |
< |
while(it.hasNext()){ |
1564 |
> |
while (it.hasNext()){ |
1565 |
|
assertEquals(it.next(), q.take()); |
1566 |
|
} |
1567 |
|
} catch (InterruptedException e){ |
1634 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1635 |
|
int i = 0; |
1636 |
|
Iterator it = q.descendingIterator(); |
1637 |
< |
while(it.hasNext()) { |
1637 |
> |
while (it.hasNext()) { |
1638 |
|
assertTrue(q.contains(it.next())); |
1639 |
|
++i; |
1640 |
|
} |
1642 |
|
assertFalse(it.hasNext()); |
1643 |
|
try { |
1644 |
|
it.next(); |
1645 |
< |
} catch(NoSuchElementException success) { |
1645 |
> |
} catch (NoSuchElementException success) { |
1646 |
|
} |
1647 |
|
} |
1648 |
|
|
1791 |
|
assertEquals(q.size(), r.size()); |
1792 |
|
while (!q.isEmpty()) |
1793 |
|
assertEquals(q.remove(), r.remove()); |
1794 |
< |
} catch(Exception e){ |
1794 |
> |
} catch (Exception e){ |
1795 |
|
unexpectedException(); |
1796 |
|
} |
1797 |
|
} |
1804 |
|
try { |
1805 |
|
q.drainTo(null); |
1806 |
|
shouldThrow(); |
1807 |
< |
} catch(NullPointerException success) { |
1807 |
> |
} catch (NullPointerException success) { |
1808 |
|
} |
1809 |
|
} |
1810 |
|
|
1816 |
|
try { |
1817 |
|
q.drainTo(q); |
1818 |
|
shouldThrow(); |
1819 |
< |
} catch(IllegalArgumentException success) { |
1819 |
> |
} catch (IllegalArgumentException success) { |
1820 |
|
} |
1821 |
|
} |
1822 |
|
|
1867 |
|
assertEquals(l.get(i), new Integer(i)); |
1868 |
|
t.join(); |
1869 |
|
assertTrue(q.size() + l.size() >= SIZE); |
1870 |
< |
} catch(Exception e){ |
1870 |
> |
} catch (Exception e){ |
1871 |
|
unexpectedException(); |
1872 |
|
} |
1873 |
|
} |
1880 |
|
try { |
1881 |
|
q.drainTo(null, 0); |
1882 |
|
shouldThrow(); |
1883 |
< |
} catch(NullPointerException success) { |
1883 |
> |
} catch (NullPointerException success) { |
1884 |
|
} |
1885 |
|
} |
1886 |
|
|
1892 |
|
try { |
1893 |
|
q.drainTo(q, 0); |
1894 |
|
shouldThrow(); |
1895 |
< |
} catch(IllegalArgumentException success) { |
1895 |
> |
} catch (IllegalArgumentException success) { |
1896 |
|
} |
1897 |
|
} |
1898 |
|
|
1902 |
|
public void testDrainToN() { |
1903 |
|
LinkedBlockingDeque q = new LinkedBlockingDeque(); |
1904 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
1905 |
< |
for(int j = 0; j < SIZE; j++) |
1905 |
> |
for (int j = 0; j < SIZE; j++) |
1906 |
|
assertTrue(q.offer(new Integer(j))); |
1907 |
|
ArrayList l = new ArrayList(); |
1908 |
|
q.drainTo(l, i); |