Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 70   Methods: 5
NCLOC: 48   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CopyOnWriteArrayTest.java 75% 92% 80% 88.2%
coverage coverage
 1    package org.jboss.cache.misc;
 2   
 3    import junit.framework.Test;
 4    import junit.framework.TestCase;
 5    import junit.framework.TestSuite;
 6   
 7    import java.util.Iterator;
 8    import java.util.LinkedList;
 9    import java.util.concurrent.CopyOnWriteArrayList;
 10   
 11    /**
 12    * @author Bela Ban
 13    * @version $Id: CopyOnWriteArrayTest.java,v 1.3 2007/01/17 01:31:07 genman Exp $
 14    */
 15    public class CopyOnWriteArrayTest extends TestCase {
 16    LinkedList l;
 17    CopyOnWriteArrayList list;
 18    Exception thread_ex=null;
 19   
 20  1 protected void setUp() throws Exception {
 21  1 super.setUp();
 22  1 l=new LinkedList();
 23  1 l.add("one");
 24  1 l.add("two");
 25  1 l.add("three");
 26  1 list=new CopyOnWriteArrayList(l);
 27  1 thread_ex=null;
 28    }
 29   
 30  1 protected void tearDown() throws Exception {
 31  1 super.tearDown();
 32  1 if(thread_ex != null)
 33  0 throw thread_ex;
 34    }
 35   
 36   
 37  1 public void testInsertionandIteration() {
 38  1 Object el;
 39  1 System.out.println("list = " + list);
 40   
 41  1 Iterator it=list.iterator();
 42  1 System.out.println(it.next());
 43   
 44  1 list.add("four");
 45   
 46  1 int count=0;
 47  1 while(it.hasNext()) {
 48  2 el=it.next();
 49  2 System.out.println(el);
 50  2 ++count;
 51    }
 52  1 assertEquals(2, count);
 53   
 54  1 System.out.println("list: " + list);
 55  1 assertEquals(4, list.size());
 56    }
 57   
 58   
 59   
 60   
 61   
 62  1 public static Test suite() {
 63  1 return new TestSuite(CopyOnWriteArrayTest.class);
 64    }
 65   
 66  0 public static void main(String[] args) {
 67  0 junit.textui.TestRunner.run(suite());
 68    }
 69   
 70    }