craigmcc 01/04/21 05:22:31 Modified: collections/src/test/org/apache/commons/collections TestAll.java TestArrayStack.java TestFastArrayList.java TestFastHashMap.java TestFastTreeMap.java Added: collections/src/test/org/apache/commons/collections TestArrayList.java TestFastArrayList1.java TestFastHashMap1.java TestFastTreeMap1.java TestHashMap.java TestTreeMap.java Log: Add tests for the standard JDK collection classes (ArrayList, HashMap, TreeMap). These help validate the tests themselves (by proving that they operate as expected against the standard Java APIs), and serve as convenient base classes for testing the "fast" variants. Make TestArrayStack extend TestArrayList so that all standard ArrayList contracts are tested. Test FastArrayList, FastHashMap, and FastTreeMap in both "slow" mode and "fast" mode. Revision Changes Path 1.5 +10 -4 jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java Index: TestAll.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TestAll.java 2001/04/20 16:54:10 1.4 +++ TestAll.java 2001/04/21 12:22:30 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java,v 1.4 2001/04/20 16:54:10 rwaldhoff Exp $ - * $Revision: 1.4 $ - * $Date: 2001/04/20 16:54:10 $ + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java,v 1.5 2001/04/21 12:22:30 craigmcc Exp $ + * $Revision: 1.5 $ + * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * @@ -66,7 +66,7 @@ /** * Entry point for all Collections tests. * @author Rodney Waldhoff - * @version $Id: TestAll.java,v 1.4 2001/04/20 16:54:10 rwaldhoff Exp $ + * @version $Id: TestAll.java,v 1.5 2001/04/21 12:22:30 craigmcc Exp $ */ public class TestAll extends TestCase { public TestAll(String testName) { @@ -75,11 +75,17 @@ public static Test suite() { TestSuite suite = new TestSuite(); + suite.addTest(TestArrayList.suite()); suite.addTest(TestArrayStack.suite()); suite.addTest(TestCursorableLinkedList.suite()); suite.addTest(TestFastArrayList.suite()); + suite.addTest(TestFastArrayList1.suite()); suite.addTest(TestFastHashMap.suite()); + suite.addTest(TestFastHashMap1.suite()); suite.addTest(TestFastTreeMap.suite()); + suite.addTest(TestFastTreeMap1.suite()); + suite.addTest(TestHashMap.suite()); + suite.addTest(TestTreeMap.suite()); return suite; } 1.4 +8 -7 jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayStack.java Index: TestArrayStack.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayStack.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TestArrayStack.java 2001/04/20 16:54:08 1.3 +++ TestArrayStack.java 2001/04/21 12:22:30 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayStack.java,v 1.3 2001/04/20 16:54:08 rwaldhoff Exp $ - * $Revision: 1.3 $ - * $Date: 2001/04/20 16:54:08 $ + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayStack.java,v 1.4 2001/04/21 12:22:30 craigmcc Exp $ + * $Revision: 1.4 $ + * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * @@ -66,10 +66,10 @@ /** * @author Craig McClanahan - * @version $Id: TestArrayStack.java,v 1.3 2001/04/20 16:54:08 rwaldhoff Exp $ + * @version $Id: TestArrayStack.java,v 1.4 2001/04/21 12:22:30 craigmcc Exp $ */ -public class TestArrayStack extends TestList { +public class TestArrayStack extends TestArrayList { public TestArrayStack(String testName) { super(testName); @@ -88,10 +88,11 @@ return new ArrayStack(); } - private ArrayStack stack = null; + protected ArrayStack stack = null; public void setUp() { - stack = new ArrayStack(); + stack = (ArrayStack) makeList(); + list = stack; } public void testNewStack() { 1.3 +10 -36 jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList.java Index: TestFastArrayList.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestFastArrayList.java 2001/04/20 16:54:06 1.2 +++ TestFastArrayList.java 2001/04/21 12:22:30 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList.java,v 1.2 2001/04/20 16:54:06 rwaldhoff Exp $ - * $Revision: 1.2 $ - * $Date: 2001/04/20 16:54:06 $ + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList.java,v 1.3 2001/04/21 12:22:30 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * @@ -64,13 +64,14 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import java.util.ArrayList; import java.util.List; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> - * @version $Id: TestFastArrayList.java,v 1.2 2001/04/20 16:54:06 rwaldhoff Exp $ + * @version $Id: TestFastArrayList.java,v 1.3 2001/04/21 12:22:30 craigmcc Exp $ */ -public class TestFastArrayList extends TestList +public class TestFastArrayList extends TestArrayList { public TestFastArrayList(String testName) { @@ -88,43 +89,16 @@ junit.textui.TestRunner.main(testCaseName); } - private FastArrayList list = null; - public void setUp() { - list = new FastArrayList(); + list = (ArrayList) makeList(); } public List makeList() { - return new FastArrayList(); - } - - public void testNewFastArrayList() - { - assert("New list is empty", list.isEmpty()); - assertEquals("New list has size zero", list.size(), 0); - - try - { - list.get(1); - fail("get(int i) should have thrown IndexOutOfBoundsException"); - } - catch (IndexOutOfBoundsException e) - { - ; // Expected result - } + FastArrayList fal = new FastArrayList(); + fal.setFast(false); + return (fal); } - public void testSearch() - { - list.add("First Item"); - list.add("Last Item"); - assertEquals("First item is 'First Item'", list.get(0), "First Item"); - assertEquals("Last Item is 'Last Item'", list.get(1), "Last Item"); - } - - public void testCollectionEquals() { - // FastArrayList currently doesn't support the List equals contract - } } 1.3 +10 -22 jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastHashMap.java Index: TestFastHashMap.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastHashMap.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestFastHashMap.java 2001/04/20 16:54:05 1.2 +++ TestFastHashMap.java 2001/04/21 12:22:30 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastHashMap.java,v 1.2 2001/04/20 16:54:05 rwaldhoff Exp $ - * $Revision: 1.2 $ - * $Date: 2001/04/20 16:54:05 $ + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastHashMap.java,v 1.3 2001/04/21 12:22:30 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * @@ -64,13 +64,14 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import java.util.HashMap; import java.util.Map; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> - * @version $Id: TestFastHashMap.java,v 1.2 2001/04/20 16:54:05 rwaldhoff Exp $ + * @version $Id: TestFastHashMap.java,v 1.3 2001/04/21 12:22:30 craigmcc Exp $ */ -public class TestFastHashMap extends TestMap +public class TestFastHashMap extends TestHashMap { public TestFastHashMap(String testName) { @@ -89,27 +90,14 @@ } public Map makeMap() { - return new FastHashMap(); + FastHashMap fhm = new FastHashMap(); + fhm.setFast(false); + return (fhm); } - private FastHashMap map = null; - public void setUp() - { - map = new FastHashMap(); - } - - public void testNewMap() { - assert("New map is empty", map.isEmpty()); - assertEquals("New map has size zero", map.size(), 0); + map = (HashMap) makeMap(); } - public void testSearch() - { - map.put("first", "First Item"); - map.put("second", "Second Item"); - assertEquals("Top item is 'Second Item'", map.get("first"), "First Item"); - assertEquals("Next Item is 'First Item'", map.get("second"), "Second Item"); - } } 1.3 +10 -22 jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastTreeMap.java Index: TestFastTreeMap.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastTreeMap.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestFastTreeMap.java 2001/04/20 16:54:04 1.2 +++ TestFastTreeMap.java 2001/04/21 12:22:30 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastTreeMap.java,v 1.2 2001/04/20 16:54:04 rwaldhoff Exp $ - * $Revision: 1.2 $ - * $Date: 2001/04/20 16:54:04 $ + * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastTreeMap.java,v 1.3 2001/04/21 12:22:30 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * @@ -65,12 +65,13 @@ import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.Map; +import java.util.TreeMap; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> - * @version $Id: TestFastTreeMap.java,v 1.2 2001/04/20 16:54:04 rwaldhoff Exp $ + * @version $Id: TestFastTreeMap.java,v 1.3 2001/04/21 12:22:30 craigmcc Exp $ */ -public class TestFastTreeMap extends TestMap +public class TestFastTreeMap extends TestTreeMap { public TestFastTreeMap(String testName) { @@ -89,27 +90,14 @@ } public Map makeMap() { - return new FastTreeMap(); + FastTreeMap ftm = new FastTreeMap(); + ftm.setFast(false); + return (ftm); } - private FastTreeMap map = null; - public void setUp() - { - map = new FastTreeMap(); - } - - public void testNewMap() { - assert("New map is empty", map.isEmpty()); - assertEquals("New map has size zero", map.size(), 0); + map = (TreeMap) makeMap(); } - public void testSearch() - { - map.put("first", "First Item"); - map.put("second", "Second Item"); - assertEquals("Top item is 'Second Item'", map.get("first"), "First Item"); - assertEquals("Next Item is 'First Item'", map.get("second"), "Second Item"); - } } 1.1 jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayList.java Index: TestArrayList.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayList.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * * 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 [EMAIL PROTECTED] * * 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.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.ArrayList; import java.util.List; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @version $Id: TestArrayList.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ */ public class TestArrayList extends TestList { public TestArrayList(String testName) { super(testName); } public static Test suite() { return new TestSuite(TestArrayList.class); } public static void main(String args[]) { String[] testCaseName = { TestArrayList.class.getName() }; junit.textui.TestRunner.main(testCaseName); } protected ArrayList list = null; public void setUp() { list = (ArrayList) makeList(); } public List makeList() { ArrayList al = new ArrayList(); return (al); } public void testNewArrayList() { assert("New list is empty", list.isEmpty()); assertEquals("New list has size zero", list.size(), 0); try { list.get(1); fail("get(int i) should have thrown IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { ; // Expected result } } public void testSearch() { list.add("First Item"); list.add("Last Item"); assertEquals("First item is 'First Item'", list.get(0), "First Item"); assertEquals("Last Item is 'Last Item'", list.get(1), "Last Item"); } } 1.1 jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList1.java Index: TestFastArrayList1.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastArrayList1.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * * 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 [EMAIL PROTECTED] * * 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.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.ArrayList; import java.util.List; /** * Test FastArrayList implementation in <strong>fast</strong> mode. * * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @version $Id: TestFastArrayList1.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ */ public class TestFastArrayList1 extends TestFastArrayList { public TestFastArrayList1(String testName) { super(testName); } public static Test suite() { return new TestSuite(TestFastArrayList1.class); } public static void main(String args[]) { String[] testCaseName = { TestFastArrayList1.class.getName() }; junit.textui.TestRunner.main(testCaseName); } public void setUp() { list = (ArrayList) makeList(); } public List makeList() { FastArrayList fal = new FastArrayList(); fal.setFast(true); return (fal); } } 1.1 jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastHashMap1.java Index: TestFastHashMap1.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastHashMap1.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * * 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 [EMAIL PROTECTED] * * 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.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.HashMap; import java.util.Map; /** * Test FastHashMap in <strong>fast</strong> mode. * * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @version $Id: TestFastHashMap1.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ */ public class TestFastHashMap1 extends TestFastHashMap { public TestFastHashMap1(String testName) { super(testName); } public static Test suite() { return new TestSuite(TestFastHashMap1.class); } public static void main(String args[]) { String[] testCaseName = { TestFastHashMap1.class.getName() }; junit.textui.TestRunner.main(testCaseName); } public Map makeMap() { FastHashMap fhm = new FastHashMap(); fhm.setFast(true); return (fhm); } public void setUp() { map = (HashMap) makeMap(); } } 1.1 jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastTreeMap1.java Index: TestFastTreeMap1.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastTreeMap1.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * * 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 [EMAIL PROTECTED] * * 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.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.Map; import java.util.TreeMap; /** * Test FastTreeMap in <strong>fast</strong> mode. * * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @version $Id: TestFastTreeMap1.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ */ public class TestFastTreeMap1 extends TestFastTreeMap { public TestFastTreeMap1(String testName) { super(testName); } public static Test suite() { return new TestSuite(TestFastTreeMap1.class); } public static void main(String args[]) { String[] testCaseName = { TestFastTreeMap1.class.getName() }; junit.textui.TestRunner.main(testCaseName); } public Map makeMap() { FastTreeMap ftm = new FastTreeMap(); ftm.setFast(true); return (ftm); } public void setUp() { map = (TreeMap) makeMap(); } } 1.1 jakarta-commons/collections/src/test/org/apache/commons/collections/TestHashMap.java Index: TestHashMap.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestHashMap.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * * 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 [EMAIL PROTECTED] * * 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.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.HashMap; import java.util.Map; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @version $Id: TestHashMap.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ */ public class TestHashMap extends TestMap { public TestHashMap(String testName) { super(testName); } public static Test suite() { return new TestSuite(TestHashMap.class); } public static void main(String args[]) { String[] testCaseName = { TestHashMap.class.getName() }; junit.textui.TestRunner.main(testCaseName); } public Map makeMap() { HashMap hm = new HashMap(); return (hm); } protected HashMap map = null; public void setUp() { map = (HashMap) makeMap(); } public void testNewMap() { assert("New map is empty", map.isEmpty()); assertEquals("New map has size zero", map.size(), 0); } public void testSearch() { map.put("first", "First Item"); map.put("second", "Second Item"); assertEquals("Top item is 'Second Item'", map.get("first"), "First Item"); assertEquals("Next Item is 'First Item'", map.get("second"), "Second Item"); } } 1.1 jakarta-commons/collections/src/test/org/apache/commons/collections/TestTreeMap.java Index: TestTreeMap.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestTreeMap.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/04/21 12:22:30 $ * * ==================================================================== * * 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 [EMAIL PROTECTED] * * 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.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.TreeMap; import java.util.Map; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @version $Id: TestTreeMap.java,v 1.1 2001/04/21 12:22:30 craigmcc Exp $ */ public class TestTreeMap extends TestMap { public TestTreeMap(String testName) { super(testName); } public static Test suite() { return new TestSuite(TestTreeMap.class); } public static void main(String args[]) { String[] testCaseName = { TestTreeMap.class.getName() }; junit.textui.TestRunner.main(testCaseName); } public Map makeMap() { TreeMap tm = new TreeMap(); return (tm); } protected TreeMap map = null; public void setUp() { map = (TreeMap) makeMap(); } public void testNewMap() { assert("New map is empty", map.isEmpty()); assertEquals("New map has size zero", map.size(), 0); } public void testSearch() { map.put("first", "First Item"); map.put("second", "Second Item"); assertEquals("Top item is 'Second Item'", map.get("first"), "First Item"); assertEquals("Next Item is 'First Item'", map.get("second"), "Second Item"); } }