* add tests

* make a few minor changes so that those tests pass


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130983 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rodney Waldhoff 2003-03-01 00:47:29 +00:00
parent b9fbf5945b
commit 487ccad396
17 changed files with 1195 additions and 43 deletions

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractRandomAccessIntList.java,v 1.12 2003/02/28 00:17:52 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractRandomAccessIntList.java,v 1.13 2003/03/01 00:47:28 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -74,7 +74,7 @@ import java.util.NoSuchElementException;
* to provide a more efficient implementation.
*
* @since Commons Collections 2.2
* @version $Revision: 1.12 $ $Date: 2003/02/28 00:17:52 $
* @version $Revision: 1.13 $ $Date: 2003/03/01 00:47:28 $
*
* @author Rodney Waldhoff
*/
@ -369,8 +369,10 @@ public abstract class AbstractRandomAccessIntList extends AbstractIntCollection
protected static class RandomAccessIntSubList extends AbstractRandomAccessIntList implements IntList {
RandomAccessIntSubList(AbstractRandomAccessIntList list, int fromIndex, int toIndex) {
if(fromIndex < 0 || toIndex > list.size() || fromIndex > toIndex) {
if(fromIndex < 0 || toIndex > list.size()) {
throw new IndexOutOfBoundsException();
} else if(fromIndex > toIndex) {
throw new IllegalArgumentException();
} else {
_list = list;
_offset = fromIndex;

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/CollectionIntCollection.java,v 1.6 2003/02/28 21:21:51 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/CollectionIntCollection.java,v 1.7 2003/03/01 00:47:28 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -72,7 +72,7 @@ import org.apache.commons.collections.primitives.IntCollection;
* implementation in the "obvious" way.
*
* @since Commons Collections 2.2
* @version $Revision: 1.6 $ $Date: 2003/02/28 21:21:51 $
* @version $Revision: 1.7 $ $Date: 2003/03/01 00:47:28 $
* @author Rodney Waldhoff
*/
final public class CollectionIntCollection extends AbstractCollectionIntCollection implements Serializable {
@ -97,12 +97,6 @@ final public class CollectionIntCollection extends AbstractCollectionIntCollecti
}
}
/**
* No-arg constructor, for serialization purposes.
*/
protected CollectionIntCollection() {
}
/**
* Creates an {@link IntCollection IntCollection} wrapping
* the specified {@link Collection Collection}.

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/IntCollectionCollection.java,v 1.5 2003/02/28 21:21:51 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/IntCollectionCollection.java,v 1.6 2003/03/01 00:47:28 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -72,7 +72,7 @@ import org.apache.commons.collections.primitives.IntCollection;
* implementation in the "obvious" way.
*
* @since Commons Collections 2.2
* @version $Revision: 1.5 $ $Date: 2003/02/28 21:21:51 $
* @version $Revision: 1.6 $ $Date: 2003/03/01 00:47:28 $
* @author Rodney Waldhoff
*/
final public class IntCollectionCollection extends AbstractIntCollectionCollection implements Serializable {
@ -99,12 +99,6 @@ final public class IntCollectionCollection extends AbstractIntCollectionCollecti
}
}
/**
* No-arg constructor, for serialization purposes.
*/
protected IntCollectionCollection() {
}
/**
* Creates a {@link Collection Collection} wrapping
* the specified {@link IntCollection IntCollection}.

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/IntListList.java,v 1.5 2003/02/28 21:21:51 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/IntListList.java,v 1.6 2003/03/01 00:47:28 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -71,7 +71,7 @@ import org.apache.commons.collections.primitives.IntList;
* implementation in the "obvious" way.
*
* @since Commons Collections 2.2
* @version $Revision: 1.5 $ $Date: 2003/02/28 21:21:51 $
* @version $Revision: 1.6 $ $Date: 2003/03/01 00:47:28 $
* @author Rodney Waldhoff
*/
final public class IntListList extends AbstractIntListList implements Serializable {
@ -98,12 +98,6 @@ final public class IntListList extends AbstractIntListList implements Serializab
}
}
/**
* No-arg constructor, for serialization purposes.
*/
protected IntListList() {
}
/**
* Creates a {@link List List} wrapping
* the specified {@link IntList IntList}.

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/ListIntList.java,v 1.6 2003/02/28 00:17:53 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/ListIntList.java,v 1.7 2003/03/01 00:47:28 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -71,7 +71,7 @@ import org.apache.commons.collections.primitives.IntList;
* implementation in the "obvious" way.
*
* @since Commons Collections 2.2
* @version $Revision: 1.6 $ $Date: 2003/02/28 00:17:53 $
* @version $Revision: 1.7 $ $Date: 2003/03/01 00:47:28 $
* @author Rodney Waldhoff
*/
public class ListIntList extends AbstractListIntList implements Serializable {
@ -98,12 +98,6 @@ public class ListIntList extends AbstractListIntList implements Serializable {
}
}
/**
* No-arg constructor, for serialization purposes.
*/
protected ListIntList() {
}
/**
* Creates an {@link IntList IntList} wrapping
* the specified {@link List List}.

View File

@ -0,0 +1,157 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntIterator.java,v 1.1 2003/03/01 00:47:28 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;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.apache.commons.collections.iterators.TestIterator;
import org.apache.commons.collections.primitives.adapters.IntIteratorIterator;
/**
* @version $Revision: 1.1 $ $Date: 2003/03/01 00:47:28 $
* @author Rodney Waldhoff
*/
public abstract class TestIntIterator extends TestIterator {
// conventional
// ------------------------------------------------------------------------
public TestIntIterator(String testName) {
super(testName);
}
// collections testing framework
// ------------------------------------------------------------------------
protected Object makeObject() {
return makeFullIterator();
}
public Iterator makeEmptyIterator() {
return IntIteratorIterator.wrap(makeEmptyIntIterator());
}
public Iterator makeFullIterator() {
return IntIteratorIterator.wrap(makeFullIntIterator());
}
protected abstract IntIterator makeEmptyIntIterator();
protected abstract IntIterator makeFullIntIterator();
protected abstract int[] getFullElements();
// tests
// ------------------------------------------------------------------------
public void testNextHasNextRemove() {
int[] elements = getFullElements();
IntIterator iter = makeFullIntIterator();
for(int i=0;i<elements.length;i++) {
assertTrue(iter.hasNext());
assertEquals(elements[i],iter.next());
if(supportsRemove()) {
iter.remove();
}
}
assertTrue(! iter.hasNext() );
}
public void testEmptyIntIterator() {
assertTrue( ! makeEmptyIntIterator().hasNext() );
try {
makeEmptyIntIterator().next();
fail("Expected NoSuchElementException");
} catch(NoSuchElementException e) {
// expected
}
if(supportsRemove()) {
try {
makeEmptyIntIterator().remove();
fail("Expected IllegalStateException");
} catch(IllegalStateException e) {
// expected
}
}
}
public void testRemoveBeforeNext() {
if(supportsRemove()) {
try {
makeFullIntIterator().remove();
fail("Expected IllegalStateException");
} catch(IllegalStateException e) {
// expected
}
}
}
public void testRemoveAfterRemove() {
if(supportsRemove()) {
IntIterator iter = makeFullIntIterator();
iter.next();
iter.remove();
try {
iter.remove();
fail("Expected IllegalStateException");
} catch(IllegalStateException e) {
// expected
}
}
}
}

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntList.java,v 1.6 2003/02/28 00:17:53 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntList.java,v 1.7 2003/03/01 00:47:28 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -66,7 +66,7 @@ import org.apache.commons.collections.primitives.adapters.IntListList;
import org.apache.commons.collections.primitives.adapters.ListIntList;
/**
* @version $Revision: 1.6 $ $Date: 2003/02/28 00:17:53 $
* @version $Revision: 1.7 $ $Date: 2003/03/01 00:47:28 $
* @author Rodney Waldhoff
*/
public abstract class TestIntList extends TestList {
@ -140,6 +140,43 @@ public abstract class TestIntList extends TestList {
// tests
// ------------------------------------------------------------------------
public void testToJustBigEnoughIntArray() {
IntList list = makeFullIntList();
int[] dest = new int[list.size()];
assertSame(dest,list.toArray(dest));
int i=0;
for(IntIterator iter = list.iterator(); iter.hasNext();i++) {
assertEquals(iter.next(),dest[i]);
}
}
public void testToLargerThanNeededIntArray() {
IntList list = makeFullIntList();
int[] dest = new int[list.size()*2];
for(int i=0;i<dest.length;i++) {
dest[i] = Integer.MAX_VALUE;
}
assertSame(dest,list.toArray(dest));
int i=0;
for(IntIterator iter = list.iterator(); iter.hasNext();i++) {
assertEquals(iter.next(),dest[i]);
}
for(;i<dest.length;i++) {
assertEquals(Integer.MAX_VALUE,dest[i]);
}
}
public void testToSmallerThanNeededIntArray() {
IntList list = makeFullIntList();
int[] dest = new int[list.size()/2];
int[] dest2 = list.toArray(dest);
assertTrue(dest != dest2);
int i=0;
for(IntIterator iter = list.iterator(); iter.hasNext();i++) {
assertEquals(iter.next(),dest2[i]);
}
}
public void testHashCodeSpecification() {
IntList list = makeFullIntList();
int hash = 1;
@ -310,4 +347,35 @@ public abstract class TestIntList extends TestList {
assertTrue( ! (list instanceof Serializable) );
}
public void testSubListOutOfBounds() throws Exception {
try {
makeEmptyIntList().subList(2,3);
fail("Expected IndexOutOfBoundsException");
} catch(IndexOutOfBoundsException e) {
// expected
}
try {
makeFullIntList().subList(-1,3);
fail("Expected IndexOutOfBoundsException");
} catch(IndexOutOfBoundsException e) {
// expected
}
try {
makeFullIntList().subList(5,2);
fail("Expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// expected
}
try {
makeFullIntList().subList(2,makeFullIntList().size()+2);
fail("Expected IndexOutOfBoundsException");
} catch(IndexOutOfBoundsException e) {
// expected
}
}
}

View File

@ -0,0 +1,91 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntListIterator.java,v 1.1 2003/03/01 00:47:28 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;
/**
* @version $Revision: 1.1 $ $Date: 2003/03/01 00:47:28 $
* @author Rodney Waldhoff
*/
public abstract class TestIntListIterator extends TestIntIterator {
// conventional
// ------------------------------------------------------------------------
public TestIntListIterator(String testName) {
super(testName);
}
// collections testing framework
// ------------------------------------------------------------------------
public IntIterator makeEmptyIntIterator() {
return makeEmptyIntListIterator();
}
public IntIterator makeFullIntIterator() {
return makeFullIntListIterator();
}
public abstract IntListIterator makeEmptyIntListIterator();
public abstract IntListIterator makeFullIntListIterator();
// tests
// ------------------------------------------------------------------------
}

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestAll.java,v 1.1 2003/02/26 19:17:24 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestAll.java,v 1.2 2003/03/01 00:47:29 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -62,7 +62,7 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* @version $Revision: 1.1 $ $Date: 2003/02/26 19:17:24 $
* @version $Revision: 1.2 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestAll extends TestCase {
@ -78,8 +78,14 @@ public class TestAll extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(TestCollectionIntCollection.suite());
suite.addTest(TestIntCollectionCollection.suite());
suite.addTest(TestIntListList.suite());
suite.addTest(TestListIntList.suite());
suite.addTest(TestIteratorIntIterator.suite());
suite.addTest(TestListIteratorIntListIterator.suite());
suite.addTest(TestIntIteratorIterator.suite());
suite.addTest(TestIntListIteratorListIterator.suite());
return suite;
}

View File

@ -0,0 +1,137 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestCollectionIntCollection.java,v 1.1 2003/03/01 00:47:29 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.adapters;
import java.io.Serializable;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.TestObject;
import org.apache.commons.collections.primitives.IntCollection;
/**
* @version $Revision: 1.1 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestCollectionIntCollection extends TestObject {
// conventional
// ------------------------------------------------------------------------
public TestCollectionIntCollection(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestCollectionIntCollection.class);
}
// collections testing framework
// ------------------------------------------------------------------------
protected Object makeObject() {
List list = new ArrayList();
for(int i=0;i<10;i++) {
list.add(new Integer(i));
}
return new CollectionIntCollection(list);
}
public void testSerializeDeserializeThenCompare() {
// Collection.equal contract doesn't work that way
}
/** @todo need to add serialized form to cvs */
public void testCanonicalEmptyCollectionExists() {
// XXX FIX ME XXX
// need to add a serialized form to cvs
}
/** @todo need to add serialized form to cvs */
public void testCanonicalFullCollectionExists() {
// XXX FIX ME XXX
// need to add a serialized form to cvs
}
// tests
// ------------------------------------------------------------------------
public void testWrapNull() {
assertNull(CollectionIntCollection.wrap(null));
}
public void testWrapSerializable() {
IntCollection collection = CollectionIntCollection.wrap(new ArrayList());
assertNotNull(collection);
assertTrue(collection instanceof Serializable);
}
public void testWrapNonSerializable() {
IntCollection collection = CollectionIntCollection.wrap(new AbstractList() {
public Object get(int i) { throw new IndexOutOfBoundsException(); }
public int size() { return 0; }
});
assertNotNull(collection);
assertTrue(!(collection instanceof Serializable));
}
}

View File

@ -0,0 +1,137 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestIntCollectionCollection.java,v 1.1 2003/03/01 00:47:29 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.adapters;
import java.io.Serializable;
import java.util.Collection;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.TestObject;
import org.apache.commons.collections.primitives.AbstractRandomAccessIntList;
import org.apache.commons.collections.primitives.ArrayIntList;
import org.apache.commons.collections.primitives.IntList;
/**
* @version $Revision: 1.1 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestIntCollectionCollection extends TestObject {
// conventional
// ------------------------------------------------------------------------
public TestIntCollectionCollection(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIntCollectionCollection.class);
}
// collections testing framework
// ------------------------------------------------------------------------
protected Object makeObject() {
IntList list = new ArrayIntList();
for(int i=0;i<10;i++) {
list.add(i);
}
return new IntCollectionCollection(list);
}
public void testSerializeDeserializeThenCompare() {
// Collection.equal contract doesn't work that way
}
/** @todo need to add serialized form to cvs */
public void testCanonicalEmptyCollectionExists() {
// XXX FIX ME XXX
// need to add a serialized form to cvs
}
/** @todo need to add serialized form to cvs */
public void testCanonicalFullCollectionExists() {
// XXX FIX ME XXX
// need to add a serialized form to cvs
}
// tests
// ------------------------------------------------------------------------
public void testWrapNull() {
assertNull(IntCollectionCollection.wrap(null));
}
public void testWrapSerializable() {
Collection collection = IntCollectionCollection.wrap(new ArrayIntList());
assertNotNull(collection);
assertTrue(collection instanceof Serializable);
}
public void testWrapNonSerializable() {
Collection collection = IntCollectionCollection.wrap(new AbstractRandomAccessIntList() {
public int get(int i) { throw new IndexOutOfBoundsException(); }
public int size() { return 0; }
});
assertNotNull(collection);
assertTrue(!(collection instanceof Serializable));
}
}

View File

@ -0,0 +1,122 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestIntIteratorIterator.java,v 1.1 2003/03/01 00:47:29 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.adapters;
import java.util.Iterator;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.iterators.TestIterator;
import org.apache.commons.collections.primitives.ArrayIntList;
import org.apache.commons.collections.primitives.IntList;
/**
* @version $Revision: 1.1 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestIntIteratorIterator extends TestIterator {
// conventional
// ------------------------------------------------------------------------
public TestIntIteratorIterator(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIntIteratorIterator.class);
}
// collections testing framework
// ------------------------------------------------------------------------
public Object makeObject() {
return makeFullIterator();
}
public Iterator makeEmptyIterator() {
return IntIteratorIterator.wrap(makeEmptyIntList().iterator());
}
public Iterator makeFullIterator() {
return IntIteratorIterator.wrap(makeFullIntList().iterator());
}
protected IntList makeEmptyIntList() {
return new ArrayIntList();
}
protected IntList makeFullIntList() {
IntList list = makeEmptyIntList();
int[] elts = getFullElements();
for(int i=0;i<elts.length;i++) {
list.add(elts[i]);
}
return list;
}
public int[] getFullElements() {
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
// tests
// ------------------------------------------------------------------------
}

View File

@ -0,0 +1,180 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestIntListIteratorListIterator.java,v 1.1 2003/03/01 00:47:29 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.adapters;
import java.util.Iterator;
import java.util.NoSuchElementException;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.iterators.TestIterator;
import org.apache.commons.collections.primitives.ArrayIntList;
import org.apache.commons.collections.primitives.IntList;
/**
* @todo should extend TestListIterator when there is one
* @version $Revision: 1.1 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestIntListIteratorListIterator extends TestIterator {
// conventional
// ------------------------------------------------------------------------
public TestIntListIteratorListIterator(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIntIteratorIterator.class);
}
// collections testing framework
// ------------------------------------------------------------------------
public Object makeObject() {
return makeFullIterator();
}
public Iterator makeEmptyIterator() {
return IntListIteratorListIterator.wrap(makeEmptyIntList().listIterator());
}
public Iterator makeFullIterator() {
return IntListIteratorListIterator.wrap(makeFullIntList().listIterator());
}
protected IntList makeEmptyIntList() {
return new ArrayIntList();
}
protected IntList makeFullIntList() {
IntList list = makeEmptyIntList();
int[] elts = getFullElements();
for(int i=0;i<elts.length;i++) {
list.add(elts[i]);
}
return list;
}
public int[] getFullElements() {
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
// tests
// ------------------------------------------------------------------------
public void testNextHasNextRemove() {
int[] elements = getFullElements();
Iterator iter = makeFullIterator();
for(int i=0;i<elements.length;i++) {
assertTrue(iter.hasNext());
assertEquals(new Integer(elements[i]),iter.next());
if(supportsRemove()) {
iter.remove();
}
}
assertTrue(! iter.hasNext() );
}
public void testEmptyIterator() {
assertTrue( ! makeEmptyIterator().hasNext() );
try {
makeEmptyIterator().next();
fail("Expected NoSuchElementException");
} catch(NoSuchElementException e) {
// expected
}
if(supportsRemove()) {
try {
makeEmptyIterator().remove();
fail("Expected IllegalStateException");
} catch(IllegalStateException e) {
// expected
}
}
}
public void testRemoveBeforeNext() {
if(supportsRemove()) {
try {
makeFullIterator().remove();
fail("Expected IllegalStateException");
} catch(IllegalStateException e) {
// expected
}
}
}
public void testRemoveAfterRemove() {
if(supportsRemove()) {
Iterator iter = makeFullIterator();
iter.next();
iter.remove();
try {
iter.remove();
fail("Expected IllegalStateException");
} catch(IllegalStateException e) {
// expected
}
}
}
}

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestIntListList.java,v 1.1 2003/02/26 19:17:24 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestIntListList.java,v 1.2 2003/03/01 00:47:29 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -57,6 +57,7 @@
package org.apache.commons.collections.primitives.adapters;
import java.io.Serializable;
import java.util.List;
import junit.framework.Test;
@ -64,10 +65,11 @@ import junit.framework.TestSuite;
import org.apache.commons.collections.BulkTest;
import org.apache.commons.collections.TestList;
import org.apache.commons.collections.primitives.AbstractRandomAccessIntList;
import org.apache.commons.collections.primitives.ArrayIntList;
/**
* @version $Revision: 1.1 $ $Date: 2003/02/26 19:17:24 $
* @version $Revision: 1.2 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestIntListList extends TestList {
@ -134,4 +136,22 @@ public class TestIntListList extends TestList {
// need to add a serialized form to cvs
}
public void testWrapNull() {
assertNull(IntListList.wrap(null));
}
public void testWrapSerializable() {
List list = IntListList.wrap(new ArrayIntList());
assertNotNull(list);
assertTrue(list instanceof Serializable);
}
public void testWrapNonSerializable() {
List list = IntListList.wrap(new AbstractRandomAccessIntList() {
public int get(int i) { throw new IndexOutOfBoundsException(); }
public int size() { return 0; }
});
assertNotNull(list);
assertTrue(!(list instanceof Serializable));
}
}

View File

@ -0,0 +1,118 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestIteratorIntIterator.java,v 1.1 2003/03/01 00:47:29 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.adapters;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.primitives.IntIterator;
import org.apache.commons.collections.primitives.TestIntIterator;
/**
* @version $Revision: 1.1 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestIteratorIntIterator extends TestIntIterator {
// conventional
// ------------------------------------------------------------------------
public TestIteratorIntIterator(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIteratorIntIterator.class);
}
// collections testing framework
// ------------------------------------------------------------------------
public IntIterator makeEmptyIntIterator() {
return IteratorIntIterator.wrap(makeEmptyList().iterator());
}
public IntIterator makeFullIntIterator() {
return IteratorIntIterator.wrap(makeFullList().iterator());
}
protected List makeEmptyList() {
return new ArrayList();
}
protected List makeFullList() {
List list = makeEmptyList();
int[] elts = getFullElements();
for(int i=0;i<elts.length;i++) {
list.add(new Integer(elts[i]));
}
return list;
}
public int[] getFullElements() {
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
// tests
// ------------------------------------------------------------------------
}

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestListIntList.java,v 1.2 2003/02/28 00:17:56 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestListIntList.java,v 1.3 2003/03/01 00:47:29 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -57,6 +57,8 @@
package org.apache.commons.collections.primitives.adapters;
import java.io.Serializable;
import java.util.AbstractList;
import java.util.ArrayList;
import junit.framework.Test;
@ -67,7 +69,7 @@ import org.apache.commons.collections.primitives.IntList;
import org.apache.commons.collections.primitives.TestIntList;
/**
* @version $Revision: 1.2 $ $Date: 2003/02/28 00:17:56 $
* @version $Revision: 1.3 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestListIntList extends TestIntList {
@ -134,5 +136,23 @@ public class TestListIntList extends TestIntList {
// XXX FIX ME XXX
// need to add a serialized form to cvs
}
public void testWrapNull() {
assertNull(ListIntList.wrap(null));
}
public void testWrapSerializable() {
IntList list = ListIntList.wrap(new ArrayList());
assertNotNull(list);
assertTrue(list instanceof Serializable);
}
public void testWrapNonSerializable() {
IntList list = ListIntList.wrap(new AbstractList() {
public Object get(int i) { throw new IndexOutOfBoundsException(); }
public int size() { return 0; }
});
assertNotNull(list);
assertTrue(!(list instanceof Serializable));
}
}

View File

@ -0,0 +1,118 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestListIteratorIntListIterator.java,v 1.1 2003/03/01 00:47:29 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.adapters;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.primitives.IntListIterator;
import org.apache.commons.collections.primitives.TestIntListIterator;
/**
* @version $Revision: 1.1 $ $Date: 2003/03/01 00:47:29 $
* @author Rodney Waldhoff
*/
public class TestListIteratorIntListIterator extends TestIntListIterator {
// conventional
// ------------------------------------------------------------------------
public TestListIteratorIntListIterator(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestListIteratorIntListIterator.class);
}
// collections testing framework
// ------------------------------------------------------------------------
public IntListIterator makeEmptyIntListIterator() {
return ListIteratorIntListIterator.wrap(makeEmptyList().listIterator());
}
public IntListIterator makeFullIntListIterator() {
return ListIteratorIntListIterator.wrap(makeFullList().listIterator());
}
protected List makeEmptyList() {
return new ArrayList();
}
protected List makeFullList() {
List list = makeEmptyList();
int[] elts = getFullElements();
for(int i=0;i<elts.length;i++) {
list.add(new Integer(elts[i]));
}
return list;
}
public int[] getFullElements() {
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
// tests
// ------------------------------------------------------------------------
}