commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/adapters BaseTestList.java
Date Thu, 29 Jul 2004 22:30:55 GMT
scolebourne    2004/07/29 15:30:55

  Modified:    primitives project.xml build.properties.sample build.xml
               primitives/src/test/org/apache/commons/collections/primitives/adapters
                        BaseTestList.java
  Log:
  Upgrade to commons-collections-testframework-3.1 (hints from gump)
  
  Revision  Changes    Path
  1.19      +1 -1      jakarta-commons/primitives/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/primitives/project.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- project.xml	14 Apr 2004 22:46:19 -0000	1.18
  +++ project.xml	29 Jul 2004 22:30:55 -0000	1.19
  @@ -109,7 +109,7 @@
       </dependency>
       <dependency>
         <id>commons-collections:commons-collections-testframework</id>
  -      <version>3.0</version>
  +      <version>3.1</version>
         <url>http://jakarta.apache.org/commons/collections/</url>
       </dependency>
   
  
  
  
  1.5       +1 -1      jakarta-commons/primitives/build.properties.sample
  
  Index: build.properties.sample
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/primitives/build.properties.sample,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- build.properties.sample	25 Feb 2004 20:38:25 -0000	1.4
  +++ build.properties.sample	29 Jul 2004 22:30:55 -0000	1.5
  @@ -20,4 +20,4 @@
   junit.jar = ${junit.home}/junit.jar
   
   # The pathname of the collections-testframework.jar
  -collections-testframework.jar=../target/commons-collections-testframework.jar
  \ No newline at end of file
  +collections-testframework.jar=../target/commons-collections-testframework-3.1.jar
  \ No newline at end of file
  
  
  
  1.11      +2 -2      jakarta-commons/primitives/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/primitives/build.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- build.xml	25 Feb 2004 20:42:18 -0000	1.10
  +++ build.xml	29 Jul 2004 22:30:55 -0000	1.11
  @@ -212,7 +212,7 @@
                   version="true"
                  doctitle="&lt;h1&gt;${component.title}&lt;/h1&gt;"
               windowtitle="${component.title} (Version ${component.version})"
  -                 bottom="Copyright (c) 2002-2003 - Apache Software Foundation">
  +                 bottom="Copyright (c) 2002-2004 - Apache Software Foundation">
         <classpath refid="compile.classpath"/>
       </javadoc>
     </target>
  
  
  
  1.4       +111 -1    jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/adapters/BaseTestList.java
  
  Index: BaseTestList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/adapters/BaseTestList.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BaseTestList.java	25 Feb 2004 20:46:29 -0000	1.3
  +++ BaseTestList.java	29 Jul 2004 22:30:55 -0000	1.4
  @@ -15,9 +15,12 @@
    */
   package org.apache.commons.collections.primitives.adapters;
   
  +import java.util.Arrays;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.ListIterator;
   
  +import org.apache.commons.collections.BulkTest;
   import org.apache.commons.collections.list.AbstractTestList;
   
   /**
  @@ -56,4 +59,111 @@
           assertFalse(iter.hasNext());
       }
   
  +    /**
  +     * Override to change assertSame to assertEquals.
  +     */
  +    public void testListListIteratorPreviousRemove() {
  +        if (isRemoveSupported() == false) return;
  +        resetFull();
  +        ListIterator it = getList().listIterator();
  +        Object zero = it.next();
  +        Object one = it.next();
  +        Object two = it.next();
  +        Object two2 = it.previous();
  +        Object one2 = it.previous();
  +        assertEquals(one, one2);
  +        assertEquals(two, two2);
  +        assertEquals(zero, getList().get(0));
  +        assertEquals(one, getList().get(1));
  +        assertEquals(two, getList().get(2));
  +        it.remove();
  +        assertEquals(zero, getList().get(0));
  +        assertEquals(two, getList().get(1));
  +    }
  +
  +    /**
  +     * Override to change assertSame to assertEquals.
  +     */
  +    public BulkTest bulkTestSubList() {
  +        if (getFullElements().length - 6 < 10) return null;
  +        return new PrimitiveBulkTestSubList(this);
  +    }
  +
  +
  +    /**
  +     * Whole class copied as sub list constructor was package scoped in 3.1.
  +     */
  +    public static class PrimitiveBulkTestSubList extends BaseTestList {
  +        private BaseTestList outer;
  +    
  +        PrimitiveBulkTestSubList(BaseTestList outer) {
  +            super("");
  +            this.outer = outer;
  +        }
  +    
  +        public Object[] getFullElements() {
  +            List l = Arrays.asList(outer.getFullElements());
  +            return l.subList(3, l.size() - 3).toArray();
  +        }
  +        public Object[] getOtherElements() {
  +            return outer.getOtherElements();
  +        }
  +        public boolean isAddSupported() {
  +            return outer.isAddSupported();
  +        }
  +        public boolean isSetSupported() {
  +            return outer.isSetSupported();
  +        }
  +        public boolean isRemoveSupported() {
  +            return outer.isRemoveSupported();
  +        }
  +    
  +        public List makeEmptyList() {
  +            return outer.makeFullList().subList(4, 4);
  +        }
  +        public List makeFullList() {
  +            int size = getFullElements().length;
  +            return outer.makeFullList().subList(3, size - 3);
  +        }
  +        public void resetEmpty() {
  +            outer.resetFull();
  +            this.collection = outer.getList().subList(4, 4);
  +            this.confirmed = outer.getConfirmedList().subList(4, 4);
  +        }
  +        public void resetFull() {
  +            outer.resetFull();
  +            int size = outer.confirmed.size();
  +            this.collection = outer.getList().subList(3, size - 3);
  +            this.confirmed = outer.getConfirmedList().subList(3, size - 3);
  +        }
  +        public void verify() {
  +            super.verify();
  +            outer.verify();
  +        }
  +        public boolean isTestSerialization() {
  +            return false;
  +        }
  +        /**
  +         * Override to change assertSame to assertEquals.
  +         */
  +        public void testListListIteratorPreviousRemove() {
  +            if (isRemoveSupported() == false)
  +                return;
  +            resetFull();
  +            ListIterator it = getList().listIterator();
  +            Object zero = it.next();
  +            Object one = it.next();
  +            Object two = it.next();
  +            Object two2 = it.previous();
  +            Object one2 = it.previous();
  +            assertEquals(one, one2);
  +            assertEquals(two, two2);
  +            assertEquals(zero, getList().get(0));
  +            assertEquals(one, getList().get(1));
  +            assertEquals(two, getList().get(2));
  +            it.remove();
  +            assertEquals(zero, getList().get(0));
  +            assertEquals(two, getList().get(1));
  +        }
  +    }
   }
  
  
  

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


Mime
View raw message