http://git-wip-us.apache.org/repos/asf/commons-collections/blob/03ef3163/src/test/org/apache/commons/collections/TestSequencedHashMap.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestSequencedHashMap.java b/src/test/org/apache/commons/collections/TestSequencedHashMap.java deleted file mode 100644 index d213624..0000000 --- a/src/test/org/apache/commons/collections/TestSequencedHashMap.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.apache.commons.collections; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 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 "Apache" and "Apache Software Foundation" and - * "Apache Turbine" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apa...@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache Turbine", nor may "Apache" appear in their name, 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/>. - */ - -import java.util.Iterator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit tests {@link org.apache.commons.collections.SequencedHashMap}. - * - * @author <a href="mailto:d...@collab.net">Daniel Rall</a> - * @author <a href="mailto:h...@intermeta.de">Henning P. Schmiedehausen</a> - * @author <a href="mailto:jstrac...@apache.org">James Strachan</a> - */ -public class TestSequencedHashMap extends TestHashMap -{ - /** - * The instance to experiment on. - */ - protected SequencedHashMap labRat; - - public TestSequencedHashMap(String name) { - super(name); - } - - public static Test suite() { - return new TestSuite(TestSequencedHashMap.class); - } - - public static void main(String[] args[]) { - String[] testCaseName = { TestSequencedHashMap.class.getName() }; - junit.textui.TestRunner.main(testCaseName); - } - - public void setUp() { - super.setUp(); - labRat = new SequencedHashMap(); - } - - public Map makeMap() { - return new SequencedHashMap(); - } - - protected Object[] getKeys() { - return new Object[] { "foo", "baz", "eek" }; - } - - protected Object[] getValues() { - return new Object[] { "bar", "frob", new Object() }; - } - - public void testSequenceMap() throws Throwable { - Object[] keys = getKeys(); - int expectedSize = keys.length; - Object[] values = getValues(); - for (int i = 0; i < expectedSize; i++) { - labRat.put(keys[i], values[i]); - } - - // Test size(). - assertEquals("size() does not match expected size", - expectedSize, labRat.size()); - - // Test clone(), iterator(), and get(Object). - SequencedHashMap clone = (SequencedHashMap) labRat.clone(); - assertEquals("Size of clone does not match original", - labRat.size(), clone.size()); - Iterator origKeys = labRat.keySet().iterator(); - Iterator copiedKeys = clone.keySet().iterator(); - while (origKeys.hasNext()) { - Object origKey = origKeys.next(); - Object copiedKey = copiedKeys.next(); - assertEquals("Cloned key does not match orginal", - origKey, copiedKey); - assertEquals("Cloned value does not match original", - labRat.get(origKey), clone.get(copiedKey)); - } - assertTrue("iterator() returned different number of elements than keys()", - !copiedKeys.hasNext()); - - // Test sequence() - List seq = labRat.sequence(); - assertEquals("sequence() returns more keys than in the Map", - expectedSize, seq.size()); - - for (int i = 0; i < seq.size(); i++) { - assertEquals("Key " + i + " is not the same as the key in the Map", - keys[i], seq.get(i)); - } - } - - public void testYoungest() { - labRat.put(new Integer(1),"foo"); - labRat.put(new Integer(2),"bar"); - assertTrue("first key is correct",labRat.get(0).equals(new Integer(1))); - labRat.put(new Integer(1),"boo"); - assertTrue("second key is reassigned to first",labRat.get(0).equals(new Integer(2))); - } - - public void testYoungestReplaceNullWithValue() { - labRat.put(new Integer(1),null); - labRat.put(new Integer(2),"foo"); - assertTrue("first key is correct",labRat.get(0).equals(new Integer(1))); - labRat.put(new Integer(1),"bar"); - assertTrue("second key is reassigned to first",labRat.get(0).equals(new Integer(2))); - } - - public void testYoungestReplaceValueWithNull() { - labRat.put(new Integer(1),"bar"); - labRat.put(new Integer(2),"foo"); - assertTrue("first key is correct",labRat.get(0).equals(new Integer(1))); - labRat.put(new Integer(1),null); - assertTrue("second key is reassigned to first",labRat.get(0).equals(new Integer(2))); - } - - protected void tearDown() { - labRat = null; - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/03ef3163/src/test/org/apache/commons/collections/TestSingletonIterator.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestSingletonIterator.java b/src/test/org/apache/commons/collections/TestSingletonIterator.java deleted file mode 100644 index b6d0b95..0000000 --- a/src/test/org/apache/commons/collections/TestSingletonIterator.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestSingletonIterator.java,v 1.1 2001/08/22 07:43:53 jstrachan Exp $ - * $Revision: 1.1 $ - * $Date: 2001/08/22 07:43:53 $ - * - * ==================================================================== - * - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2001 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 acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements 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 apa...@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 Group. - * - * 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; - -import junit.framework.*; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * Tests the SingletonIterator to ensure that the next() method will actually - * perform the iteration rather than the hasNext() method. - * - * @author James Strachan - * @version $Id: TestSingletonIterator.java,v 1.1 2001/08/22 07:43:53 jstrachan Exp $ - */ -public class TestSingletonIterator extends TestObject { - - private static final Object testValue = "foo"; - - public static Test suite() { - return new TestSuite(TestSingletonIterator.class); - } - - public TestSingletonIterator(String testName) { - super(testName); - } - - /** - * Return a new, empty {@link Object} to used for testing. - */ - public Object makeObject() { - return new SingletonIterator( testValue ); - } - - public void testIterator() { - Iterator iter = (Iterator) makeObject(); - assertTrue( "Iterator has a first item", iter.hasNext() ); - - Object iterValue = iter.next(); - assertEquals( "Iteration value is correct", testValue, iterValue ); - - assertTrue("Iterator should now be empty", ! iter.hasNext() ); - - try { - Object testValue = iter.next(); - } - catch (Exception e) { - assertTrue("NoSuchElementException must be thrown", - e.getClass().equals((new NoSuchElementException()).getClass())); - } - } -} - http://git-wip-us.apache.org/repos/asf/commons-collections/blob/03ef3163/src/test/org/apache/commons/collections/TestTreeBag.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestTreeBag.java b/src/test/org/apache/commons/collections/TestTreeBag.java deleted file mode 100644 index 930bb77..0000000 --- a/src/test/org/apache/commons/collections/TestTreeBag.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestTreeBag.java,v 1.1 2001/08/29 15:28:07 jstrachan Exp $ - * $Revision: 1.1 $ - * $Date: 2001/08/29 15:28:07 $ - * - * ==================================================================== - * - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2001 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 acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements 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 apa...@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 Group. - * - * 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; - -import junit.framework.*; - -/** - * Extension of {@link TestBag} for exercising the {@link TreeBag} - * implementation. - * - * @author Chuck Burdick - * @version $Id: TestTreeBag.java,v 1.1 2001/08/29 15:28:07 jstrachan Exp $ */ -public class TestTreeBag extends TestBag { - public TestTreeBag(String testName) { - super(testName); - } - - public static Test suite() { - return new TestSuite(TestTreeBag.class); - } - - public static void main(String args[]) { - String[] testCaseName = { TestTreeBag.class.getName() }; - junit.textui.TestRunner.main(testCaseName); - } - - public Bag makeBag() { - return new TreeBag(); - } - - public SortedBag setupBag() { - SortedBag bag = (SortedBag)makeBag(); - bag.add("C"); - bag.add("A"); - bag.add("B"); - bag.add("D"); - return bag; - } - - public void testOrdering() { - Bag bag = setupBag(); - assertEquals("Should get elements in correct order", - "A", bag.toArray()[0]); - assertEquals("Should get elements in correct order", - "B", bag.toArray()[1]); - assertEquals("Should get elements in correct order", - "C", bag.toArray()[2]); - assertEquals("Should get first key", - "A", ((SortedBag)bag).first()); - assertEquals("Should get last key", - "D", ((SortedBag)bag).last()); - } -} - - - - - - -