commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators BaseUnmodifiableLongListIteratorTest.java TestBaseProxyLongList.java TestUnmodifiableLongListIterator.java TestUnmodifiableLongList.java BaseUnmodifiableLongListTest.java TestBaseProxyLongCollection.java TestUnmodifiableLongIterator.java BaseUnmodifiableLongIteratorTest.java PackageTestSuite.java
Date Mon, 27 Oct 2003 23:46:31 GMT
rwaldhoff    2003/10/27 15:46:31

  Modified:    primitives/src/test/org/apache/commons/collections/primitives
                        PackageTestSuite.java
               primitives/src/test/org/apache/commons/collections/primitives/decorators
                        PackageTestSuite.java
  Added:       primitives/src/test/org/apache/commons/collections/primitives
                        TestLongCollections.java
               primitives/src/test/org/apache/commons/collections/primitives/decorators
                        BaseUnmodifiableLongListIteratorTest.java
                        TestBaseProxyLongList.java
                        TestUnmodifiableLongListIterator.java
                        TestUnmodifiableLongList.java
                        BaseUnmodifiableLongListTest.java
                        TestBaseProxyLongCollection.java
                        TestUnmodifiableLongIterator.java
                        BaseUnmodifiableLongIteratorTest.java
  Log:
  add tests for LongCollections
  
  Revision  Changes    Path
  1.2       +3 -2      jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/PackageTestSuite.java
  
  Index: PackageTestSuite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/PackageTestSuite.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PackageTestSuite.java	13 Oct 2003 22:46:56 -0000	1.1
  +++ PackageTestSuite.java	27 Oct 2003 23:46:31 -0000	1.2
  @@ -98,6 +98,7 @@
           suite.addTest(TestArrayIntList.suite());
           suite.addTest(TestArrayUnsignedShortList.suite());
   
  +        suite.addTest(TestLongCollections.suite());
   		suite.addTest(TestAbstractLongCollection.suite());
   		suite.addTest(TestRandomAccessLongList.suite());
           suite.addTest(TestArrayLongList.suite());
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestLongCollections.java
  
  Index: TestLongCollections.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/TestLongCollections.java,v 1.1 2003/10/27 23:46:31 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002-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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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 LONGERRUPTION) 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;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public class TestLongCollections extends TestCase {
  
      //------------------------------------------------------------ Conventional
  
      public TestLongCollections(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestLongCollections.class);
      }
  
      //---------------------------------------------------------------- Tests
  
      public void testSingletonLongListIterator() {
          LongListIterator iter = LongCollections.singletonLongListIterator(17);
          assertTrue(!iter.hasPrevious());        
          assertTrue(iter.hasNext());        
          assertEquals(17,iter.next());        
          assertTrue(iter.hasPrevious());        
          assertTrue(!iter.hasNext());        
          assertEquals(17,iter.previous());        
          try {
              iter.set(18);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      public void testSingletonLongIterator() {
          LongIterator iter = LongCollections.singletonLongIterator(17);
          assertTrue(iter.hasNext());        
          assertEquals(17,iter.next());        
          assertTrue(!iter.hasNext());        
          try {
              iter.remove();
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      public void testSingletonLongList() {
          LongList list = LongCollections.singletonLongList(17);
          assertEquals(1,list.size());
          assertEquals(17,list.get(0));        
          try {
              list.add(18);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      public void testUnmodifiableLongListNull() {
          try {
              LongCollections.unmodifiableLongList(null);
              fail("Expected NullPointerException");
          } catch(NullPointerException e) {
              // expected
          }
      }
  
      public void testEmptyLongList() {
          assertSame(LongCollections.EMPTY_LONG_LIST,LongCollections.getEmptyLongList());
          assertTrue(LongCollections.EMPTY_LONG_LIST.isEmpty());
          try {
              LongCollections.EMPTY_LONG_LIST.add(1);
              fail("Expected UnsupportedOperationExcpetion");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      public void testUnmodifiableLongIteratorNull() {
          try {
              LongCollections.unmodifiableLongIterator(null);
              fail("Expected NullPointerException");
          } catch(NullPointerException e) {
              // expected
          }
      }
  
      public void testEmptyLongIterator() {
          assertSame(LongCollections.EMPTY_LONG_ITERATOR,LongCollections.getEmptyLongIterator());
          assertTrue(! LongCollections.EMPTY_LONG_ITERATOR.hasNext());
          try {
              LongCollections.EMPTY_LONG_ITERATOR.remove();
              fail("Expected UnsupportedOperationExcpetion");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      public void testUnmodifiableLongListIteratorNull() {
          try {
              LongCollections.unmodifiableLongListIterator(null);
              fail("Expected NullPointerException");
          } catch(NullPointerException e) {
              // expected
          }
      }
  
      public void testEmptyLongListIterator() {
          assertSame(LongCollections.EMPTY_LONG_LIST_ITERATOR,LongCollections.getEmptyLongListIterator());
          assertTrue(! LongCollections.EMPTY_LONG_LIST_ITERATOR.hasNext());
          assertTrue(! LongCollections.EMPTY_LONG_LIST_ITERATOR.hasPrevious());
          try {
              LongCollections.EMPTY_LONG_LIST_ITERATOR.add(1);
              fail("Expected UnsupportedOperationExcpetion");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  }
  
  
  
  
  1.2       +8 -2      jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/PackageTestSuite.java
  
  Index: PackageTestSuite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/PackageTestSuite.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PackageTestSuite.java	13 Oct 2003 22:46:58 -0000	1.1
  +++ PackageTestSuite.java	27 Oct 2003 23:46:31 -0000	1.2
  @@ -85,6 +85,12 @@
           suite.addTest(TestUnmodifiableIntIterator.suite());
           suite.addTest(TestUnmodifiableIntListIterator.suite());
   
  +        suite.addTest(TestBaseProxyLongCollection.suite());
  +        suite.addTest(TestBaseProxyLongList.suite());
  +        suite.addTest(TestUnmodifiableLongList.suite());
  +        suite.addTest(TestUnmodifiableLongIterator.suite());
  +        suite.addTest(TestUnmodifiableLongListIterator.suite());
  +
           return suite;
       }
   }
  
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableLongListIteratorTest.java
  
  Index: BaseUnmodifiableLongListIteratorTest.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableLongListIteratorTest.java,v 1.1 2003/10/27 23:46:31 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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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 org.apache.commons.collections.primitives.ArrayLongList;
  import org.apache.commons.collections.primitives.LongIterator;
  import org.apache.commons.collections.primitives.LongList;
  import org.apache.commons.collections.primitives.LongListIterator;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public abstract class BaseUnmodifiableLongListIteratorTest extends BaseUnmodifiableLongIteratorTest {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public BaseUnmodifiableLongListIteratorTest(String testName) {
          super(testName);
      }
      
  
      // framework
      // ------------------------------------------------------------------------
  
      protected abstract LongListIterator makeUnmodifiableLongListIterator();
  
      protected LongIterator makeUnmodifiableLongIterator() {
          return makeUnmodifiableLongListIterator();
      }
  
      protected LongIterator makeLongIterator() {
          return makeLongListIterator();
      }
      
      protected LongListIterator makeLongListIterator() {
          LongList list = new ArrayLongList();
          for(int i=0;i<10;i++) {
              list.add(i);
          }
          return list.listIterator();
      }
  
      // tests
      // ------------------------------------------------------------------------
  
      public final void testLongListIteratorNotModifiable() {
          LongListIterator iter = makeUnmodifiableLongListIterator();
          assertTrue(iter.hasNext());
          iter.next();
          try {
              iter.remove();
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          try {
              iter.add(1);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          try {
              iter.set(3);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      public final void testIterateLongListIterator() {        
          LongListIterator iter = makeUnmodifiableLongListIterator();
          LongListIterator expected = makeLongListIterator();
          
          assertTrue(! iter.hasPrevious());
          
          while( expected.hasNext() ) {
              assertTrue(iter.hasNext());
              assertEquals(expected.nextIndex(),iter.nextIndex());
              assertEquals(expected.previousIndex(),iter.previousIndex());
              assertEquals(expected.next(),iter.next());
              assertTrue(iter.hasPrevious());
              assertEquals(expected.nextIndex(),iter.nextIndex());
              assertEquals(expected.previousIndex(),iter.previousIndex());
          }
  
          assertTrue(! iter.hasNext() );
  
          while( expected.hasPrevious() ) {
              assertTrue(iter.hasPrevious());
              assertEquals(expected.nextIndex(),iter.nextIndex());
              assertEquals(expected.previousIndex(),iter.previousIndex());
              assertEquals(expected.previous(),iter.previous());
              assertTrue(iter.hasNext());
              assertEquals(expected.nextIndex(),iter.nextIndex());
              assertEquals(expected.previousIndex(),iter.previousIndex());
          }
          assertTrue(! iter.hasPrevious() );
      }
  
  }
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestBaseProxyLongList.java
  
  Index: TestBaseProxyLongList.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestBaseProxyLongList.java,v 1.1 2003/10/27 23:46:31 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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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.LongCollection;
  import org.apache.commons.collections.primitives.LongList;
  import org.apache.commons.collections.primitives.LongListIterator;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public class TestBaseProxyLongList extends TestCase {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public TestBaseProxyLongList(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestBaseProxyLongList.class);
      }
  
      // tests
      // ------------------------------------------------------------------------
      
      public void testListCallsAreProxied() {
          final InvocationCounter proxied = new InvocationCounter();
          BaseProxyLongList list = new BaseProxyLongList() {
              protected LongList 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 TestBaseProxyLongCollection.InvocationCounter implements LongList {
          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, long element) {
              addCount++;
          }
  
          public boolean addAll(int index, LongCollection collection) {
              addAllCount++;
              return false;
          }
  
          public long get(int index) {
              getCount++;
              return 0;
          }
  
          public int indexOf(long element) {
              indexOfCount++;
              return 0;
          }
  
          public int lastIndexOf(long element) {
              lastIndexOfCount++;
              return 0;
          }
  
          public LongListIterator listIterator() {
              listIteratorCount++;
              return null;
          }
  
          public LongListIterator listIterator(int index) {
              listIteratorFromCount++;
              return null;
          }
  
          public long removeElementAt(int index) {
              removeElementAtCount++;
              return 0;
          }
  
          public long set(int index, long element) {
              setCount++;
              return 0;
          }
  
          public LongList 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;
          }
  
      }
  }
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestUnmodifiableLongListIterator.java
  
  Index: TestUnmodifiableLongListIterator.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestUnmodifiableLongListIterator.java,v 1.1 2003/10/27 23:46:31 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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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.TestSuite;
  
  import org.apache.commons.collections.primitives.LongListIterator;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public class TestUnmodifiableLongListIterator extends BaseUnmodifiableLongListIteratorTest {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public TestUnmodifiableLongListIterator(String testName) {
          super(testName);
      }
      
  
      public static Test suite() {
          return new TestSuite(TestUnmodifiableLongListIterator.class);
      }
  
      // framework
      // ------------------------------------------------------------------------
  
      protected LongListIterator makeUnmodifiableLongListIterator() {
          return UnmodifiableLongListIterator.wrap(makeLongListIterator());
      }
  
      // tests
      // ------------------------------------------------------------------------
  
      public void testWrapNotNull() {
          assertNotNull(UnmodifiableLongListIterator.wrap(makeLongListIterator()));
      }
  
      public void testWrapNull() {
          assertNull(UnmodifiableLongListIterator.wrap(null));
      }
  
      public void testWrapUnmodifiableLongListIterator() {
          LongListIterator iter = makeUnmodifiableLongListIterator();
          assertSame(iter,UnmodifiableLongListIterator.wrap(iter));
      }
  
  }
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestUnmodifiableLongList.java
  
  Index: TestUnmodifiableLongList.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestUnmodifiableLongList.java,v 1.1 2003/10/27 23:46:31 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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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 java.io.Serializable;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.collections.primitives.LongList;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public class TestUnmodifiableLongList extends BaseUnmodifiableLongListTest {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public TestUnmodifiableLongList(String testName) {
          super(testName);
      }
      
  
      public static Test suite() {
          return new TestSuite(TestUnmodifiableLongList.class);
      }
  
      // framework
      // ------------------------------------------------------------------------
  
      protected LongList makeUnmodifiableLongList() {
          return UnmodifiableLongList.wrap(makeLongList());
      }
  
      // tests
      // ------------------------------------------------------------------------
  
      public void testWrapNull() {
          assertNull(UnmodifiableLongList.wrap(null));
      }
  
      public void testWrapUnmodifiableLongList() {
          LongList list = makeUnmodifiableLongList();
          assertSame(list,UnmodifiableLongList.wrap(list));
      }
  
      public void testWrapSerializableLongList() {
          LongList list = makeLongList();
          assertTrue(list instanceof Serializable);
          assertTrue(UnmodifiableLongList.wrap(list) instanceof Serializable);
      }
  
      public void testWrapNonSerializableLongList() {
          LongList list = makeLongList();
          LongList ns = list.subList(0,list.size());
          assertTrue(!(ns instanceof Serializable));
          assertTrue(!(UnmodifiableLongList.wrap(ns) instanceof Serializable));
      }
  }
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableLongListTest.java
  
  Index: BaseUnmodifiableLongListTest.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableLongListTest.java,v 1.1 2003/10/27 23:46:31 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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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.TestCase;
  
  import org.apache.commons.collections.primitives.ArrayLongList;
  import org.apache.commons.collections.primitives.LongIterator;
  import org.apache.commons.collections.primitives.LongList;
  import org.apache.commons.collections.primitives.LongListIterator;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public abstract class BaseUnmodifiableLongListTest extends TestCase {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public BaseUnmodifiableLongListTest(String testName) {
          super(testName);
      }
      
      // framework
      // ------------------------------------------------------------------------
  
      protected abstract LongList makeUnmodifiableLongList();
  
      protected LongList makeLongList() {
          LongList list = new ArrayLongList();
          for(int i=0;i<10;i++) {
              list.add(i);
          }
          return list;
      }
  
      // tests
      // ------------------------------------------------------------------------
      
      public final void testNotModifiable() throws Exception {
          assertListNotModifiable(makeUnmodifiableLongList());
      }
  
      public final void testSublistNotModifiable() throws Exception {
          LongList list = makeUnmodifiableLongList();
          assertListNotModifiable(list.subList(0,list.size()-2));
      }
      
      public final void testIteratorNotModifiable() throws Exception {
          LongList list = makeUnmodifiableLongList();
          assertIteratorNotModifiable(list.iterator());
          assertIteratorNotModifiable(list.subList(0,list.size()-2).iterator());
      }
      
      public final void testListIteratorNotModifiable() throws Exception {
          LongList list = makeUnmodifiableLongList();
          assertListIteratorNotModifiable(list.listIterator());
          assertListIteratorNotModifiable(list.subList(0,list.size()-2).listIterator());
          assertListIteratorNotModifiable(list.listIterator(1));
          assertListIteratorNotModifiable(list.subList(0,list.size()-2).listIterator(1));
      }
  
      // util
      // ------------------------------------------------------------------------
      
      private void assertListIteratorNotModifiable(LongListIterator iter) throws Exception {
          assertIteratorNotModifiable(iter);
          
          assertTrue(iter.hasPrevious());
          
          try {
              iter.set(2);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          
          try {
              iter.add(2);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      private void assertIteratorNotModifiable(LongIterator iter) throws Exception {
          assertTrue(iter.hasNext());
          iter.next();
          
          try {
              iter.remove();
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      private void assertListNotModifiable(LongList list) throws Exception {
          try {
              list.add(1);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          
          try {
              list.add(1,2);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          
          try {
              list.addAll(makeLongList());
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          
          try {
              list.addAll(1,makeLongList());
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          
          try {
              list.removeElementAt(1);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          
          try {
              list.removeElement(1);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          
          try {
              list.removeAll(makeLongList());
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
                  
          try {
              list.retainAll(makeLongList());
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
  
          try {
              list.clear();
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
          
          try {
              list.set(1,2);
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  }
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestBaseProxyLongCollection.java
  
  Index: TestBaseProxyLongCollection.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestBaseProxyLongCollection.java,v 1.1 2003/10/27 23:46:31 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002-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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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.LongCollection;
  import org.apache.commons.collections.primitives.LongIterator;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public class TestBaseProxyLongCollection extends TestCase {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public TestBaseProxyLongCollection(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestBaseProxyLongCollection.class);
      }
  
      // tests
      // ------------------------------------------------------------------------
      
      public void testCollectionCallsAreProxied() {
          final InvocationCounter proxied = new InvocationCounter();
          LongCollection collection = new BaseProxyLongCollection() {
              protected LongCollection getProxiedCollection() {
                  return proxied;
              }
          };
          
          assertEquals(0,proxied.getAddCount());
          collection.add(1);
          assertEquals(1,proxied.getAddCount());
  
          assertEquals(0,proxied.getAddAllCount());
          collection.addAll(null);
          assertEquals(1,proxied.getAddAllCount());
          
          assertEquals(0,proxied.getClearCount());
          collection.clear();
          assertEquals(1,proxied.getClearCount());
  
          assertEquals(0,proxied.getContainsCount());
          collection.contains(1);
          assertEquals(1,proxied.getContainsCount());
  
          assertEquals(0,proxied.getContainsAllCount());
          collection.containsAll(null);
          assertEquals(1,proxied.getContainsAllCount());
  
          assertEquals(0,proxied.getIsEmptyCount());
          collection.isEmpty();
          assertEquals(1,proxied.getIsEmptyCount());
  
          assertEquals(0,proxied.getIteratorCount());
          collection.iterator();
          assertEquals(1,proxied.getIteratorCount());
  
          assertEquals(0,proxied.getRemoveAllCount());
          collection.removeAll(null);
          assertEquals(1,proxied.getRemoveAllCount());
  
          assertEquals(0,proxied.getRetainAllCount());
          collection.retainAll(null);
          assertEquals(1,proxied.getRetainAllCount());
  
          assertEquals(0,proxied.getRemoveElementCount());
          collection.removeElement(1);
          assertEquals(1,proxied.getRemoveElementCount());
  
          assertEquals(0,proxied.getSizeCount());
          collection.size();
          assertEquals(1,proxied.getSizeCount());
  
          assertEquals(0,proxied.getToArrayLongArrayCount());
          collection.toArray(new long[0]);
          assertEquals(1,proxied.getToArrayLongArrayCount());
          
          assertEquals(0,proxied.getToArrayCount());
          collection.toArray();
          assertEquals(1,proxied.getToArrayCount());
          
          assertEquals(0,proxied.getToStringCount());
          collection.toString();
          assertEquals(1,proxied.getToStringCount());
          
          assertEquals(0,proxied.getEqualsCount());
          collection.equals(null);
          assertEquals(1,proxied.getEqualsCount());
          
          assertEquals(0,proxied.getHashCodeCount());
          collection.hashCode();
          assertEquals(1,proxied.getHashCodeCount());
          
      }
      
      // inner classes
      // ------------------------------------------------------------------------
  
      static class InvocationCounter implements LongCollection {
          private int _toArrayLongArray;
          private int _toArray;
          private int _size;
          private int _retainAll;
          private int _removeElement;
          private int _removeAll;
          private int _iterator;
          private int _isEmpty;
          private int _containsAll;
          private int _contains;
          private int _clear;
          private int _addAll;
          private int _add;
  
          private int _equals;
          private int _toString;
          private int _hashCode;
  
          public boolean add(long element) {
              _add++;
              return false;
          }
  
          public boolean addAll(LongCollection c) {
              _addAll++;
              return false;
          }
  
          public void clear() {
              _clear++;
          }
  
          public boolean contains(long element) {
              _contains++;
              return false;
          }
  
          public boolean containsAll(LongCollection c) {
              _containsAll++;
              return false;
          }
  
          public boolean isEmpty() {
              _isEmpty++;
              return false;
          }
  
          public LongIterator iterator() {
              _iterator++;
              return null;
          }
  
          public boolean removeAll(LongCollection c) {
              _removeAll++;
              return false;
          }
  
          public boolean removeElement(long element) {
              _removeElement++;
              return false;
          }
  
          public boolean retainAll(LongCollection c) {
              _retainAll++;
              return false;
          }
  
          public int size() {
              _size++;
              return 0;
          }
  
          public long[] toArray() {
              _toArray++;
              return null;
          }
  
          public long[] toArray(long[] a) {
              _toArrayLongArray++;
              return null;
          }
  
          public boolean equals(Object obj) {
              _equals++;
              return false;
          }
  
          public int hashCode() {
              _hashCode++;
              return 0;
          }
  
          public String toString() {
              _toString++;
              return null;
          }
  
  
          public int getAddCount() {
              return _add;
          }
  
          public int getAddAllCount() {
              return _addAll;
          }
  
          public int getClearCount() {
              return _clear;
          }
  
          public int getContainsCount() {
              return _contains;
          }
  
          public int getContainsAllCount() {
              return _containsAll;
          }
  
          public int getIsEmptyCount() {
              return _isEmpty;
          }
  
          public int getIteratorCount() {
              return _iterator;
          }
  
          public int getRemoveAllCount() {
              return _removeAll;
          }
  
          public int getRemoveElementCount() {
              return _removeElement;
          }
  
          public int getRetainAllCount() {
              return _retainAll;
          }
  
          public int getSizeCount() {
              return _size;
          }
  
          public int getToArrayCount() {
              return _toArray;
          }
  
          public int getToArrayLongArrayCount() {
              return _toArrayLongArray;
          }
  
          public int getEqualsCount() {
              return _equals;
          }
  
          public int getHashCodeCount() {
              return _hashCode;
          }
  
          public int getToStringCount() {
              return _toString;
          }
  
      }
  }
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestUnmodifiableLongIterator.java
  
  Index: TestUnmodifiableLongIterator.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/TestUnmodifiableLongIterator.java,v 1.1 2003/10/27 23:46:31 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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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.TestSuite;
  
  import org.apache.commons.collections.primitives.LongIterator;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public class TestUnmodifiableLongIterator extends BaseUnmodifiableLongIteratorTest {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public TestUnmodifiableLongIterator(String testName) {
          super(testName);
      }
      
  
      public static Test suite() {
          return new TestSuite(TestUnmodifiableLongIterator.class);
      }
  
      // framework
      // ------------------------------------------------------------------------
  
      protected LongIterator makeUnmodifiableLongIterator() {
          return UnmodifiableLongIterator.wrap(makeLongIterator());
      }
  
      // tests
      // ------------------------------------------------------------------------
  
      public void testWrapNotNull() {
          assertNotNull(UnmodifiableLongIterator.wrap(makeLongIterator()));
      }
  
      public void testWrapNull() {
          assertNull(UnmodifiableLongIterator.wrap(null));
      }
  
      public void testWrapUnmodifiableLongIterator() {
          LongIterator iter = makeUnmodifiableLongIterator();
          assertSame(iter,UnmodifiableLongIterator.wrap(iter));
      }
  
  }
  
  
  1.1                  jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableLongIteratorTest.java
  
  Index: BaseUnmodifiableLongIteratorTest.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/primitives/src/test/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableLongIteratorTest.java,v 1.1 2003/10/27 23:46:31 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 acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements 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.TestCase;
  
  import org.apache.commons.collections.primitives.ArrayLongList;
  import org.apache.commons.collections.primitives.LongIterator;
  import org.apache.commons.collections.primitives.LongList;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/10/27 23:46:31 $
   * @author Rodney Waldhoff
   */
  public abstract class BaseUnmodifiableLongIteratorTest extends TestCase {
  
      // conventional
      // ------------------------------------------------------------------------
  
      public BaseUnmodifiableLongIteratorTest(String testName) {
          super(testName);
      }
      
  
      // framework
      // ------------------------------------------------------------------------
      protected abstract LongIterator makeUnmodifiableLongIterator();
  
      protected LongIterator makeLongIterator() {
          LongList list = new ArrayLongList();
          for(long i=0;i<10;i++) {
              list.add(i);
          }
          return list.iterator();
      }
  
      // tests
      // ------------------------------------------------------------------------
  
      public final void testLongIteratorNotModifiable() {
          LongIterator iter = makeUnmodifiableLongIterator();
          assertTrue(iter.hasNext());
          iter.next();
          try {
              iter.remove();
              fail("Expected UnsupportedOperationException");
          } catch(UnsupportedOperationException e) {
              // expected
          }
      }
  
      public final void testIterateLongIterator() {        
          LongIterator iter = makeUnmodifiableLongIterator();
          for(LongIterator expected = makeLongIterator(); expected.hasNext(); ) {
              assertTrue(iter.hasNext());
              assertEquals(expected.next(),iter.next());
          }
          assertTrue(! iter.hasNext() );
      }
  
  }
  
  

---------------------------------------------------------------------
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