138 |
|
NavigableSet q = set0(); |
139 |
|
q.add(null); |
140 |
|
shouldThrow(); |
141 |
< |
} catch (NullPointerException success) { } |
141 |
> |
} catch (NullPointerException success) {} |
142 |
|
} |
143 |
|
|
144 |
|
/** |
168 |
|
q.add(new Object()); |
169 |
|
q.add(new Object()); |
170 |
|
shouldThrow(); |
171 |
< |
} |
172 |
< |
catch (ClassCastException success) {} |
171 |
> |
} catch (ClassCastException success) {} |
172 |
|
} |
173 |
|
|
174 |
|
|
180 |
|
NavigableSet q = set0(); |
181 |
|
q.addAll(null); |
182 |
|
shouldThrow(); |
183 |
< |
} |
185 |
< |
catch (NullPointerException success) {} |
183 |
> |
} catch (NullPointerException success) {} |
184 |
|
} |
185 |
|
/** |
186 |
|
* addAll of a collection with null elements throws NPE |
191 |
|
Integer[] ints = new Integer[SIZE]; |
192 |
|
q.addAll(Arrays.asList(ints)); |
193 |
|
shouldThrow(); |
194 |
< |
} |
197 |
< |
catch (NullPointerException success) {} |
194 |
> |
} catch (NullPointerException success) {} |
195 |
|
} |
196 |
|
/** |
197 |
|
* addAll of a collection with any null elements throws NPE after |
205 |
|
ints[i] = new Integer(i+SIZE); |
206 |
|
q.addAll(Arrays.asList(ints)); |
207 |
|
shouldThrow(); |
208 |
< |
} |
212 |
< |
catch (NullPointerException success) {} |
208 |
> |
} catch (NullPointerException success) {} |
209 |
|
} |
210 |
|
|
211 |
|
/** |
212 |
|
* Set contains all elements of successful addAll |
213 |
|
*/ |
214 |
|
public void testAddAll5() { |
215 |
< |
try { |
216 |
< |
Integer[] empty = new Integer[0]; |
217 |
< |
Integer[] ints = new Integer[SIZE]; |
218 |
< |
for (int i = 0; i < SIZE; ++i) |
219 |
< |
ints[i] = new Integer(SIZE-1- i); |
220 |
< |
NavigableSet q = set0(); |
221 |
< |
assertFalse(q.addAll(Arrays.asList(empty))); |
222 |
< |
assertTrue(q.addAll(Arrays.asList(ints))); |
223 |
< |
for (int i = 0; i < SIZE; ++i) |
228 |
< |
assertEquals(new Integer(i), q.pollFirst()); |
229 |
< |
} |
230 |
< |
finally {} |
215 |
> |
Integer[] empty = new Integer[0]; |
216 |
> |
Integer[] ints = new Integer[SIZE]; |
217 |
> |
for (int i = 0; i < SIZE; ++i) |
218 |
> |
ints[i] = new Integer(SIZE-1- i); |
219 |
> |
NavigableSet q = set0(); |
220 |
> |
assertFalse(q.addAll(Arrays.asList(empty))); |
221 |
> |
assertTrue(q.addAll(Arrays.asList(ints))); |
222 |
> |
for (int i = 0; i < SIZE; ++i) |
223 |
> |
assertEquals(new Integer(i), q.pollFirst()); |
224 |
|
} |
225 |
|
|
226 |
|
/** |
487 |
|
/** |
488 |
|
* A deserialized serialized set has same elements |
489 |
|
*/ |
490 |
< |
public void testSerialization() { |
490 |
> |
public void testSerialization() throws Exception { |
491 |
|
NavigableSet q = populatedSet(SIZE); |
492 |
< |
try { |
493 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
494 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
495 |
< |
out.writeObject(q); |
496 |
< |
out.close(); |
497 |
< |
|
498 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
499 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
500 |
< |
NavigableSet r = (NavigableSet)in.readObject(); |
501 |
< |
assertEquals(q.size(), r.size()); |
502 |
< |
while (!q.isEmpty()) |
510 |
< |
assertEquals(q.pollFirst(), r.pollFirst()); |
511 |
< |
} catch (Exception e) { |
512 |
< |
e.printStackTrace(); |
513 |
< |
unexpectedException(); |
514 |
< |
} |
492 |
> |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
493 |
> |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
494 |
> |
out.writeObject(q); |
495 |
> |
out.close(); |
496 |
> |
|
497 |
> |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
498 |
> |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
499 |
> |
NavigableSet r = (NavigableSet)in.readObject(); |
500 |
> |
assertEquals(q.size(), r.size()); |
501 |
> |
while (!q.isEmpty()) |
502 |
> |
assertEquals(q.pollFirst(), r.pollFirst()); |
503 |
|
} |
504 |
|
|
505 |
|
/** |
644 |
|
NavigableSet q = dset0(); |
645 |
|
q.add(null); |
646 |
|
shouldThrow(); |
647 |
< |
} catch (NullPointerException success) { } |
647 |
> |
} catch (NullPointerException success) {} |
648 |
|
} |
649 |
|
|
650 |
|
/** |
674 |
|
q.add(new Object()); |
675 |
|
q.add(new Object()); |
676 |
|
shouldThrow(); |
677 |
< |
} |
690 |
< |
catch (ClassCastException success) {} |
677 |
> |
} catch (ClassCastException success) {} |
678 |
|
} |
679 |
|
|
680 |
|
|
686 |
|
NavigableSet q = dset0(); |
687 |
|
q.addAll(null); |
688 |
|
shouldThrow(); |
689 |
< |
} |
703 |
< |
catch (NullPointerException success) {} |
689 |
> |
} catch (NullPointerException success) {} |
690 |
|
} |
691 |
|
/** |
692 |
|
* addAll of a collection with null elements throws NPE |
697 |
|
Integer[] ints = new Integer[SIZE]; |
698 |
|
q.addAll(Arrays.asList(ints)); |
699 |
|
shouldThrow(); |
700 |
< |
} |
715 |
< |
catch (NullPointerException success) {} |
700 |
> |
} catch (NullPointerException success) {} |
701 |
|
} |
702 |
|
/** |
703 |
|
* addAll of a collection with any null elements throws NPE after |
711 |
|
ints[i] = new Integer(i+SIZE); |
712 |
|
q.addAll(Arrays.asList(ints)); |
713 |
|
shouldThrow(); |
714 |
< |
} |
730 |
< |
catch (NullPointerException success) {} |
714 |
> |
} catch (NullPointerException success) {} |
715 |
|
} |
716 |
|
|
717 |
|
/** |
718 |
|
* Set contains all elements of successful addAll |
719 |
|
*/ |
720 |
|
public void testDescendingAddAll5() { |
721 |
< |
try { |
722 |
< |
Integer[] empty = new Integer[0]; |
723 |
< |
Integer[] ints = new Integer[SIZE]; |
724 |
< |
for (int i = 0; i < SIZE; ++i) |
725 |
< |
ints[i] = new Integer(SIZE-1- i); |
726 |
< |
NavigableSet q = dset0(); |
727 |
< |
assertFalse(q.addAll(Arrays.asList(empty))); |
728 |
< |
assertTrue(q.addAll(Arrays.asList(ints))); |
729 |
< |
for (int i = 0; i < SIZE; ++i) |
746 |
< |
assertEquals(new Integer(i), q.pollFirst()); |
747 |
< |
} |
748 |
< |
finally {} |
721 |
> |
Integer[] empty = new Integer[0]; |
722 |
> |
Integer[] ints = new Integer[SIZE]; |
723 |
> |
for (int i = 0; i < SIZE; ++i) |
724 |
> |
ints[i] = new Integer(SIZE-1- i); |
725 |
> |
NavigableSet q = dset0(); |
726 |
> |
assertFalse(q.addAll(Arrays.asList(empty))); |
727 |
> |
assertTrue(q.addAll(Arrays.asList(ints))); |
728 |
> |
for (int i = 0; i < SIZE; ++i) |
729 |
> |
assertEquals(new Integer(i), q.pollFirst()); |
730 |
|
} |
731 |
|
|
732 |
|
/** |
993 |
|
/** |
994 |
|
* A deserialized serialized set has same elements |
995 |
|
*/ |
996 |
< |
public void testDescendingSerialization() { |
996 |
> |
public void testDescendingSerialization() throws Exception { |
997 |
|
NavigableSet q = populatedSet(SIZE); |
998 |
< |
try { |
999 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
1000 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
1001 |
< |
out.writeObject(q); |
1002 |
< |
out.close(); |
1003 |
< |
|
1004 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
1005 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
1006 |
< |
NavigableSet r = (NavigableSet)in.readObject(); |
1007 |
< |
assertEquals(q.size(), r.size()); |
1008 |
< |
while (!q.isEmpty()) |
1028 |
< |
assertEquals(q.pollFirst(), r.pollFirst()); |
1029 |
< |
} catch (Exception e) { |
1030 |
< |
e.printStackTrace(); |
1031 |
< |
unexpectedException(); |
1032 |
< |
} |
998 |
> |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
999 |
> |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
1000 |
> |
out.writeObject(q); |
1001 |
> |
out.close(); |
1002 |
> |
|
1003 |
> |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
1004 |
> |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
1005 |
> |
NavigableSet r = (NavigableSet)in.readObject(); |
1006 |
> |
assertEquals(q.size(), r.size()); |
1007 |
> |
while (!q.isEmpty()) |
1008 |
> |
assertEquals(q.pollFirst(), r.pollFirst()); |
1009 |
|
} |
1010 |
|
|
1011 |
|
/** |