--- jsr166/src/test/tck/ConcurrentSkipListSubMapTest.java 2009/11/21 02:07:26 1.9 +++ jsr166/src/test/tck/ConcurrentSkipListSubMapTest.java 2009/11/21 17:38:05 1.11 @@ -444,8 +444,7 @@ public class ConcurrentSkipListSubMapTes try { e.setValue("A"); shouldThrow(); - } catch (Exception ok) { - } + } catch (UnsupportedOperationException success) {} e = map.pollFirstEntry(); assertNull(e); } @@ -472,8 +471,7 @@ public class ConcurrentSkipListSubMapTes try { e.setValue("E"); shouldThrow(); - } catch (Exception ok) { - } + } catch (UnsupportedOperationException success) {} e = map.pollLastEntry(); assertNull(e); } @@ -509,7 +507,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map5(); c.get(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -520,7 +518,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map5(); c.containsKey(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -531,7 +529,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map0(); c.containsValue(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } @@ -543,7 +541,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map5(); c.put(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -554,7 +552,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map5(); c.putIfAbsent(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -565,7 +563,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map5(); c.replace(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -576,7 +574,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map5(); c.replace(null, one, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -587,7 +585,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map5(); c.remove(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -598,31 +596,26 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = map5(); c.remove(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** * A deserialized map equals original */ - public void testSerialization() { + public void testSerialization() throws Exception { ConcurrentNavigableMap q = map5(); - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject(); - assertEquals(q.size(), r.size()); - assertTrue(q.equals(r)); - assertTrue(r.equals(q)); - } catch (Exception e) { - e.printStackTrace(); - unexpectedException(); - } + ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); + ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); + out.writeObject(q); + out.close(); + + ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); + ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); + ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject(); + assertEquals(q.size(), r.size()); + assertTrue(q.equals(r)); + assertTrue(r.equals(q)); } @@ -1143,8 +1136,7 @@ public class ConcurrentSkipListSubMapTes try { e.setValue("A"); shouldThrow(); - } catch (Exception ok) { - } + } catch (UnsupportedOperationException success) {} e = map.pollFirstEntry(); assertNull(e); } @@ -1171,8 +1163,7 @@ public class ConcurrentSkipListSubMapTes try { e.setValue("E"); shouldThrow(); - } catch (Exception ok) { - } + } catch (UnsupportedOperationException success) {} e = map.pollLastEntry(); assertNull(e); } @@ -1208,7 +1199,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap5(); c.get(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -1219,7 +1210,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap5(); c.containsKey(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -1230,7 +1221,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap0(); c.containsValue(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } @@ -1242,7 +1233,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap5(); c.put(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -1253,7 +1244,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap5(); c.putIfAbsent(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -1264,7 +1255,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap5(); c.replace(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -1275,7 +1266,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap5(); c.replace(null, m1, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -1286,7 +1277,7 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap5(); c.remove(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -1297,35 +1288,29 @@ public class ConcurrentSkipListSubMapTes ConcurrentNavigableMap c = dmap5(); c.remove(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** * A deserialized map equals original */ - public void testDescendingSerialization() { + public void testDescendingSerialization() throws Exception { ConcurrentNavigableMap q = dmap5(); - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject(); - assertEquals(q.size(), r.size()); - assertTrue(q.equals(r)); - assertTrue(r.equals(q)); - } catch (Exception e) { - e.printStackTrace(); - unexpectedException(); - } + ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); + ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); + out.writeObject(q); + out.close(); + + ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); + ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); + ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject(); + assertEquals(q.size(), r.size()); + assertTrue(q.equals(r)); + assertTrue(r.equals(q)); } - /** * subMap returns map with keys in requested range */