77 |
|
try { |
78 |
|
TreeSet q = new TreeSet((Collection)null); |
79 |
|
shouldThrow(); |
80 |
< |
} |
81 |
< |
catch (NullPointerException success) {} |
80 |
> |
} catch (NullPointerException success) {} |
81 |
|
} |
82 |
|
|
83 |
|
/** |
88 |
|
Integer[] ints = new Integer[SIZE]; |
89 |
|
TreeSet q = new TreeSet(Arrays.asList(ints)); |
90 |
|
shouldThrow(); |
91 |
< |
} |
93 |
< |
catch (NullPointerException success) {} |
91 |
> |
} catch (NullPointerException success) {} |
92 |
|
} |
93 |
|
|
94 |
|
/** |
101 |
|
ints[i] = new Integer(i); |
102 |
|
TreeSet q = new TreeSet(Arrays.asList(ints)); |
103 |
|
shouldThrow(); |
104 |
< |
} |
107 |
< |
catch (NullPointerException success) {} |
104 |
> |
} catch (NullPointerException success) {} |
105 |
|
} |
106 |
|
|
107 |
|
/** |
174 |
|
TreeSet q = populatedSet(SIZE); |
175 |
|
q.add(null); |
176 |
|
shouldThrow(); |
177 |
< |
} catch (NullPointerException success) { } |
177 |
> |
} catch (NullPointerException success) {} |
178 |
|
} |
179 |
|
|
180 |
|
/** |
205 |
|
q.add(new Object()); |
206 |
|
q.add(new Object()); |
207 |
|
shouldThrow(); |
208 |
< |
} |
212 |
< |
catch (ClassCastException success) {} |
208 |
> |
} catch (ClassCastException success) {} |
209 |
|
} |
210 |
|
|
211 |
|
/** |
216 |
|
TreeSet q = new TreeSet(); |
217 |
|
q.addAll(null); |
218 |
|
shouldThrow(); |
219 |
< |
} |
224 |
< |
catch (NullPointerException success) {} |
219 |
> |
} catch (NullPointerException success) {} |
220 |
|
} |
221 |
|
/** |
222 |
|
* addAll of a collection with null elements throws NPE |
227 |
|
Integer[] ints = new Integer[SIZE]; |
228 |
|
q.addAll(Arrays.asList(ints)); |
229 |
|
shouldThrow(); |
230 |
< |
} |
236 |
< |
catch (NullPointerException success) {} |
230 |
> |
} catch (NullPointerException success) {} |
231 |
|
} |
232 |
|
/** |
233 |
|
* addAll of a collection with any null elements throws NPE after |
241 |
|
ints[i] = new Integer(i); |
242 |
|
q.addAll(Arrays.asList(ints)); |
243 |
|
shouldThrow(); |
244 |
< |
} |
251 |
< |
catch (NullPointerException success) {} |
244 |
> |
} catch (NullPointerException success) {} |
245 |
|
} |
246 |
|
|
247 |
|
/** |
538 |
|
/** |
539 |
|
* A deserialized serialized set has same elements |
540 |
|
*/ |
541 |
< |
public void testSerialization() { |
541 |
> |
public void testSerialization() throws Exception { |
542 |
|
TreeSet q = populatedSet(SIZE); |
543 |
< |
try { |
544 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
545 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
546 |
< |
out.writeObject(q); |
547 |
< |
out.close(); |
548 |
< |
|
549 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
550 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
551 |
< |
TreeSet r = (TreeSet)in.readObject(); |
552 |
< |
assertEquals(q.size(), r.size()); |
553 |
< |
while (!q.isEmpty()) |
561 |
< |
assertEquals(q.pollFirst(), r.pollFirst()); |
562 |
< |
} catch (Exception e) { |
563 |
< |
e.printStackTrace(); |
564 |
< |
unexpectedException(); |
565 |
< |
} |
543 |
> |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
544 |
> |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
545 |
> |
out.writeObject(q); |
546 |
> |
out.close(); |
547 |
> |
|
548 |
> |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
549 |
> |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
550 |
> |
TreeSet r = (TreeSet)in.readObject(); |
551 |
> |
assertEquals(q.size(), r.size()); |
552 |
> |
while (!q.isEmpty()) |
553 |
> |
assertEquals(q.pollFirst(), r.pollFirst()); |
554 |
|
} |
555 |
|
|
556 |
|
/** |