39 |
|
private PriorityBlockingQueue populatedQueue(int n) { |
40 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(n); |
41 |
|
assertTrue(q.isEmpty()); |
42 |
< |
for(int i = n-1; i >= 0; i-=2) |
42 |
> |
for (int i = n-1; i >= 0; i-=2) |
43 |
|
assertTrue(q.offer(new Integer(i))); |
44 |
< |
for(int i = (n & 1); i < n; i+=2) |
44 |
> |
for (int i = (n & 1); i < n; i+=2) |
45 |
|
assertTrue(q.offer(new Integer(i))); |
46 |
|
assertFalse(q.isEmpty()); |
47 |
|
assertEquals(NOCAP, q.remainingCapacity()); |
212 |
|
q.offer(new Object()); |
213 |
|
shouldThrow(); |
214 |
|
} |
215 |
< |
catch(ClassCastException success) {} |
215 |
> |
catch (ClassCastException success) {} |
216 |
|
} |
217 |
|
|
218 |
|
/** |
690 |
|
Object[] o = q.toArray(); |
691 |
|
Arrays.sort(o); |
692 |
|
try { |
693 |
< |
for(int i = 0; i < o.length; i++) |
693 |
> |
for (int i = 0; i < o.length; i++) |
694 |
|
assertEquals(o[i], q.take()); |
695 |
|
} catch (InterruptedException e){ |
696 |
|
unexpectedException(); |
706 |
|
ints = (Integer[])q.toArray(ints); |
707 |
|
Arrays.sort(ints); |
708 |
|
try { |
709 |
< |
for(int i = 0; i < ints.length; i++) |
709 |
> |
for (int i = 0; i < ints.length; i++) |
710 |
|
assertEquals(ints[i], q.take()); |
711 |
|
} catch (InterruptedException e){ |
712 |
|
unexpectedException(); |
721 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
722 |
|
Object o[] = q.toArray(null); |
723 |
|
shouldThrow(); |
724 |
< |
} catch(NullPointerException success){} |
724 |
> |
} catch (NullPointerException success){} |
725 |
|
} |
726 |
|
|
727 |
|
/** |
732 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
733 |
|
Object o[] = q.toArray(new String[10] ); |
734 |
|
shouldThrow(); |
735 |
< |
} catch(ArrayStoreException success){} |
735 |
> |
} catch (ArrayStoreException success){} |
736 |
|
} |
737 |
|
|
738 |
|
/** |
742 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
743 |
|
int i = 0; |
744 |
|
Iterator it = q.iterator(); |
745 |
< |
while(it.hasNext()) { |
745 |
> |
while (it.hasNext()) { |
746 |
|
assertTrue(q.contains(it.next())); |
747 |
|
++i; |
748 |
|
} |
831 |
|
assertEquals(q.size(), r.size()); |
832 |
|
while (!q.isEmpty()) |
833 |
|
assertEquals(q.remove(), r.remove()); |
834 |
< |
} catch(Exception e){ |
834 |
> |
} catch (Exception e){ |
835 |
|
unexpectedException(); |
836 |
|
} |
837 |
|
} |
844 |
|
try { |
845 |
|
q.drainTo(null); |
846 |
|
shouldThrow(); |
847 |
< |
} catch(NullPointerException success) { |
847 |
> |
} catch (NullPointerException success) { |
848 |
|
} |
849 |
|
} |
850 |
|
|
856 |
|
try { |
857 |
|
q.drainTo(q); |
858 |
|
shouldThrow(); |
859 |
< |
} catch(IllegalArgumentException success) { |
859 |
> |
} catch (IllegalArgumentException success) { |
860 |
|
} |
861 |
|
} |
862 |
|
|
903 |
|
assertEquals(l.get(i), new Integer(i)); |
904 |
|
t.join(); |
905 |
|
assertTrue(q.size() + l.size() >= SIZE); |
906 |
< |
} catch(Exception e){ |
906 |
> |
} catch (Exception e){ |
907 |
|
unexpectedException(); |
908 |
|
} |
909 |
|
} |
916 |
|
try { |
917 |
|
q.drainTo(null, 0); |
918 |
|
shouldThrow(); |
919 |
< |
} catch(NullPointerException success) { |
919 |
> |
} catch (NullPointerException success) { |
920 |
|
} |
921 |
|
} |
922 |
|
|
928 |
|
try { |
929 |
|
q.drainTo(q, 0); |
930 |
|
shouldThrow(); |
931 |
< |
} catch(IllegalArgumentException success) { |
931 |
> |
} catch (IllegalArgumentException success) { |
932 |
|
} |
933 |
|
} |
934 |
|
|
938 |
|
public void testDrainToN() { |
939 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE*2); |
940 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
941 |
< |
for(int j = 0; j < SIZE; j++) |
941 |
> |
for (int j = 0; j < SIZE; j++) |
942 |
|
assertTrue(q.offer(new Integer(j))); |
943 |
|
ArrayList l = new ArrayList(); |
944 |
|
q.drainTo(l, i); |