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.10 by jsr166, Tue Dec 1 06:03:49 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 488 | Line 481 | public class TreeSubMapTest extends JSR1
481          assertEquals(1, sm.size());
482          assertEquals(three, sm.firstKey());
483          assertEquals(three, sm.lastKey());
484 <        assertTrue(sm.remove(three) != null);
484 >        assertEquals("C", sm.remove(three));
485          assertTrue(sm.isEmpty());
486          assertEquals(3, map.size());
487      }
# Line 516 | Line 509 | public class TreeSubMapTest extends JSR1
509          assertEquals(4, map.size());
510          assertEquals(0, sm.size());
511          assertTrue(sm.isEmpty());
512 <        assertTrue(sm.remove(three) == null);
512 >        assertSame(sm.remove(three), null);
513          assertEquals(4, map.size());
514      }
515  
# Line 588 | Line 581 | public class TreeSubMapTest extends JSR1
581          SortedMap ssm = sm.tailMap(four);
582          assertEquals(four, ssm.firstKey());
583          assertEquals(five, ssm.lastKey());
584 <        assertTrue(ssm.remove(four) != null);
584 >        assertEquals("D", ssm.remove(four));
585          assertEquals(1, ssm.size());
586          assertEquals(3, sm.size());
587          assertEquals(4, map.size());
# 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       */
# Line 1037 | Line 1022 | public class TreeSubMapTest extends JSR1
1022          assertEquals(1, sm.size());
1023          assertEquals(m3, sm.firstKey());
1024          assertEquals(m3, sm.lastKey());
1025 <        assertTrue(sm.remove(m3) != null);
1025 >        assertEquals("C", sm.remove(m3));
1026          assertTrue(sm.isEmpty());
1027          assertEquals(3, map.size());
1028      }
# Line 1065 | Line 1050 | public class TreeSubMapTest extends JSR1
1050          assertEquals(4, map.size());
1051          assertEquals(0, sm.size());
1052          assertTrue(sm.isEmpty());
1053 <        assertTrue(sm.remove(m3) == null);
1053 >        assertSame(sm.remove(m3), null);
1054          assertEquals(4, map.size());
1055      }
1056  
# Line 1137 | Line 1122 | public class TreeSubMapTest extends JSR1
1122          SortedMap ssm = sm.tailMap(m4);
1123          assertEquals(m4, ssm.firstKey());
1124          assertEquals(m5, ssm.lastKey());
1125 <        assertTrue(ssm.remove(m4) != null);
1125 >        assertEquals("D", ssm.remove(m4));
1126          assertEquals(1, ssm.size());
1127          assertEquals(3, sm.size());
1128          assertEquals(4, map.size());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines