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

Comparing jsr166/src/test/tck/CopyOnWriteArrayListTest.java (file contents):
Revision 1.11 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.14 by jsr166, Sun Nov 22 18:57:17 2009 UTC

# Line 189 | Line 189 | public class CopyOnWriteArrayListTest ex
189      }
190  
191      /**
192 <     *   get returns the  value at the given index
192 >     *   get returns the value at the given index
193       */
194      public void testGet() {
195          CopyOnWriteArrayList full = populatedArray(3);
196 <        assertEquals(0, ((Integer)full.get(0)).intValue());
196 >        assertEquals(0, full.get(0));
197      }
198  
199      /**
# Line 233 | Line 233 | public class CopyOnWriteArrayListTest ex
233          Iterator i = full.iterator();
234          int j;
235          for (j = 0; i.hasNext(); j++)
236 <            assertEquals(j, ((Integer)i.next()).intValue());
236 >            assertEquals(j, i.next());
237          assertEquals(SIZE, j);
238      }
239  
# Line 247 | Line 247 | public class CopyOnWriteArrayListTest ex
247          try {
248              it.remove();
249              shouldThrow();
250 <        }
251 <        catch (UnsupportedOperationException success) {}
250 >        } catch (UnsupportedOperationException success) {}
251      }
252  
253      /**
# Line 292 | Line 291 | public class CopyOnWriteArrayListTest ex
291          ListIterator i = full.listIterator();
292          int j;
293          for (j = 0; i.hasNext(); j++)
294 <            assertEquals(j, ((Integer)i.next()).intValue());
294 >            assertEquals(j, i.next());
295          assertEquals(SIZE, j);
296      }
297  
# Line 304 | Line 303 | public class CopyOnWriteArrayListTest ex
303          ListIterator i = full.listIterator(1);
304          int j;
305          for (j = 0; i.hasNext(); j++)
306 <            assertEquals(j+1, ((Integer)i.next()).intValue());
306 >            assertEquals(j+1, i.next());
307          assertEquals(2, j);
308      }
309  
# Line 335 | Line 334 | public class CopyOnWriteArrayListTest ex
334      public void testSet() {
335          CopyOnWriteArrayList full = populatedArray(3);
336          assertEquals(two, full.set(2, four));
337 <        assertEquals(4, ((Integer)full.get(2)).intValue());
337 >        assertEquals(4, full.get(2));
338      }
339  
340      /**
# Line 355 | Line 354 | public class CopyOnWriteArrayListTest ex
354          CopyOnWriteArrayList full = populatedArray(3);
355          Object[] o = full.toArray();
356          assertEquals(3, o.length);
357 <        assertEquals(0, ((Integer)o[0]).intValue());
358 <        assertEquals(1, ((Integer)o[1]).intValue());
359 <        assertEquals(2, ((Integer)o[2]).intValue());
357 >        assertEquals(0, o[0]);
358 >        assertEquals(1, o[1]);
359 >        assertEquals(2, o[2]);
360      }
361  
362      /**
# Line 411 | Line 410 | public class CopyOnWriteArrayListTest ex
410              c.add("asdadasd");
411              c.toArray(new Long[5]);
412              shouldThrow();
413 <        } catch (ArrayStoreException e) {}
413 >        } catch (ArrayStoreException success) {}
414      }
415  
416      /**
# Line 422 | Line 421 | public class CopyOnWriteArrayListTest ex
421              CopyOnWriteArrayList c = new CopyOnWriteArrayList();
422              c.get(-1);
423              shouldThrow();
424 <        } catch (IndexOutOfBoundsException e) {}
424 >        } catch (IndexOutOfBoundsException success) {}
425      }
426  
427      /**
# Line 435 | Line 434 | public class CopyOnWriteArrayListTest ex
434              c.add("asdad");
435              c.get(100);
436              shouldThrow();
437 <        } catch (IndexOutOfBoundsException e) {}
437 >        } catch (IndexOutOfBoundsException success) {}
438      }
439  
440      /**
# Line 446 | Line 445 | public class CopyOnWriteArrayListTest ex
445              CopyOnWriteArrayList c = new CopyOnWriteArrayList();
446              c.set(-1,"qwerty");
447              shouldThrow();
448 <        } catch (IndexOutOfBoundsException e) {}
448 >        } catch (IndexOutOfBoundsException success) {}
449      }
450  
451      /**
# Line 459 | Line 458 | public class CopyOnWriteArrayListTest ex
458              c.add("asdad");
459              c.set(100, "qwerty");
460              shouldThrow();
461 <        } catch (IndexOutOfBoundsException e) {}
461 >        } catch (IndexOutOfBoundsException success) {}
462      }
463  
464      /**
# Line 470 | Line 469 | public class CopyOnWriteArrayListTest ex
469              CopyOnWriteArrayList c = new CopyOnWriteArrayList();
470              c.add(-1,"qwerty");
471              shouldThrow();
472 <        } catch (IndexOutOfBoundsException e) {}
472 >        } catch (IndexOutOfBoundsException success) {}
473      }
474  
475      /**
# Line 483 | Line 482 | public class CopyOnWriteArrayListTest ex
482              c.add("asdasdasd");
483              c.add(100, "qwerty");
484              shouldThrow();
485 <        } catch (IndexOutOfBoundsException e) {}
485 >        } catch (IndexOutOfBoundsException success) {}
486      }
487  
488      /**
# Line 494 | Line 493 | public class CopyOnWriteArrayListTest ex
493              CopyOnWriteArrayList c = new CopyOnWriteArrayList();
494              c.remove(-1);
495              shouldThrow();
496 <        } catch (IndexOutOfBoundsException e) {}
496 >        } catch (IndexOutOfBoundsException success) {}
497      }
498  
499      /**
# Line 507 | Line 506 | public class CopyOnWriteArrayListTest ex
506              c.add("adasdasd");
507              c.remove(100);
508              shouldThrow();
509 <        } catch (IndexOutOfBoundsException e) {}
509 >        } catch (IndexOutOfBoundsException success) {}
510      }
511  
512      /**
# Line 518 | Line 517 | public class CopyOnWriteArrayListTest ex
517              CopyOnWriteArrayList c = new CopyOnWriteArrayList();
518              c.addAll(-1,new LinkedList());
519              shouldThrow();
520 <        } catch (IndexOutOfBoundsException e) {}
520 >        } catch (IndexOutOfBoundsException success) {}
521      }
522  
523      /**
# Line 531 | Line 530 | public class CopyOnWriteArrayListTest ex
530              c.add("asdasdasd");
531              c.addAll(100, new LinkedList());
532              shouldThrow();
533 <        } catch (IndexOutOfBoundsException e) {}
533 >        } catch (IndexOutOfBoundsException success) {}
534      }
535  
536      /**
# Line 542 | Line 541 | public class CopyOnWriteArrayListTest ex
541              CopyOnWriteArrayList c = new CopyOnWriteArrayList();
542              c.listIterator(-1);
543              shouldThrow();
544 <        } catch (IndexOutOfBoundsException e) {}
544 >        } catch (IndexOutOfBoundsException success) {}
545      }
546  
547      /**
# Line 555 | Line 554 | public class CopyOnWriteArrayListTest ex
554              c.add("asdasdas");
555              c.listIterator(100);
556              shouldThrow();
557 <        } catch (IndexOutOfBoundsException e) {}
557 >        } catch (IndexOutOfBoundsException success) {}
558      }
559  
560      /**
# Line 565 | Line 564 | public class CopyOnWriteArrayListTest ex
564          try {
565              CopyOnWriteArrayList c = new CopyOnWriteArrayList();
566              c.subList(-1,100);
568
567              shouldThrow();
568 <        } catch (IndexOutOfBoundsException e) {}
568 >        } catch (IndexOutOfBoundsException success) {}
569      }
570  
571      /**
# Line 579 | Line 577 | public class CopyOnWriteArrayListTest ex
577              c.add("asdasd");
578              c.subList(1,100);
579              shouldThrow();
580 <        } catch (IndexOutOfBoundsException e) {}
580 >        } catch (IndexOutOfBoundsException success) {}
581      }
582  
583      /**
# Line 590 | Line 588 | public class CopyOnWriteArrayListTest ex
588          try {
589              CopyOnWriteArrayList c = new CopyOnWriteArrayList();
590              c.subList(3,1);
593
591              shouldThrow();
592 <        } catch (IndexOutOfBoundsException e) {}
592 >        } catch (IndexOutOfBoundsException success) {}
593      }
594  
595      /**
596       * a deserialized serialiszed list is equal
597       */
598 <    public void testSerialization() {
598 >    public void testSerialization() throws Exception {
599          CopyOnWriteArrayList q = populatedArray(SIZE);
600  
601 <        try {
602 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
603 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
604 <            out.writeObject(q);
605 <            out.close();
606 <
607 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
608 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
609 <            CopyOnWriteArrayList r = (CopyOnWriteArrayList)in.readObject();
610 <            assertEquals(q.size(), r.size());
611 <            assertTrue(q.equals(r));
615 <            assertTrue(r.equals(q));
616 <        } catch (Exception e) {
617 <            unexpectedException();
618 <        }
601 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
602 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
603 >        out.writeObject(q);
604 >        out.close();
605 >
606 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
607 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
608 >        CopyOnWriteArrayList r = (CopyOnWriteArrayList)in.readObject();
609 >        assertEquals(q.size(), r.size());
610 >        assertTrue(q.equals(r));
611 >        assertTrue(r.equals(q));
612      }
613  
614   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines