29 |
|
private LinkedBlockingQueue populatedQueue(int n) { |
30 |
|
LinkedBlockingQueue q = new LinkedBlockingQueue(n); |
31 |
|
assertTrue(q.isEmpty()); |
32 |
< |
for(int i = 0; i < n; i++) |
32 |
> |
for (int i = 0; i < n; i++) |
33 |
|
assertTrue(q.offer(new Integer(i))); |
34 |
|
assertFalse(q.isEmpty()); |
35 |
|
assertEquals(0, q.remainingCapacity()); |
716 |
|
LinkedBlockingQueue q = populatedQueue(SIZE); |
717 |
|
Object[] o = q.toArray(); |
718 |
|
try { |
719 |
< |
for(int i = 0; i < o.length; i++) |
719 |
> |
for (int i = 0; i < o.length; i++) |
720 |
|
assertEquals(o[i], q.take()); |
721 |
|
} catch (InterruptedException e){ |
722 |
|
unexpectedException(); |
731 |
|
Integer[] ints = new Integer[SIZE]; |
732 |
|
ints = (Integer[])q.toArray(ints); |
733 |
|
try { |
734 |
< |
for(int i = 0; i < ints.length; i++) |
734 |
> |
for (int i = 0; i < ints.length; i++) |
735 |
|
assertEquals(ints[i], q.take()); |
736 |
|
} catch (InterruptedException e){ |
737 |
|
unexpectedException(); |
746 |
|
LinkedBlockingQueue q = populatedQueue(SIZE); |
747 |
|
Object o[] = q.toArray(null); |
748 |
|
shouldThrow(); |
749 |
< |
} catch(NullPointerException success){} |
749 |
> |
} catch (NullPointerException success){} |
750 |
|
} |
751 |
|
|
752 |
|
/** |
757 |
|
LinkedBlockingQueue q = populatedQueue(SIZE); |
758 |
|
Object o[] = q.toArray(new String[10] ); |
759 |
|
shouldThrow(); |
760 |
< |
} catch(ArrayStoreException success){} |
760 |
> |
} catch (ArrayStoreException success){} |
761 |
|
} |
762 |
|
|
763 |
|
|
768 |
|
LinkedBlockingQueue q = populatedQueue(SIZE); |
769 |
|
Iterator it = q.iterator(); |
770 |
|
try { |
771 |
< |
while(it.hasNext()){ |
771 |
> |
while (it.hasNext()){ |
772 |
|
assertEquals(it.next(), q.take()); |
773 |
|
} |
774 |
|
} catch (InterruptedException e){ |
934 |
|
assertEquals(q.size(), r.size()); |
935 |
|
while (!q.isEmpty()) |
936 |
|
assertEquals(q.remove(), r.remove()); |
937 |
< |
} catch(Exception e){ |
937 |
> |
} catch (Exception e){ |
938 |
|
unexpectedException(); |
939 |
|
} |
940 |
|
} |
947 |
|
try { |
948 |
|
q.drainTo(null); |
949 |
|
shouldThrow(); |
950 |
< |
} catch(NullPointerException success) { |
950 |
> |
} catch (NullPointerException success) { |
951 |
|
} |
952 |
|
} |
953 |
|
|
959 |
|
try { |
960 |
|
q.drainTo(q); |
961 |
|
shouldThrow(); |
962 |
< |
} catch(IllegalArgumentException success) { |
962 |
> |
} catch (IllegalArgumentException success) { |
963 |
|
} |
964 |
|
} |
965 |
|
|
1010 |
|
assertEquals(l.get(i), new Integer(i)); |
1011 |
|
t.join(); |
1012 |
|
assertTrue(q.size() + l.size() >= SIZE); |
1013 |
< |
} catch(Exception e){ |
1013 |
> |
} catch (Exception e){ |
1014 |
|
unexpectedException(); |
1015 |
|
} |
1016 |
|
} |
1023 |
|
try { |
1024 |
|
q.drainTo(null, 0); |
1025 |
|
shouldThrow(); |
1026 |
< |
} catch(NullPointerException success) { |
1026 |
> |
} catch (NullPointerException success) { |
1027 |
|
} |
1028 |
|
} |
1029 |
|
|
1035 |
|
try { |
1036 |
|
q.drainTo(q, 0); |
1037 |
|
shouldThrow(); |
1038 |
< |
} catch(IllegalArgumentException success) { |
1038 |
> |
} catch (IllegalArgumentException success) { |
1039 |
|
} |
1040 |
|
} |
1041 |
|
|
1045 |
|
public void testDrainToN() { |
1046 |
|
LinkedBlockingQueue q = new LinkedBlockingQueue(); |
1047 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
1048 |
< |
for(int j = 0; j < SIZE; j++) |
1048 |
> |
for (int j = 0; j < SIZE; j++) |
1049 |
|
assertTrue(q.offer(new Integer(j))); |
1050 |
|
ArrayList l = new ArrayList(); |
1051 |
|
q.drainTo(l, i); |