You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rw...@apache.org on 2003/05/06 02:04:30 UTC

cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators TestBaseProxyIntList.java TestAll.java

rwaldhoff    2003/05/05 17:04:30

  Modified:    collections/src/test/org/apache/commons/collections/primitives/decorators
                        TestAll.java
  Added:       collections/src/test/org/apache/commons/collections/primitives/decorators
                        TestBaseProxyIntList.java
  Log:
  add tests
  
  Revision  Changes    Path
  1.2       +3 -3      jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/TestAll.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestAll.java	4 May 2003 12:58:48 -0000	1.1
  +++ TestAll.java	6 May 2003 00:04:30 -0000	1.2
  @@ -79,7 +79,7 @@
           TestSuite suite = new TestSuite();
   
           suite.addTest(TestBaseProxyIntCollection.suite());
  -        // TODO: suite.addTest(TestBaseProxyIntList.suite());
  +        suite.addTest(TestBaseProxyIntList.suite());
   
           return suite;
       }
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/TestBaseProxyIntList.java
  
  Index: TestBaseProxyIntList.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/TestBaseProxyIntList.java,v 1.1 2003/05/06 00:04:30 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.collections.primitives.decorators;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  import org.apache.commons.collections.primitives.IntCollection;
  import org.apache.commons.collections.primitives.IntList;
  import org.apache.commons.collections.primitives.IntListIterator;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/05/06 00:04:30 $
   * @author Rodney Waldhoff
   */
  public class TestBaseProxyIntList extends TestCase {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public TestBaseProxyIntList(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestBaseProxyIntList.class);
      }
  
      // tests
      // ------------------------------------------------------------------------
      
      public void testListCallsAreProxied() {
          final InvocationCounter proxied = new InvocationCounter();
          BaseProxyIntList list = new BaseProxyIntList() {
              protected IntList getProxiedList() {
                  return proxied;
              }
          };
          
          assertSame(list.getProxiedList(),list.getProxiedCollection());
          
          assertEquals(0,proxied.getAddCount());
          list.add(1,1);
          assertEquals(1,proxied.getAddCount());
  
          assertEquals(0,proxied.getAddAllCount());
          list.addAll(1,null);
          assertEquals(1,proxied.getAddAllCount());
  
          assertEquals(0,proxied.getGetCount());
          list.get(1);
          assertEquals(1,proxied.getGetCount());
  
          assertEquals(0,proxied.getIndexOfCount());
          list.indexOf(1);
          assertEquals(1,proxied.getIndexOfCount());
  
          assertEquals(0,proxied.getLastIndexOfCount());
          list.lastIndexOf(1);
          assertEquals(1,proxied.getLastIndexOfCount());
  
          assertEquals(0,proxied.getListIteratorCount());
          list.listIterator();
          assertEquals(1,proxied.getListIteratorCount());
  
          assertEquals(0,proxied.getListIteratorFromCount());
          list.listIterator(1);
          assertEquals(1,proxied.getListIteratorFromCount());
  
          assertEquals(0,proxied.getRemoveElementAtCount());
          list.removeElementAt(1);
          assertEquals(1,proxied.getRemoveElementAtCount());
  
          assertEquals(0,proxied.getSetCount());
          list.set(1,1);
          assertEquals(1,proxied.getSetCount());
  
          assertEquals(0,proxied.getSubListCount());
          list.subList(1,2);
          assertEquals(1,proxied.getSubListCount());
      }
      
      // inner classes
      // ------------------------------------------------------------------------
  
      static class InvocationCounter extends TestBaseProxyIntCollection.InvocationCounter implements IntList {
          private int addCount;
          private int addAllCount;
          private int getCount;
          private int indexOfCount;
          private int lastIndexOfCount;
          private int listIteratorCount;
          private int listIteratorFromCount;
          private int removeElementAtCount;
          private int setCount;
          private int subListCount;
          
          public void add(int index, int element) {
              addCount++;
          }
  
          public boolean addAll(int index, IntCollection collection) {
              addAllCount++;
              return false;
          }
  
          public int get(int index) {
              getCount++;
              return 0;
          }
  
          public int indexOf(int element) {
              indexOfCount++;
              return 0;
          }
  
          public int lastIndexOf(int element) {
              lastIndexOfCount++;
              return 0;
          }
  
          public IntListIterator listIterator() {
              listIteratorCount++;
              return null;
          }
  
          public IntListIterator listIterator(int index) {
              listIteratorFromCount++;
              return null;
          }
  
          public int removeElementAt(int index) {
              removeElementAtCount++;
              return 0;
          }
  
          public int set(int index, int element) {
              setCount++;
              return 0;
          }
  
          public IntList subList(int fromIndex, int toIndex) {
              subListCount++;
              return null;
          }
  
          public int getAddAllCount() {
              return addAllCount;
          }
  
          public int getAddCount() {
              return addCount;
          }
  
          public int getGetCount() {
              return getCount;
          }
  
          public int getIndexOfCount() {
              return indexOfCount;
          }
  
          public int getLastIndexOfCount() {
              return lastIndexOfCount;
          }
  
          public int getListIteratorCount() {
              return listIteratorCount;
          }
  
          public int getListIteratorFromCount() {
              return listIteratorFromCount;
          }
  
          public int getRemoveElementAtCount() {
              return removeElementAtCount;
          }
  
          public int getSetCount() {
              return setCount;
          }
  
          public int getSubListCount() {
              return subListCount;
          }
  
      }
  }
  
  

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