11 |
|
|
12 |
|
public class TreeSubSetTest extends JSR166TestCase { |
13 |
|
public static void main(String[] args) { |
14 |
< |
junit.textui.TestRunner.run (suite()); |
14 |
> |
junit.textui.TestRunner.run(suite()); |
15 |
|
} |
16 |
|
public static Test suite() { |
17 |
< |
return new TestSuite(TreeSubSetTest.class); |
17 |
> |
return new TestSuite(TreeSubSetTest.class); |
18 |
|
} |
19 |
|
|
20 |
< |
static class MyReverseComparator implements Comparator { |
20 |
> |
static class MyReverseComparator implements Comparator { |
21 |
|
public int compare(Object x, Object y) { |
22 |
< |
int i = ((Integer)x).intValue(); |
23 |
< |
int j = ((Integer)y).intValue(); |
24 |
< |
if (i < j) return 1; |
25 |
< |
if (i > j) return -1; |
26 |
< |
return 0; |
22 |
> |
return ((Comparable)y).compareTo(x); |
23 |
|
} |
24 |
|
} |
25 |
|
|
31 |
|
TreeSet q = new TreeSet(); |
32 |
|
assertTrue(q.isEmpty()); |
33 |
|
|
34 |
< |
for(int i = n-1; i >= 0; i-=2) |
35 |
< |
assertTrue(q.add(new Integer(i))); |
36 |
< |
for(int i = (n & 1); i < n; i+=2) |
37 |
< |
assertTrue(q.add(new Integer(i))); |
34 |
> |
for (int i = n-1; i >= 0; i-=2) |
35 |
> |
assertTrue(q.add(new Integer(i))); |
36 |
> |
for (int i = (n & 1); i < n; i+=2) |
37 |
> |
assertTrue(q.add(new Integer(i))); |
38 |
|
assertTrue(q.add(new Integer(-n))); |
39 |
|
assertTrue(q.add(new Integer(n))); |
40 |
|
NavigableSet s = q.subSet(new Integer(0), true, new Integer(n), false); |
41 |
|
assertFalse(s.isEmpty()); |
42 |
< |
assertEquals(n, s.size()); |
42 |
> |
assertEquals(n, s.size()); |
43 |
|
return s; |
44 |
|
} |
45 |
|
|
57 |
|
q.add(zero); |
58 |
|
q.add(seven); |
59 |
|
NavigableSet s = q.subSet(one, true, seven, false); |
60 |
< |
assertEquals(5, s.size()); |
60 |
> |
assertEquals(5, s.size()); |
61 |
|
return s; |
62 |
|
} |
63 |
|
|
70 |
|
q.add(m4); |
71 |
|
q.add(m5); |
72 |
|
NavigableSet s = q.descendingSet(); |
73 |
< |
assertEquals(5, s.size()); |
73 |
> |
assertEquals(5, s.size()); |
74 |
|
return s; |
75 |
|
} |
76 |
|
|
77 |
< |
private static NavigableSet set0() { |
78 |
< |
TreeSet set = new TreeSet(); |
77 |
> |
private static NavigableSet set0() { |
78 |
> |
TreeSet set = new TreeSet(); |
79 |
|
assertTrue(set.isEmpty()); |
80 |
|
return set.tailSet(m1, false); |
81 |
|
} |
82 |
|
|
83 |
< |
private static NavigableSet dset0() { |
84 |
< |
TreeSet set = new TreeSet(); |
83 |
> |
private static NavigableSet dset0() { |
84 |
> |
TreeSet set = new TreeSet(); |
85 |
|
assertTrue(set.isEmpty()); |
86 |
|
return set; |
87 |
|
} |
88 |
< |
|
88 |
> |
|
89 |
|
/** |
90 |
|
* A new set has unbounded capacity |
91 |
|
*/ |
100 |
|
public void testEmpty() { |
101 |
|
NavigableSet q = set0(); |
102 |
|
assertTrue(q.isEmpty()); |
103 |
< |
q.add(new Integer(1)); |
103 |
> |
assertTrue(q.add(new Integer(1))); |
104 |
|
assertFalse(q.isEmpty()); |
105 |
< |
q.add(new Integer(2)); |
105 |
> |
assertTrue(q.add(new Integer(2))); |
106 |
|
q.pollFirst(); |
107 |
|
q.pollFirst(); |
108 |
|
assertTrue(q.isEmpty()); |
127 |
|
* add(null) throws NPE |
128 |
|
*/ |
129 |
|
public void testAddNull() { |
130 |
< |
try { |
130 |
> |
try { |
131 |
|
NavigableSet q = set0(); |
132 |
|
q.add(null); |
133 |
|
shouldThrow(); |
134 |
< |
} catch (NullPointerException success) { } |
134 |
> |
} catch (NullPointerException success) {} |
135 |
|
} |
136 |
|
|
137 |
|
/** |
161 |
|
q.add(new Object()); |
162 |
|
q.add(new Object()); |
163 |
|
shouldThrow(); |
164 |
< |
} |
169 |
< |
catch(ClassCastException success) {} |
164 |
> |
} catch (ClassCastException success) {} |
165 |
|
} |
166 |
|
|
167 |
|
|
173 |
|
NavigableSet q = set0(); |
174 |
|
q.addAll(null); |
175 |
|
shouldThrow(); |
176 |
< |
} |
182 |
< |
catch (NullPointerException success) {} |
176 |
> |
} catch (NullPointerException success) {} |
177 |
|
} |
178 |
+ |
|
179 |
|
/** |
180 |
|
* addAll of a collection with null elements throws NPE |
181 |
|
*/ |
185 |
|
Integer[] ints = new Integer[SIZE]; |
186 |
|
q.addAll(Arrays.asList(ints)); |
187 |
|
shouldThrow(); |
188 |
< |
} |
194 |
< |
catch (NullPointerException success) {} |
188 |
> |
} catch (NullPointerException success) {} |
189 |
|
} |
190 |
+ |
|
191 |
|
/** |
192 |
|
* addAll of a collection with any null elements throws NPE after |
193 |
|
* possibly adding some elements |
200 |
|
ints[i] = new Integer(i+SIZE); |
201 |
|
q.addAll(Arrays.asList(ints)); |
202 |
|
shouldThrow(); |
203 |
< |
} |
209 |
< |
catch (NullPointerException success) {} |
203 |
> |
} catch (NullPointerException success) {} |
204 |
|
} |
205 |
|
|
206 |
|
/** |
207 |
|
* Set contains all elements of successful addAll |
208 |
|
*/ |
209 |
|
public void testAddAll5() { |
210 |
< |
try { |
211 |
< |
Integer[] empty = new Integer[0]; |
212 |
< |
Integer[] ints = new Integer[SIZE]; |
213 |
< |
for (int i = 0; i < SIZE; ++i) |
214 |
< |
ints[i] = new Integer(SIZE-1- i); |
215 |
< |
NavigableSet q = set0(); |
216 |
< |
assertFalse(q.addAll(Arrays.asList(empty))); |
217 |
< |
assertTrue(q.addAll(Arrays.asList(ints))); |
218 |
< |
for (int i = 0; i < SIZE; ++i) |
225 |
< |
assertEquals(new Integer(i), q.pollFirst()); |
226 |
< |
} |
227 |
< |
finally {} |
210 |
> |
Integer[] empty = new Integer[0]; |
211 |
> |
Integer[] ints = new Integer[SIZE]; |
212 |
> |
for (int i = 0; i < SIZE; ++i) |
213 |
> |
ints[i] = new Integer(SIZE-1- i); |
214 |
> |
NavigableSet q = set0(); |
215 |
> |
assertFalse(q.addAll(Arrays.asList(empty))); |
216 |
> |
assertTrue(q.addAll(Arrays.asList(ints))); |
217 |
> |
for (int i = 0; i < SIZE; ++i) |
218 |
> |
assertEquals(new Integer(i), q.pollFirst()); |
219 |
|
} |
220 |
|
|
221 |
|
/** |
224 |
|
public void testPoll() { |
225 |
|
NavigableSet q = populatedSet(SIZE); |
226 |
|
for (int i = 0; i < SIZE; ++i) { |
227 |
< |
assertEquals(i, ((Integer)q.pollFirst()).intValue()); |
227 |
> |
assertEquals(i, q.pollFirst()); |
228 |
|
} |
229 |
< |
assertNull(q.pollFirst()); |
229 |
> |
assertNull(q.pollFirst()); |
230 |
|
} |
231 |
|
|
232 |
|
/** |
243 |
|
} |
244 |
|
assertTrue(q.isEmpty()); |
245 |
|
} |
246 |
< |
|
246 |
> |
|
247 |
|
/** |
248 |
|
* contains(x) reports true when elements added but not yet removed |
249 |
|
*/ |
264 |
|
q.clear(); |
265 |
|
assertTrue(q.isEmpty()); |
266 |
|
assertEquals(0, q.size()); |
267 |
< |
q.add(new Integer(1)); |
267 |
> |
assertTrue(q.add(new Integer(1))); |
268 |
|
assertFalse(q.isEmpty()); |
269 |
|
q.clear(); |
270 |
|
assertTrue(q.isEmpty()); |
319 |
|
} |
320 |
|
} |
321 |
|
|
322 |
< |
|
322 |
> |
|
323 |
|
|
324 |
|
/** |
325 |
|
* lower returns preceding element |
337 |
|
|
338 |
|
Object e4 = q.lower(zero); |
339 |
|
assertNull(e4); |
349 |
– |
|
340 |
|
} |
341 |
|
|
342 |
|
/** |
355 |
|
|
356 |
|
Object e4 = q.higher(six); |
357 |
|
assertNull(e4); |
368 |
– |
|
358 |
|
} |
359 |
|
|
360 |
|
/** |
373 |
|
|
374 |
|
Object e4 = q.floor(zero); |
375 |
|
assertNull(e4); |
387 |
– |
|
376 |
|
} |
377 |
|
|
378 |
|
/** |
391 |
|
|
392 |
|
Object e4 = q.ceiling(six); |
393 |
|
assertNull(e4); |
406 |
– |
|
394 |
|
} |
395 |
|
|
396 |
|
/** |
397 |
< |
* toArray contains all elements |
397 |
> |
* toArray contains all elements in sorted order |
398 |
|
*/ |
399 |
|
public void testToArray() { |
400 |
|
NavigableSet q = populatedSet(SIZE); |
401 |
< |
Object[] o = q.toArray(); |
402 |
< |
Arrays.sort(o); |
403 |
< |
for(int i = 0; i < o.length; i++) |
417 |
< |
assertEquals(o[i], q.pollFirst()); |
401 |
> |
Object[] o = q.toArray(); |
402 |
> |
for (int i = 0; i < o.length; i++) |
403 |
> |
assertSame(o[i], q.pollFirst()); |
404 |
|
} |
405 |
|
|
406 |
|
/** |
407 |
< |
* toArray(a) contains all elements |
407 |
> |
* toArray(a) contains all elements in sorted order |
408 |
|
*/ |
409 |
|
public void testToArray2() { |
410 |
|
NavigableSet q = populatedSet(SIZE); |
411 |
< |
Integer[] ints = new Integer[SIZE]; |
412 |
< |
ints = (Integer[])q.toArray(ints); |
413 |
< |
Arrays.sort(ints); |
414 |
< |
for(int i = 0; i < ints.length; i++) |
429 |
< |
assertEquals(ints[i], q.pollFirst()); |
411 |
> |
Integer[] ints = new Integer[SIZE]; |
412 |
> |
assertSame(ints, q.toArray(ints)); |
413 |
> |
for (int i = 0; i < ints.length; i++) |
414 |
> |
assertSame(ints[i], q.pollFirst()); |
415 |
|
} |
416 |
< |
|
416 |
> |
|
417 |
|
/** |
418 |
|
* iterator iterates through all elements |
419 |
|
*/ |
420 |
|
public void testIterator() { |
421 |
|
NavigableSet q = populatedSet(SIZE); |
422 |
|
int i = 0; |
423 |
< |
Iterator it = q.iterator(); |
424 |
< |
while(it.hasNext()) { |
423 |
> |
Iterator it = q.iterator(); |
424 |
> |
while (it.hasNext()) { |
425 |
|
assertTrue(q.contains(it.next())); |
426 |
|
++i; |
427 |
|
} |
434 |
|
public void testEmptyIterator() { |
435 |
|
NavigableSet q = set0(); |
436 |
|
int i = 0; |
437 |
< |
Iterator it = q.iterator(); |
438 |
< |
while(it.hasNext()) { |
437 |
> |
Iterator it = q.iterator(); |
438 |
> |
while (it.hasNext()) { |
439 |
|
assertTrue(q.contains(it.next())); |
440 |
|
++i; |
441 |
|
} |
445 |
|
/** |
446 |
|
* iterator.remove removes current element |
447 |
|
*/ |
448 |
< |
public void testIteratorRemove () { |
448 |
> |
public void testIteratorRemove() { |
449 |
|
final NavigableSet q = set0(); |
450 |
|
q.add(new Integer(2)); |
451 |
|
q.add(new Integer(1)); |
456 |
|
it.remove(); |
457 |
|
|
458 |
|
it = q.iterator(); |
459 |
< |
assertEquals(it.next(), new Integer(2)); |
460 |
< |
assertEquals(it.next(), new Integer(3)); |
459 |
> |
assertEquals(it.next(), 2); |
460 |
> |
assertEquals(it.next(), 3); |
461 |
|
assertFalse(it.hasNext()); |
462 |
|
} |
463 |
|
|
471 |
|
for (int i = 0; i < SIZE; ++i) { |
472 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
473 |
|
} |
474 |
< |
} |
474 |
> |
} |
475 |
|
|
476 |
|
/** |
477 |
< |
* A deserialized serialized set has same elements |
477 |
> |
* A deserialized serialized set has same elements |
478 |
|
*/ |
479 |
< |
public void testSerialization() { |
479 |
> |
public void testSerialization() throws Exception { |
480 |
|
NavigableSet q = populatedSet(SIZE); |
481 |
< |
try { |
482 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
483 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
484 |
< |
out.writeObject(q); |
485 |
< |
out.close(); |
486 |
< |
|
487 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
488 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
489 |
< |
NavigableSet r = (NavigableSet)in.readObject(); |
490 |
< |
assertEquals(q.size(), r.size()); |
491 |
< |
while (!q.isEmpty()) |
507 |
< |
assertEquals(q.pollFirst(), r.pollFirst()); |
508 |
< |
} catch(Exception e){ |
509 |
< |
e.printStackTrace(); |
510 |
< |
unexpectedException(); |
511 |
< |
} |
481 |
> |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
482 |
> |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
483 |
> |
out.writeObject(q); |
484 |
> |
out.close(); |
485 |
> |
|
486 |
> |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
487 |
> |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
488 |
> |
NavigableSet r = (NavigableSet)in.readObject(); |
489 |
> |
assertEquals(q.size(), r.size()); |
490 |
> |
while (!q.isEmpty()) |
491 |
> |
assertEquals(q.pollFirst(), r.pollFirst()); |
492 |
|
} |
493 |
|
|
494 |
|
/** |
652 |
|
q.add(new Object()); |
653 |
|
q.add(new Object()); |
654 |
|
shouldThrow(); |
655 |
< |
} |
676 |
< |
catch(ClassCastException success) {} |
655 |
> |
} catch (ClassCastException success) {} |
656 |
|
} |
657 |
|
|
658 |
|
|
664 |
|
NavigableSet q = dset0(); |
665 |
|
q.addAll(null); |
666 |
|
shouldThrow(); |
667 |
< |
} |
689 |
< |
catch (NullPointerException success) {} |
667 |
> |
} catch (NullPointerException success) {} |
668 |
|
} |
669 |
+ |
|
670 |
|
/** |
671 |
|
* addAll of a collection with null elements throws NPE |
672 |
|
*/ |
676 |
|
Integer[] ints = new Integer[SIZE]; |
677 |
|
q.addAll(Arrays.asList(ints)); |
678 |
|
shouldThrow(); |
679 |
< |
} |
701 |
< |
catch (NullPointerException success) {} |
679 |
> |
} catch (NullPointerException success) {} |
680 |
|
} |
681 |
+ |
|
682 |
|
/** |
683 |
|
* addAll of a collection with any null elements throws NPE after |
684 |
|
* possibly adding some elements |
691 |
|
ints[i] = new Integer(i+SIZE); |
692 |
|
q.addAll(Arrays.asList(ints)); |
693 |
|
shouldThrow(); |
694 |
< |
} |
716 |
< |
catch (NullPointerException success) {} |
694 |
> |
} catch (NullPointerException success) {} |
695 |
|
} |
696 |
|
|
697 |
|
/** |
698 |
|
* Set contains all elements of successful addAll |
699 |
|
*/ |
700 |
|
public void testDescendingAddAll5() { |
701 |
< |
try { |
702 |
< |
Integer[] empty = new Integer[0]; |
703 |
< |
Integer[] ints = new Integer[SIZE]; |
704 |
< |
for (int i = 0; i < SIZE; ++i) |
705 |
< |
ints[i] = new Integer(SIZE-1- i); |
706 |
< |
NavigableSet q = dset0(); |
707 |
< |
assertFalse(q.addAll(Arrays.asList(empty))); |
708 |
< |
assertTrue(q.addAll(Arrays.asList(ints))); |
709 |
< |
for (int i = 0; i < SIZE; ++i) |
732 |
< |
assertEquals(new Integer(i), q.pollFirst()); |
733 |
< |
} |
734 |
< |
finally {} |
701 |
> |
Integer[] empty = new Integer[0]; |
702 |
> |
Integer[] ints = new Integer[SIZE]; |
703 |
> |
for (int i = 0; i < SIZE; ++i) |
704 |
> |
ints[i] = new Integer(SIZE-1- i); |
705 |
> |
NavigableSet q = dset0(); |
706 |
> |
assertFalse(q.addAll(Arrays.asList(empty))); |
707 |
> |
assertTrue(q.addAll(Arrays.asList(ints))); |
708 |
> |
for (int i = 0; i < SIZE; ++i) |
709 |
> |
assertEquals(new Integer(i), q.pollFirst()); |
710 |
|
} |
711 |
|
|
712 |
|
/** |
715 |
|
public void testDescendingPoll() { |
716 |
|
NavigableSet q = populatedSet(SIZE); |
717 |
|
for (int i = 0; i < SIZE; ++i) { |
718 |
< |
assertEquals(i, ((Integer)q.pollFirst()).intValue()); |
718 |
> |
assertEquals(i, q.pollFirst()); |
719 |
|
} |
720 |
< |
assertNull(q.pollFirst()); |
720 |
> |
assertNull(q.pollFirst()); |
721 |
|
} |
722 |
|
|
723 |
|
/** |
734 |
|
} |
735 |
|
assertTrue(q.isEmpty()); |
736 |
|
} |
737 |
< |
|
737 |
> |
|
738 |
|
/** |
739 |
|
* contains(x) reports true when elements added but not yet removed |
740 |
|
*/ |
755 |
|
q.clear(); |
756 |
|
assertTrue(q.isEmpty()); |
757 |
|
assertEquals(0, q.size()); |
758 |
< |
q.add(new Integer(1)); |
758 |
> |
assertTrue(q.add(new Integer(1))); |
759 |
|
assertFalse(q.isEmpty()); |
760 |
|
q.clear(); |
761 |
|
assertTrue(q.isEmpty()); |
810 |
|
} |
811 |
|
} |
812 |
|
|
813 |
< |
|
813 |
> |
|
814 |
|
|
815 |
|
/** |
816 |
|
* lower returns preceding element |
828 |
|
|
829 |
|
Object e4 = q.lower(zero); |
830 |
|
assertNull(e4); |
856 |
– |
|
831 |
|
} |
832 |
|
|
833 |
|
/** |
846 |
|
|
847 |
|
Object e4 = q.higher(m6); |
848 |
|
assertNull(e4); |
875 |
– |
|
849 |
|
} |
850 |
|
|
851 |
|
/** |
864 |
|
|
865 |
|
Object e4 = q.floor(zero); |
866 |
|
assertNull(e4); |
894 |
– |
|
867 |
|
} |
868 |
|
|
869 |
|
/** |
882 |
|
|
883 |
|
Object e4 = q.ceiling(m6); |
884 |
|
assertNull(e4); |
913 |
– |
|
885 |
|
} |
886 |
|
|
887 |
|
/** |
889 |
|
*/ |
890 |
|
public void testDescendingToArray() { |
891 |
|
NavigableSet q = populatedSet(SIZE); |
892 |
< |
Object[] o = q.toArray(); |
892 |
> |
Object[] o = q.toArray(); |
893 |
|
Arrays.sort(o); |
894 |
< |
for(int i = 0; i < o.length; i++) |
895 |
< |
assertEquals(o[i], q.pollFirst()); |
894 |
> |
for (int i = 0; i < o.length; i++) |
895 |
> |
assertEquals(o[i], q.pollFirst()); |
896 |
|
} |
897 |
|
|
898 |
|
/** |
900 |
|
*/ |
901 |
|
public void testDescendingToArray2() { |
902 |
|
NavigableSet q = populatedSet(SIZE); |
903 |
< |
Integer[] ints = new Integer[SIZE]; |
904 |
< |
ints = (Integer[])q.toArray(ints); |
903 |
> |
Integer[] ints = new Integer[SIZE]; |
904 |
> |
assertSame(ints, q.toArray(ints)); |
905 |
|
Arrays.sort(ints); |
906 |
< |
for(int i = 0; i < ints.length; i++) |
906 |
> |
for (int i = 0; i < ints.length; i++) |
907 |
|
assertEquals(ints[i], q.pollFirst()); |
908 |
|
} |
909 |
< |
|
909 |
> |
|
910 |
|
/** |
911 |
|
* iterator iterates through all elements |
912 |
|
*/ |
913 |
|
public void testDescendingIterator() { |
914 |
|
NavigableSet q = populatedSet(SIZE); |
915 |
|
int i = 0; |
916 |
< |
Iterator it = q.iterator(); |
917 |
< |
while(it.hasNext()) { |
916 |
> |
Iterator it = q.iterator(); |
917 |
> |
while (it.hasNext()) { |
918 |
|
assertTrue(q.contains(it.next())); |
919 |
|
++i; |
920 |
|
} |
927 |
|
public void testDescendingEmptyIterator() { |
928 |
|
NavigableSet q = dset0(); |
929 |
|
int i = 0; |
930 |
< |
Iterator it = q.iterator(); |
931 |
< |
while(it.hasNext()) { |
930 |
> |
Iterator it = q.iterator(); |
931 |
> |
while (it.hasNext()) { |
932 |
|
assertTrue(q.contains(it.next())); |
933 |
|
++i; |
934 |
|
} |
938 |
|
/** |
939 |
|
* iterator.remove removes current element |
940 |
|
*/ |
941 |
< |
public void testDescendingIteratorRemove () { |
941 |
> |
public void testDescendingIteratorRemove() { |
942 |
|
final NavigableSet q = dset0(); |
943 |
|
q.add(new Integer(2)); |
944 |
|
q.add(new Integer(1)); |
949 |
|
it.remove(); |
950 |
|
|
951 |
|
it = q.iterator(); |
952 |
< |
assertEquals(it.next(), new Integer(2)); |
953 |
< |
assertEquals(it.next(), new Integer(3)); |
952 |
> |
assertEquals(it.next(), 2); |
953 |
> |
assertEquals(it.next(), 3); |
954 |
|
assertFalse(it.hasNext()); |
955 |
|
} |
956 |
|
|
964 |
|
for (int i = 0; i < SIZE; ++i) { |
965 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
966 |
|
} |
967 |
< |
} |
967 |
> |
} |
968 |
|
|
969 |
|
/** |
970 |
< |
* A deserialized serialized set has same elements |
970 |
> |
* A deserialized serialized set has same elements |
971 |
|
*/ |
972 |
< |
public void testDescendingSerialization() { |
972 |
> |
public void testDescendingSerialization() throws Exception { |
973 |
|
NavigableSet q = populatedSet(SIZE); |
974 |
< |
try { |
975 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
976 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
977 |
< |
out.writeObject(q); |
978 |
< |
out.close(); |
979 |
< |
|
980 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
981 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
982 |
< |
NavigableSet r = (NavigableSet)in.readObject(); |
983 |
< |
assertEquals(q.size(), r.size()); |
984 |
< |
while (!q.isEmpty()) |
1014 |
< |
assertEquals(q.pollFirst(), r.pollFirst()); |
1015 |
< |
} catch(Exception e){ |
1016 |
< |
e.printStackTrace(); |
1017 |
< |
unexpectedException(); |
1018 |
< |
} |
974 |
> |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
975 |
> |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
976 |
> |
out.writeObject(q); |
977 |
> |
out.close(); |
978 |
> |
|
979 |
> |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
980 |
> |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
981 |
> |
NavigableSet r = (NavigableSet)in.readObject(); |
982 |
> |
assertEquals(q.size(), r.size()); |
983 |
> |
while (!q.isEmpty()) |
984 |
> |
assertEquals(q.pollFirst(), r.pollFirst()); |
985 |
|
} |
986 |
|
|
987 |
|
/** |