--- jsr166/src/test/tck/CopyOnWriteArrayListTest.java 2009/11/21 02:07:26 1.11 +++ jsr166/src/test/tck/CopyOnWriteArrayListTest.java 2009/11/21 17:38:05 1.13 @@ -189,7 +189,7 @@ public class CopyOnWriteArrayListTest ex } /** - * get returns the value at the given index + * get returns the value at the given index */ public void testGet() { CopyOnWriteArrayList full = populatedArray(3); @@ -247,8 +247,7 @@ public class CopyOnWriteArrayListTest ex try { it.remove(); shouldThrow(); - } - catch (UnsupportedOperationException success) {} + } catch (UnsupportedOperationException success) {} } /** @@ -411,7 +410,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdadasd"); c.toArray(new Long[5]); shouldThrow(); - } catch (ArrayStoreException e) {} + } catch (ArrayStoreException success) {} } /** @@ -422,7 +421,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.get(-1); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -435,7 +434,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdad"); c.get(100); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -446,7 +445,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.set(-1,"qwerty"); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -459,7 +458,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdad"); c.set(100, "qwerty"); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -470,7 +469,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.add(-1,"qwerty"); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -483,7 +482,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdasdasd"); c.add(100, "qwerty"); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -494,7 +493,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.remove(-1); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -507,7 +506,7 @@ public class CopyOnWriteArrayListTest ex c.add("adasdasd"); c.remove(100); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -518,7 +517,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.addAll(-1,new LinkedList()); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -531,7 +530,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdasdasd"); c.addAll(100, new LinkedList()); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -542,7 +541,7 @@ public class CopyOnWriteArrayListTest ex CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.listIterator(-1); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -555,7 +554,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdasdas"); c.listIterator(100); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -565,9 +564,8 @@ public class CopyOnWriteArrayListTest ex try { CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.subList(-1,100); - shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -579,7 +577,7 @@ public class CopyOnWriteArrayListTest ex c.add("asdasd"); c.subList(1,100); shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** @@ -590,32 +588,27 @@ public class CopyOnWriteArrayListTest ex try { CopyOnWriteArrayList c = new CopyOnWriteArrayList(); c.subList(3,1); - shouldThrow(); - } catch (IndexOutOfBoundsException e) {} + } catch (IndexOutOfBoundsException success) {} } /** * a deserialized serialiszed list is equal */ - public void testSerialization() { + public void testSerialization() throws Exception { CopyOnWriteArrayList q = populatedArray(SIZE); - 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)); - CopyOnWriteArrayList r = (CopyOnWriteArrayList)in.readObject(); - assertEquals(q.size(), r.size()); - assertTrue(q.equals(r)); - assertTrue(r.equals(q)); - } catch (Exception e) { - 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)); + CopyOnWriteArrayList r = (CopyOnWriteArrayList)in.readObject(); + assertEquals(q.size(), r.size()); + assertTrue(q.equals(r)); + assertTrue(r.equals(q)); } }