ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/TreeSubSetTest.java
(Generate patch)

Comparing jsr166/src/test/tck/TreeSubSetTest.java (file contents):
Revision 1.6 by jsr166, Mon Nov 16 05:30:08 2009 UTC vs.
Revision 1.7 by jsr166, Fri Nov 20 06:47:13 2009 UTC

# Line 135 | Line 135 | public class TreeSubSetTest extends JSR1
135              NavigableSet q = set0();
136              q.add(null);
137              shouldThrow();
138 <        } catch (NullPointerException success) { }
138 >        } catch (NullPointerException success) {}
139      }
140  
141      /**
# Line 165 | Line 165 | public class TreeSubSetTest extends JSR1
165              q.add(new Object());
166              q.add(new Object());
167              shouldThrow();
168 <        }
169 <        catch (ClassCastException success) {}
168 >        } catch (ClassCastException success) {}
169      }
170  
171  
# Line 178 | Line 177 | public class TreeSubSetTest extends JSR1
177              NavigableSet q = set0();
178              q.addAll(null);
179              shouldThrow();
180 <        }
182 <        catch (NullPointerException success) {}
180 >        } catch (NullPointerException success) {}
181      }
182      /**
183       * addAll of a collection with null elements throws NPE
# Line 190 | Line 188 | public class TreeSubSetTest extends JSR1
188              Integer[] ints = new Integer[SIZE];
189              q.addAll(Arrays.asList(ints));
190              shouldThrow();
191 <        }
194 <        catch (NullPointerException success) {}
191 >        } catch (NullPointerException success) {}
192      }
193      /**
194       * addAll of a collection with any null elements throws NPE after
# Line 205 | Line 202 | public class TreeSubSetTest extends JSR1
202                  ints[i] = new Integer(i+SIZE);
203              q.addAll(Arrays.asList(ints));
204              shouldThrow();
205 <        }
209 <        catch (NullPointerException success) {}
205 >        } catch (NullPointerException success) {}
206      }
207  
208      /**
# Line 491 | Line 487 | public class TreeSubSetTest extends JSR1
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())
507 <                assertEquals(q.pollFirst(), r.pollFirst());
508 <        } catch (Exception e) {
509 <            e.printStackTrace();
510 <            unexpectedException();
511 <        }
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      /**
# Line 672 | Line 663 | public class TreeSubSetTest extends JSR1
663              q.add(new Object());
664              q.add(new Object());
665              shouldThrow();
666 <        }
676 <        catch (ClassCastException success) {}
666 >        } catch (ClassCastException success) {}
667      }
668  
669  
# Line 685 | Line 675 | public class TreeSubSetTest extends JSR1
675              NavigableSet q = dset0();
676              q.addAll(null);
677              shouldThrow();
678 <        }
689 <        catch (NullPointerException success) {}
678 >        } catch (NullPointerException success) {}
679      }
680      /**
681       * addAll of a collection with null elements throws NPE
# Line 697 | Line 686 | public class TreeSubSetTest extends JSR1
686              Integer[] ints = new Integer[SIZE];
687              q.addAll(Arrays.asList(ints));
688              shouldThrow();
689 <        }
701 <        catch (NullPointerException success) {}
689 >        } catch (NullPointerException success) {}
690      }
691      /**
692       * addAll of a collection with any null elements throws NPE after
# Line 712 | Line 700 | public class TreeSubSetTest extends JSR1
700                  ints[i] = new Integer(i+SIZE);
701              q.addAll(Arrays.asList(ints));
702              shouldThrow();
703 <        }
716 <        catch (NullPointerException success) {}
703 >        } catch (NullPointerException success) {}
704      }
705  
706      /**
707       * Set contains all elements of successful addAll
708       */
709      public void testDescendingAddAll5() {
710 <        try {
711 <            Integer[] empty = new Integer[0];
712 <            Integer[] ints = new Integer[SIZE];
713 <            for (int i = 0; i < SIZE; ++i)
714 <                ints[i] = new Integer(SIZE-1- i);
715 <            NavigableSet q = dset0();
716 <            assertFalse(q.addAll(Arrays.asList(empty)));
717 <            assertTrue(q.addAll(Arrays.asList(ints)));
718 <            for (int i = 0; i < SIZE; ++i)
732 <                assertEquals(new Integer(i), q.pollFirst());
733 <        }
734 <        finally {}
710 >        Integer[] empty = new Integer[0];
711 >        Integer[] ints = new Integer[SIZE];
712 >        for (int i = 0; i < SIZE; ++i)
713 >            ints[i] = new Integer(SIZE-1- i);
714 >        NavigableSet q = dset0();
715 >        assertFalse(q.addAll(Arrays.asList(empty)));
716 >        assertTrue(q.addAll(Arrays.asList(ints)));
717 >        for (int i = 0; i < SIZE; ++i)
718 >            assertEquals(new Integer(i), q.pollFirst());
719      }
720  
721      /**
# Line 998 | Line 982 | public class TreeSubSetTest extends JSR1
982      /**
983       * A deserialized serialized set has same elements
984       */
985 <    public void testDescendingSerialization() {
985 >    public void testDescendingSerialization() throws Exception {
986          NavigableSet q = populatedSet(SIZE);
987 <        try {
988 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
989 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
990 <            out.writeObject(q);
991 <            out.close();
992 <
993 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
994 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
995 <            NavigableSet r = (NavigableSet)in.readObject();
996 <            assertEquals(q.size(), r.size());
997 <            while (!q.isEmpty())
1014 <                assertEquals(q.pollFirst(), r.pollFirst());
1015 <        } catch (Exception e) {
1016 <            e.printStackTrace();
1017 <            unexpectedException();
1018 <        }
987 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
988 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
989 >        out.writeObject(q);
990 >        out.close();
991 >
992 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
993 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
994 >        NavigableSet r = (NavigableSet)in.readObject();
995 >        assertEquals(q.size(), r.size());
996 >        while (!q.isEmpty())
997 >            assertEquals(q.pollFirst(), r.pollFirst());
998      }
999  
1000      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines