27 |
|
private ArrayBlockingQueue populatedQueue(int n) { |
28 |
|
ArrayBlockingQueue q = new ArrayBlockingQueue(n); |
29 |
|
assertTrue(q.isEmpty()); |
30 |
< |
for(int i = 0; i < n; i++) |
30 |
> |
for (int i = 0; i < n; i++) |
31 |
|
assertTrue(q.offer(new Integer(i))); |
32 |
|
assertFalse(q.isEmpty()); |
33 |
|
assertEquals(0, q.remainingCapacity()); |
711 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
712 |
|
Object[] o = q.toArray(); |
713 |
|
try { |
714 |
< |
for(int i = 0; i < o.length; i++) |
714 |
> |
for (int i = 0; i < o.length; i++) |
715 |
|
assertEquals(o[i], q.take()); |
716 |
|
} catch (InterruptedException e){ |
717 |
|
unexpectedException(); |
726 |
|
Integer[] ints = new Integer[SIZE]; |
727 |
|
ints = (Integer[])q.toArray(ints); |
728 |
|
try { |
729 |
< |
for(int i = 0; i < ints.length; i++) |
729 |
> |
for (int i = 0; i < ints.length; i++) |
730 |
|
assertEquals(ints[i], q.take()); |
731 |
|
} catch (InterruptedException e){ |
732 |
|
unexpectedException(); |
741 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
742 |
|
Object o[] = q.toArray(null); |
743 |
|
shouldThrow(); |
744 |
< |
} catch(NullPointerException success){} |
744 |
> |
} catch (NullPointerException success){} |
745 |
|
} |
746 |
|
|
747 |
|
/** |
752 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
753 |
|
Object o[] = q.toArray(new String[10] ); |
754 |
|
shouldThrow(); |
755 |
< |
} catch(ArrayStoreException success){} |
755 |
> |
} catch (ArrayStoreException success){} |
756 |
|
} |
757 |
|
|
758 |
|
|
763 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
764 |
|
Iterator it = q.iterator(); |
765 |
|
try { |
766 |
< |
while(it.hasNext()){ |
766 |
> |
while (it.hasNext()){ |
767 |
|
assertEquals(it.next(), q.take()); |
768 |
|
} |
769 |
|
} catch (InterruptedException e){ |
931 |
|
assertEquals(q.size(), r.size()); |
932 |
|
while (!q.isEmpty()) |
933 |
|
assertEquals(q.remove(), r.remove()); |
934 |
< |
} catch(Exception e){ |
934 |
> |
} catch (Exception e){ |
935 |
|
unexpectedException(); |
936 |
|
} |
937 |
|
} |
944 |
|
try { |
945 |
|
q.drainTo(null); |
946 |
|
shouldThrow(); |
947 |
< |
} catch(NullPointerException success) { |
947 |
> |
} catch (NullPointerException success) { |
948 |
|
} |
949 |
|
} |
950 |
|
|
956 |
|
try { |
957 |
|
q.drainTo(q); |
958 |
|
shouldThrow(); |
959 |
< |
} catch(IllegalArgumentException success) { |
959 |
> |
} catch (IllegalArgumentException success) { |
960 |
|
} |
961 |
|
} |
962 |
|
|
1007 |
|
assertEquals(l.get(i), new Integer(i)); |
1008 |
|
t.join(); |
1009 |
|
assertTrue(q.size() + l.size() >= SIZE); |
1010 |
< |
} catch(Exception e){ |
1010 |
> |
} catch (Exception e){ |
1011 |
|
unexpectedException(); |
1012 |
|
} |
1013 |
|
} |
1020 |
|
try { |
1021 |
|
q.drainTo(null, 0); |
1022 |
|
shouldThrow(); |
1023 |
< |
} catch(NullPointerException success) { |
1023 |
> |
} catch (NullPointerException success) { |
1024 |
|
} |
1025 |
|
} |
1026 |
|
|
1032 |
|
try { |
1033 |
|
q.drainTo(q, 0); |
1034 |
|
shouldThrow(); |
1035 |
< |
} catch(IllegalArgumentException success) { |
1035 |
> |
} catch (IllegalArgumentException success) { |
1036 |
|
} |
1037 |
|
} |
1038 |
|
|
1042 |
|
public void testDrainToN() { |
1043 |
|
ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE*2); |
1044 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
1045 |
< |
for(int j = 0; j < SIZE; j++) |
1045 |
> |
for (int j = 0; j < SIZE; j++) |
1046 |
|
assertTrue(q.offer(new Integer(j))); |
1047 |
|
ArrayList l = new ArrayList(); |
1048 |
|
q.drainTo(l, i); |