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

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

# Line 328 | Line 328 | public class TreeSubMapTest extends JSR1
328          try {
329              e.setValue("A");
330              shouldThrow();
331 <        } catch (Exception ok) {
332 <        }
331 >        } catch (UnsupportedOperationException success) {}
332          assertTrue(map.isEmpty());
333          Map.Entry f = map.firstEntry();
334          assertNull(f);
# Line 359 | Line 358 | public class TreeSubMapTest extends JSR1
358          try {
359              e.setValue("E");
360              shouldThrow();
361 <        } catch (Exception ok) {
363 <        }
361 >        } catch (UnsupportedOperationException success) {}
362          e = map.pollLastEntry();
363          assertNull(e);
364      }
# Line 396 | Line 394 | public class TreeSubMapTest extends JSR1
394              NavigableMap c = map5();
395              c.get(null);
396              shouldThrow();
397 <        } catch (NullPointerException e) {}
397 >        } catch (NullPointerException success) {}
398      }
399  
400      /**
# Line 407 | Line 405 | public class TreeSubMapTest extends JSR1
405              NavigableMap c = map5();
406              c.containsKey(null);
407              shouldThrow();
408 <        } catch (NullPointerException e) {}
408 >        } catch (NullPointerException success) {}
409      }
410  
411      /**
# Line 418 | Line 416 | public class TreeSubMapTest extends JSR1
416              NavigableMap c = map5();
417              c.put(null, "whatever");
418              shouldThrow();
419 <        } catch (NullPointerException e) {}
419 >        } catch (NullPointerException success) {}
420      }
421  
422      /**
# Line 429 | Line 427 | public class TreeSubMapTest extends JSR1
427              NavigableMap c = map5();
428              c.remove(null);
429              shouldThrow();
430 <        } catch (NullPointerException e) {}
430 >        } catch (NullPointerException success) {}
431      }
432  
433      /**
434       * A deserialized map equals original
435       */
436 <    public void testSerialization() {
436 >    public void testSerialization() throws Exception {
437          NavigableMap q = map5();
438  
439 <        try {
440 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
441 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
442 <            out.writeObject(q);
443 <            out.close();
444 <
445 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
446 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
447 <            NavigableMap r = (NavigableMap)in.readObject();
448 <            assertFalse(r.isEmpty());
449 <            assertEquals(q.size(), r.size());
450 <            assertTrue(q.equals(r));
453 <            assertTrue(r.equals(q));
454 <        } catch (Exception e) {
455 <            e.printStackTrace();
456 <            unexpectedException();
457 <        }
439 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
440 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
441 >        out.writeObject(q);
442 >        out.close();
443 >
444 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
445 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
446 >        NavigableMap r = (NavigableMap)in.readObject();
447 >        assertFalse(r.isEmpty());
448 >        assertEquals(q.size(), r.size());
449 >        assertTrue(q.equals(r));
450 >        assertTrue(r.equals(q));
451      }
452  
453  
# Line 903 | Line 896 | public class TreeSubMapTest extends JSR1
896          try {
897              e.setValue("A");
898              shouldThrow();
899 <        } catch (Exception ok) {
907 <        }
899 >        } catch (UnsupportedOperationException success) {}
900          e = map.pollFirstEntry();
901          assertNull(e);
902      }
# Line 931 | Line 923 | public class TreeSubMapTest extends JSR1
923          try {
924              e.setValue("E");
925              shouldThrow();
926 <        } catch (Exception ok) {
935 <        }
926 >        } catch (UnsupportedOperationException success) {}
927          e = map.pollLastEntry();
928          assertNull(e);
929      }
# Line 968 | Line 959 | public class TreeSubMapTest extends JSR1
959              NavigableMap c = dmap5();
960              c.get(null);
961              shouldThrow();
962 <        } catch (NullPointerException e) {}
962 >        } catch (NullPointerException success) {}
963      }
964  
965      /**
# Line 979 | Line 970 | public class TreeSubMapTest extends JSR1
970              NavigableMap c = dmap5();
971              c.put(null, "whatever");
972              shouldThrow();
973 <        } catch (NullPointerException e) {}
973 >        } catch (NullPointerException success) {}
974      }
975  
976      /**
977       * A deserialized map equals original
978       */
979 <    public void testDescendingSerialization() {
979 >    public void testDescendingSerialization() throws Exception {
980          NavigableMap q = dmap5();
981  
982 <        try {
983 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
984 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
985 <            out.writeObject(q);
986 <            out.close();
987 <
988 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
989 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
990 <            NavigableMap r = (NavigableMap)in.readObject();
991 <            assertEquals(q.size(), r.size());
992 <            assertTrue(q.equals(r));
1002 <            assertTrue(r.equals(q));
1003 <        } catch (Exception e) {
1004 <            e.printStackTrace();
1005 <            unexpectedException();
1006 <        }
982 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
983 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
984 >        out.writeObject(q);
985 >        out.close();
986 >
987 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
988 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
989 >        NavigableMap r = (NavigableMap)in.readObject();
990 >        assertEquals(q.size(), r.size());
991 >        assertTrue(q.equals(r));
992 >        assertTrue(r.equals(q));
993      }
994  
995  
1010
996      /**
997       * subMap returns map with keys in requested range
998       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines