commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morg...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestAll.java TestArrayList.java TestArrayStack.java TestCursorableLinkedList.java TestFastArrayList.java TestList.java
Date Tue, 26 Feb 2002 20:23:10 GMT
morgand     02/02/26 12:23:10

  Modified:    collections/src/test/org/apache/commons/collections Tag:
                        collections_1_x_branch TestAll.java
                        TestArrayList.java TestArrayStack.java
                        TestCursorableLinkedList.java
                        TestFastArrayList.java TestList.java
  Log:
  merged with HEAD
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.15.2.4  +4 -5      jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java,v
  retrieving revision 1.15.2.3
  retrieving revision 1.15.2.4
  diff -u -r1.15.2.3 -r1.15.2.4
  --- TestAll.java	26 Feb 2002 06:17:51 -0000	1.15.2.3
  +++ TestAll.java	26 Feb 2002 20:23:10 -0000	1.15.2.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java,v
1.15.2.3 2002/02/26 06:17:51 morgand Exp $
  - * $Revision: 1.15.2.3 $
  - * $Date: 2002/02/26 06:17:51 $
  + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java,v
1.15.2.4 2002/02/26 20:23:10 morgand Exp $
  + * $Revision: 1.15.2.4 $
  + * $Date: 2002/02/26 20:23:10 $
    *
    * ====================================================================
    *
  @@ -66,7 +66,7 @@
   /**
    * Entry point for all Collections tests.
    * @author Rodney Waldhoff
  - * @version $Id: TestAll.java,v 1.15.2.3 2002/02/26 06:17:51 morgand Exp $
  + * @version $Id: TestAll.java,v 1.15.2.4 2002/02/26 20:23:10 morgand Exp $
    */
   public class TestAll extends TestCase {
       public TestAll(String testName) {
  @@ -76,7 +76,6 @@
       public static Test suite() {
           TestSuite suite = new TestSuite();
           suite.addTest(TestArrayIterator.suite());
  -        suite.addTest(TestArrayList.suite());
           suite.addTest(TestArrayStack.suite());
           suite.addTest(TestCollectionUtils.suite());
           suite.addTest(TestCursorableLinkedList.suite());
  
  
  
  1.2.2.1   +6 -12     jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayList.java
  
  Index: TestArrayList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayList.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- TestArrayList.java	14 Jul 2001 23:33:26 -0000	1.2
  +++ TestArrayList.java	26 Feb 2002 20:23:10 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayList.java,v
1.2 2001/07/14 23:33:26 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/14 23:33:26 $
  + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayList.java,v
1.2.2.1 2002/02/26 20:23:10 morgand Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/02/26 20:23:10 $
    *
    * ====================================================================
    *
  @@ -69,9 +69,9 @@
   
   /**
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
  - * @version $Id: TestArrayList.java,v 1.2 2001/07/14 23:33:26 craigmcc Exp $
  + * @version $Id: TestArrayList.java,v 1.2.2.1 2002/02/26 20:23:10 morgand Exp $
    */
  -public class TestArrayList extends TestList
  +public abstract class TestArrayList extends TestList
   {
       public TestArrayList(String testName)
       {
  @@ -93,13 +93,7 @@
   
       public void setUp()
       {
  -        list = (ArrayList) makeList();
  -    }
  -
  -    public List makeList()
  -    {
  -        ArrayList al = new ArrayList();
  -        return (al);
  +        list = (ArrayList) makeEmptyList();
       }
   
       public void testNewArrayList()
  
  
  
  1.5.2.1   +6 -6      jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayStack.java
  
  Index: TestArrayStack.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayStack.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- TestArrayStack.java	14 Jul 2001 23:33:26 -0000	1.5
  +++ TestArrayStack.java	26 Feb 2002 20:23:10 -0000	1.5.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayStack.java,v
1.5 2001/07/14 23:33:26 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/07/14 23:33:26 $
  + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayStack.java,v
1.5.2.1 2002/02/26 20:23:10 morgand Exp $
  + * $Revision: 1.5.2.1 $
  + * $Date: 2002/02/26 20:23:10 $
    *
    * ====================================================================
    *
  @@ -66,7 +66,7 @@
   
   /**
    * @author Craig McClanahan
  - * @version $Id: TestArrayStack.java,v 1.5 2001/07/14 23:33:26 craigmcc Exp $
  + * @version $Id: TestArrayStack.java,v 1.5.2.1 2002/02/26 20:23:10 morgand Exp $
    */
   
   public class TestArrayStack extends TestArrayList {
  @@ -84,14 +84,14 @@
           junit.textui.TestRunner.main(testCaseName);
       }
   
  -    public List makeList() {
  +    public List makeEmptyList() {
           return new ArrayStack();
       }
   
       protected ArrayStack stack = null;
   
       public void setUp() {
  -        stack = (ArrayStack) makeList();
  +        stack = (ArrayStack) makeEmptyList();
           list = stack;
       }
   
  
  
  
  1.3.2.1   +5 -5      jakarta-commons/collections/src/test/org/apache/commons/collections/TestCursorableLinkedList.java
  
  Index: TestCursorableLinkedList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestCursorableLinkedList.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- TestCursorableLinkedList.java	14 Jul 2001 23:33:27 -0000	1.3
  +++ TestCursorableLinkedList.java	26 Feb 2002 20:23:10 -0000	1.3.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestCursorableLinkedList.java,v
1.3 2001/07/14 23:33:27 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/07/14 23:33:27 $
  + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestCursorableLinkedList.java,v
1.3.2.1 2002/02/26 20:23:10 morgand Exp $
  + * $Revision: 1.3.2.1 $
  + * $Date: 2002/02/26 20:23:10 $
    *
    * ====================================================================
    *
  @@ -66,7 +66,7 @@
   
   /**
    * @author Rodney Waldhoff
  - * @version $Id: TestCursorableLinkedList.java,v 1.3 2001/07/14 23:33:27 craigmcc Exp $
  + * @version $Id: TestCursorableLinkedList.java,v 1.3.2.1 2002/02/26 20:23:10 morgand Exp
$
    */
   public class TestCursorableLinkedList extends TestList {
       public TestCursorableLinkedList(String testName) {
  @@ -88,7 +88,7 @@
           list = new CursorableLinkedList();
       }
   
  -    public List makeList() {
  +    public List makeEmptyList() {
           return new CursorableLinkedList();
       }
   
  
  
  
  1.3.2.1   +6 -6      jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList.java
  
  Index: TestFastArrayList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- TestFastArrayList.java	21 Apr 2001 12:22:30 -0000	1.3
  +++ TestFastArrayList.java	26 Feb 2002 20:23:10 -0000	1.3.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList.java,v
1.3 2001/04/21 12:22:30 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/04/21 12:22:30 $
  + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList.java,v
1.3.2.1 2002/02/26 20:23:10 morgand Exp $
  + * $Revision: 1.3.2.1 $
  + * $Date: 2002/02/26 20:23:10 $
    *
    * ====================================================================
    *
  @@ -69,7 +69,7 @@
   
   /**
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
  - * @version $Id: TestFastArrayList.java,v 1.3 2001/04/21 12:22:30 craigmcc Exp $
  + * @version $Id: TestFastArrayList.java,v 1.3.2.1 2002/02/26 20:23:10 morgand Exp $
    */
   public class TestFastArrayList extends TestArrayList
   {
  @@ -91,10 +91,10 @@
   
       public void setUp()
       {
  -        list = (ArrayList) makeList();
  +        list = (ArrayList) makeEmptyList();
       }
   
  -    public List makeList()
  +    public List makeEmptyList()
       {
           FastArrayList fal = new FastArrayList();
           fal.setFast(false);
  
  
  
  1.5.2.1   +108 -28   jakarta-commons/collections/src/test/org/apache/commons/collections/TestList.java
  
  Index: TestList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestList.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- TestList.java	14 Jul 2001 23:33:27 -0000	1.5
  +++ TestList.java	26 Feb 2002 20:23:10 -0000	1.5.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestList.java,v
1.5 2001/07/14 23:33:27 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/07/14 23:33:27 $
  + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestList.java,v
1.5.2.1 2002/02/26 20:23:10 morgand Exp $
  + * $Revision: 1.5.2.1 $
  + * $Date: 2002/02/26 20:23:10 $
    *
    * ====================================================================
    *
  @@ -62,6 +62,8 @@
   package org.apache.commons.collections;
   
   import junit.framework.*;
  +import java.io.IOException;
  +import java.io.Serializable;
   import java.util.List;
   import java.util.Collection;
   import java.util.Arrays;
  @@ -80,7 +82,7 @@
    * test case (method) your {@link List} fails.
    *
    * @author Rodney Waldhoff
  - * @version $Id: TestList.java,v 1.5 2001/07/14 23:33:27 craigmcc Exp $
  + * @version $Id: TestList.java,v 1.5.2.1 2002/02/26 20:23:10 morgand Exp $
    */
   public abstract class TestList extends TestCollection {
       public TestList(String testName) {
  @@ -90,14 +92,30 @@
       /**
        * Return a new, empty {@link List} to used for testing.
        */
  -    public abstract List makeList();
  +    public abstract List makeEmptyList();
  +
  +    public List makeFullList() {
  +        // only works if list supports optional "add(Object)" 
  +        // and "add(int,Object)" operations
  +        List list = makeEmptyList();
  +        list.add("1");
  +        // must be able to add to the end this way
  +        list.add(list.size(),"4");
  +        // must support duplicates
  +        list.add("1");
  +        // must support insertions
  +        list.add(1,"3");
  +
  +        // resultant list: 1, 3, 4, 1
  +        return list;
  +    }
   
       public Collection makeCollection() {
  -        return makeList();
  +        return makeEmptyList();
       }
   
       public void testListAddByIndexBoundsChecking() {
  -        List list = makeList();
  +        List list = makeEmptyList();
   
           try {
               list.add(Integer.MIN_VALUE,"element");
  @@ -153,7 +171,7 @@
       }
   
       public void testListAddByIndexBoundsChecking2() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           boolean added = tryToAdd(list,"element");
   
           try {
  @@ -184,7 +202,7 @@
       }
   
       public void testListAddByIndex() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           assertEquals(0,list.size());
           if(tryToAdd(list,0,"element2")) {
               assertEquals(1,list.size());
  @@ -201,7 +219,7 @@
       }
   
       public void testListAdd() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           if(tryToAdd(list,"1")) {
               assertTrue(list.contains("1"));
               if(tryToAdd(list,"2")) {
  @@ -223,7 +241,7 @@
       }
   
       public void testListEqualsSelf() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           assertTrue(list.equals(list));
           tryToAdd(list,"elt");
           assertTrue(list.equals(list));
  @@ -232,7 +250,7 @@
       }
   
       public void testListEqualsArrayList() {
  -        List list1 = makeList();
  +        List list1 = makeEmptyList();
           List list2 = new ArrayList();
           assertTrue(list1.equals(list2));
           assertEquals(list1.hashCode(),list2.hashCode());
  @@ -252,8 +270,8 @@
       }
   
       public void testListEquals() {
  -        List list1 = makeList();
  -        List list2 = makeList();
  +        List list1 = makeEmptyList();
  +        List list2 = makeEmptyList();
           assertTrue(list1.equals(list2));
           if(tryToAdd(list1,"a") && tryToAdd(list2,"a")) {
               assertTrue(list1.equals(list2));
  @@ -270,7 +288,7 @@
       }
   
       public void testListGetByIndex() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"a");
           tryToAdd(list,"b");
           tryToAdd(list,"c");
  @@ -284,7 +302,7 @@
       }
   
       public void testListGetByIndexBoundsChecking() {
  -        List list = makeList();
  +        List list = makeEmptyList();
   
           try {
               list.get(Integer.MIN_VALUE);
  @@ -323,7 +341,7 @@
       }
   
       public void testListGetByIndexBoundsChecking2() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           boolean added = tryToAdd(list,"a");
   
           try {
  @@ -356,7 +374,7 @@
       }
   
       public void testListIndexOf() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"a");
           tryToAdd(list,"b");
           tryToAdd(list,"c");
  @@ -371,7 +389,7 @@
       }
   
       public void testListLastIndexOf1() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"a");
           tryToAdd(list,"b");
           tryToAdd(list,"c");
  @@ -386,7 +404,7 @@
       }
   
       public void testListLastIndexOf2() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"a");
           tryToAdd(list,"b");
           tryToAdd(list,"c");
  @@ -434,7 +452,7 @@
       }
   
       public void testListSetByIndexBoundsChecking() {
  -        List list = makeList();
  +        List list = makeEmptyList();
   
           try {
               list.set(Integer.MIN_VALUE,"a");
  @@ -503,7 +521,7 @@
       }
   
       public void testListSetByIndexBoundsChecking2() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"element");
           tryToAdd(list,"element2");
   
  @@ -561,7 +579,7 @@
       }
   
       public void testListSetByIndex() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"element");
           tryToAdd(list,"element2");
           tryToAdd(list,"element3");
  @@ -586,7 +604,7 @@
       }
   
       public void testListRemoveByIndex() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"element");
           tryToAdd(list,"element2");
           tryToAdd(list,"element3");
  @@ -615,7 +633,7 @@
       }
   
       public void testListRemoveByValue() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"element1");
           tryToAdd(list,"element2");
           tryToAdd(list,"element3");
  @@ -637,7 +655,7 @@
       }
   
       public void testListListIteratorNextPrev() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"element1");
           tryToAdd(list,"element2");
           tryToAdd(list,"element3");
  @@ -667,7 +685,7 @@
       }
   
       public void testListListIteratorNextIndexPrevIndex() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"element1");
           tryToAdd(list,"element2");
           tryToAdd(list,"element3");
  @@ -689,7 +707,7 @@
       }
   
       public void testListListIteratorSet() {
  -        List list = makeList();
  +        List list = makeEmptyList();
           tryToAdd(list,"element1");
           tryToAdd(list,"element2");
           tryToAdd(list,"element3");
  @@ -780,6 +798,68 @@
               fail("List.add should only throw UnsupportedOperationException, ClassCastException,
IllegalArgumentException, or IndexOutOfBoundsException. Found " + t.toString());
               return false; // never get here, since fail throws exception
           }
  +    }
  +
  +    public void testEmptyListSerialization() 
  +    throws IOException, ClassNotFoundException {
  +        List list = makeEmptyList();
  +        if (!(list instanceof Serializable)) return;
  +        
  +        byte[] objekt = writeExternalFormToBytes((Serializable) list);
  +        List list2 = (List) readExternalFormFromBytes(objekt);
  +
  +        assertTrue("Both lists are empty",list.size()  == 0);
  +        assertTrue("Both lists are empty",list2.size() == 0);
  +    }
  +
  +    public void testFullListSerialization() 
  +    throws IOException, ClassNotFoundException {
  +        List list = makeFullList();
  +        if (!(list instanceof Serializable)) return;
  +        
  +        byte[] objekt = writeExternalFormToBytes((Serializable) list);
  +        List list2 = (List) readExternalFormFromBytes(objekt);
  +
  +        assertEquals("Both lists are same size",list.size(), 4);
  +        assertEquals("Both lists are same size",list2.size(),4);
  +    }
  +
  +    /**
  +     * Compare the current serialized form of the List
  +     * against the canonical version in CVS.
  +     */
  +    public void testEmptyListCompatibility() throws IOException, ClassNotFoundException
{
  +        /**
  +         * Create canonical objects with this code
  +        List list = makeEmptyList();
  +        if (!(list instanceof Serializable)) return;
  +        
  +        writeExternalFormToDisk((Serializable) list, getCanonicalEmptyCollectionName(list));
  +        */
  +
  +        // test to make sure the canonical form has been preserved
  +        if (!(makeEmptyList() instanceof Serializable)) return;
  +        List list = (List) readExternalFormFromDisk(getCanonicalEmptyCollectionName(makeEmptyList()));
  +        assertTrue("List is empty",list.size()  == 0);
  +    }
  +
  +        /**
  +     * Compare the current serialized form of the List
  +     * against the canonical version in CVS.
  +     */
  +    public void testFullListCompatibility() throws IOException, ClassNotFoundException
{
  +        /**
  +         * Create canonical objects with this code
  +        List list = makeFullList();
  +        if (!(list instanceof Serializable)) return;
  +        
  +        writeExternalFormToDisk((Serializable) list, getCanonicalFullCollectionName(list));
  +        */
  +
  +        // test to make sure the canonical form has been preserved
  +        if (!(makeFullList() instanceof Serializable)) return;
  +        List list = (List) readExternalFormFromDisk(getCanonicalFullCollectionName(makeFullList()));
  +        assertEquals("List is the right size",list.size(), 4);
       }
   
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message