--- jsr166/src/test/tck/ConcurrentSkipListMapTest.java 2009/11/21 10:25:05 1.13 +++ jsr166/src/test/tck/ConcurrentSkipListMapTest.java 2009/12/01 09:48:13 1.16 @@ -427,7 +427,6 @@ public class ConcurrentSkipListMapTest e map.remove(four, "A"); assertEquals(4, map.size()); assertTrue(map.containsKey(four)); - } /** @@ -446,7 +445,6 @@ public class ConcurrentSkipListMapTest e Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); - } /** @@ -465,7 +463,6 @@ public class ConcurrentSkipListMapTest e Map.Entry e4 = map.higherEntry(six); assertNull(e4); - } /** @@ -484,7 +481,6 @@ public class ConcurrentSkipListMapTest e Map.Entry e4 = map.floorEntry(zero); assertNull(e4); - } /** @@ -503,7 +499,6 @@ public class ConcurrentSkipListMapTest e Map.Entry e4 = map.ceilingEntry(six); assertNull(e4); - } /** @@ -516,25 +511,25 @@ public class ConcurrentSkipListMapTest e assertEquals(two, e.getKey()); try { e.setValue("X"); - fail(); + shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.higherEntry(zero); assertEquals(one, e.getKey()); try { e.setValue("X"); - fail(); + shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.floorEntry(one); assertEquals(one, e.getKey()); try { e.setValue("X"); - fail(); + shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.ceilingEntry(five); assertEquals(five, e.getKey()); try { e.setValue("X"); - fail(); + shouldThrow(); } catch (UnsupportedOperationException success) {} } @@ -556,7 +551,6 @@ public class ConcurrentSkipListMapTest e Object e4 = q.lowerKey(zero); assertNull(e4); - } /** @@ -575,7 +569,6 @@ public class ConcurrentSkipListMapTest e Object e4 = q.higherKey(six); assertNull(e4); - } /** @@ -594,7 +587,6 @@ public class ConcurrentSkipListMapTest e Object e4 = q.floorKey(zero); assertNull(e4); - } /** @@ -613,7 +605,6 @@ public class ConcurrentSkipListMapTest e Object e4 = q.ceilingKey(six); assertNull(e4); - } /** @@ -638,8 +629,7 @@ public class ConcurrentSkipListMapTest e try { e.setValue("A"); shouldThrow(); - } catch (Exception ok) { - } + } catch (UnsupportedOperationException success) {} e = map.pollFirstEntry(); assertNull(e); } @@ -666,8 +656,7 @@ public class ConcurrentSkipListMapTest e try { e.setValue("E"); shouldThrow(); - } catch (Exception ok) { - } + } catch (UnsupportedOperationException success) {} e = map.pollLastEntry(); assertNull(e); } @@ -703,7 +692,7 @@ public class ConcurrentSkipListMapTest e ConcurrentSkipListMap c = map5(); c.get(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -714,7 +703,7 @@ public class ConcurrentSkipListMapTest e ConcurrentSkipListMap c = map5(); c.containsKey(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -725,7 +714,7 @@ public class ConcurrentSkipListMapTest e ConcurrentSkipListMap c = new ConcurrentSkipListMap(); c.containsValue(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } @@ -737,7 +726,7 @@ public class ConcurrentSkipListMapTest e ConcurrentSkipListMap c = map5(); c.put(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -748,7 +737,7 @@ public class ConcurrentSkipListMapTest e ConcurrentSkipListMap c = map5(); c.putIfAbsent(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -759,7 +748,7 @@ public class ConcurrentSkipListMapTest e ConcurrentSkipListMap c = map5(); c.replace(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -770,7 +759,7 @@ public class ConcurrentSkipListMapTest e ConcurrentSkipListMap c = map5(); c.replace(null, one, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -782,7 +771,7 @@ public class ConcurrentSkipListMapTest e c.put("sadsdf", "asdads"); c.remove(null); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** @@ -794,20 +783,16 @@ public class ConcurrentSkipListMapTest e c.put("sadsdf", "asdads"); c.remove(null, "whatever"); shouldThrow(); - } catch (NullPointerException e) {} + } catch (NullPointerException success) {} } /** * remove(x, null) returns false */ public void testRemove3() { - try { - ConcurrentSkipListMap c = new ConcurrentSkipListMap(); - c.put("sadsdf", "asdads"); - assertFalse(c.remove("sadsdf", null)); - } catch (NullPointerException e) { - fail(); - } + ConcurrentSkipListMap c = new ConcurrentSkipListMap(); + c.put("sadsdf", "asdads"); + assertFalse(c.remove("sadsdf", null)); } /** @@ -867,7 +852,7 @@ public class ConcurrentSkipListMapTest e assertEquals(1, sm.size()); assertEquals(three, sm.firstKey()); assertEquals(three, sm.lastKey()); - assertTrue(sm.remove(three) != null); + assertEquals("C", sm.remove(three)); assertTrue(sm.isEmpty()); assertEquals(3, map.size()); } @@ -900,7 +885,7 @@ public class ConcurrentSkipListMapTest e assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); - assertTrue(sm.remove(three) == null); + assertSame(sm.remove(three), null); assertEquals(4, map.size()); } @@ -982,7 +967,7 @@ public class ConcurrentSkipListMapTest e NavigableMap ssm = sm.tailMap(four, true); assertEquals(four, ssm.firstKey()); assertEquals(five, ssm.lastKey()); - assertTrue(ssm.remove(four) != null); + assertEquals("D", ssm.remove(four)); assertEquals(1, ssm.size()); assertEquals(3, sm.size()); assertEquals(4, map.size()); @@ -994,7 +979,7 @@ public class ConcurrentSkipListMapTest e /** * Submaps of submaps subdivide correctly */ - public void testRecursiveSubMaps() { + public void testRecursiveSubMaps() throws Exception { int mapSize = 1000; Class cl = ConcurrentSkipListMap.class; NavigableMap map = newMap(cl); @@ -1012,13 +997,9 @@ public class ConcurrentSkipListMapTest e 0, mapSize - 1, true); } - static NavigableMap newMap(Class cl) { - NavigableMap result = null; - try { - result = (NavigableMap) cl.newInstance(); - } catch (Exception e) { - fail(); - } + static NavigableMap newMap(Class cl) throws Exception { + NavigableMap result = + (NavigableMap) cl.newInstance(); assertEquals(result.size(), 0); assertFalse(result.keySet().iterator().hasNext()); return result; @@ -1081,10 +1062,8 @@ public class ConcurrentSkipListMapTest e } else { try { map.put(key, 2 * key); - fail(); - } catch (IllegalArgumentException e) { - // expected - } + shouldThrow(); + } catch (IllegalArgumentException success) {} } } } @@ -1279,16 +1258,12 @@ public class ConcurrentSkipListMapTest e assertEq(rs.last(), -1); try { map.firstKey(); - fail(); - } catch (NoSuchElementException e) { - // expected - } + shouldThrow(); + } catch (NoSuchElementException success) {} try { map.lastKey(); - fail(); - } catch (NoSuchElementException e) { - // expected - } + shouldThrow(); + } catch (NoSuchElementException success) {} } }