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

Comparing jsr166/src/test/tck/TreeMapTest.java (file contents):
Revision 1.9 by jsr166, Sat Nov 21 02:07:27 2009 UTC vs.
Revision 1.11 by jsr166, Sat Nov 21 17:38:06 2009 UTC

# Line 516 | Line 516 | public class TreeMapTest extends JSR166T
516          try {
517              e.setValue("A");
518              shouldThrow();
519 <        } catch (Exception ok) {
520 <        }
519 >        } catch (UnsupportedOperationException success) {}
520          e = map.pollFirstEntry();
521          assertNull(e);
522      }
# Line 544 | Line 543 | public class TreeMapTest extends JSR166T
543          try {
544              e.setValue("E");
545              shouldThrow();
546 <        } catch (Exception ok) {
548 <        }
546 >        } catch (UnsupportedOperationException success) {}
547          e = map.pollLastEntry();
548          assertNull(e);
549      }
# Line 581 | Line 579 | public class TreeMapTest extends JSR166T
579              TreeMap c = map5();
580              c.get(null);
581              shouldThrow();
582 <        } catch (NullPointerException e) {}
582 >        } catch (NullPointerException success) {}
583      }
584  
585      /**
# Line 592 | Line 590 | public class TreeMapTest extends JSR166T
590              TreeMap c = map5();
591              c.containsKey(null);
592              shouldThrow();
593 <        } catch (NullPointerException e) {}
593 >        } catch (NullPointerException success) {}
594      }
595  
596      /**
# Line 604 | Line 602 | public class TreeMapTest extends JSR166T
602              c.put("sadsdf", "asdads");
603              c.remove(null);
604              shouldThrow();
605 <        } catch (NullPointerException e) {}
605 >        } catch (NullPointerException success) {}
606      }
607  
608      /**
609       * A deserialized map equals original
610       */
611 <    public void testSerialization() {
611 >    public void testSerialization() throws Exception {
612          TreeMap q = map5();
613  
614 <        try {
615 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
616 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
617 <            out.writeObject(q);
618 <            out.close();
619 <
620 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
621 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
622 <            TreeMap r = (TreeMap)in.readObject();
623 <            assertEquals(q.size(), r.size());
624 <            assertTrue(q.equals(r));
627 <            assertTrue(r.equals(q));
628 <        } catch (Exception e) {
629 <            e.printStackTrace();
630 <            unexpectedException();
631 <        }
614 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
615 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
616 >        out.writeObject(q);
617 >        out.close();
618 >
619 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
620 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
621 >        TreeMap r = (TreeMap)in.readObject();
622 >        assertEquals(q.size(), r.size());
623 >        assertTrue(q.equals(r));
624 >        assertTrue(r.equals(q));
625      }
626  
627      /**
# Line 794 | Line 787 | public class TreeMapTest extends JSR166T
787      /**
788       * Submaps of submaps subdivide correctly
789       */
790 <    public void testRecursiveSubMaps() {
790 >    public void testRecursiveSubMaps() throws Exception {
791          int mapSize = 1000;
792          Class cl = TreeMap.class;
793          NavigableMap<Integer, Integer> map = newMap(cl);
# Line 812 | Line 805 | public class TreeMapTest extends JSR166T
805                     0, mapSize - 1, true);
806      }
807  
808 <    static NavigableMap<Integer, Integer> newMap(Class cl) {
809 <        NavigableMap<Integer, Integer> result = null;
810 <        try {
818 <            result = (NavigableMap<Integer, Integer>) cl.newInstance();
819 <        } catch (Exception e) {
820 <            fail();
821 <        }
808 >    static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception {
809 >        NavigableMap<Integer, Integer> result
810 >            = (NavigableMap<Integer, Integer>) cl.newInstance();
811          assertEquals(result.size(), 0);
812          assertFalse(result.keySet().iterator().hasNext());
813          return result;
# Line 881 | Line 870 | public class TreeMapTest extends JSR166T
870              } else {
871                  try {
872                      map.put(key, 2 * key);
873 <                    fail();
874 <                } catch (IllegalArgumentException e) {
886 <                    // expected
887 <                }
873 >                    shouldThrow();
874 >                } catch (IllegalArgumentException success) {}
875              }
876          }
877      }
# Line 1079 | Line 1066 | public class TreeMapTest extends JSR166T
1066              assertEq(rs.last(),  -1);
1067              try {
1068                  map.firstKey();
1069 <                fail();
1070 <            } catch (NoSuchElementException e) {
1084 <                // expected
1085 <            }
1069 >                shouldThrow();
1070 >            } catch (NoSuchElementException success) {}
1071              try {
1072                  map.lastKey();
1073 <                fail();
1074 <            } catch (NoSuchElementException e) {
1090 <                // expected
1091 <            }
1073 >                shouldThrow();
1074 >            } catch (NoSuchElementException success) {}
1075          }
1076      }
1077  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines