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. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130445 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fff00791ed
commit
6f129ef861
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestAll.java,v 1.4 2001/04/20 16:54:10 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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.4 $
|
* $Revision: 1.5 $
|
||||||
* $Date: 2001/04/20 16:54:10 $
|
* $Date: 2001/04/21 12:22:30 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -66,7 +66,7 @@ import junit.framework.*;
|
||||||
/**
|
/**
|
||||||
* Entry point for all Collections tests.
|
* Entry point for all Collections tests.
|
||||||
* @author Rodney Waldhoff
|
* @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 class TestAll extends TestCase {
|
||||||
public TestAll(String testName) {
|
public TestAll(String testName) {
|
||||||
|
@ -75,11 +75,17 @@ public class TestAll extends TestCase {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite();
|
TestSuite suite = new TestSuite();
|
||||||
|
suite.addTest(TestArrayList.suite());
|
||||||
suite.addTest(TestArrayStack.suite());
|
suite.addTest(TestArrayStack.suite());
|
||||||
suite.addTest(TestCursorableLinkedList.suite());
|
suite.addTest(TestCursorableLinkedList.suite());
|
||||||
suite.addTest(TestFastArrayList.suite());
|
suite.addTest(TestFastArrayList.suite());
|
||||||
|
suite.addTest(TestFastArrayList1.suite());
|
||||||
suite.addTest(TestFastHashMap.suite());
|
suite.addTest(TestFastHashMap.suite());
|
||||||
|
suite.addTest(TestFastHashMap1.suite());
|
||||||
suite.addTest(TestFastTreeMap.suite());
|
suite.addTest(TestFastTreeMap.suite());
|
||||||
|
suite.addTest(TestFastTreeMap1.suite());
|
||||||
|
suite.addTest(TestHashMap.suite());
|
||||||
|
suite.addTest(TestTreeMap.suite());
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
/*
|
||||||
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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 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 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:jvanzyl@apache.org">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,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestArrayStack.java,v 1.3 2001/04/20 16:54:08 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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.3 $
|
* $Revision: 1.4 $
|
||||||
* $Date: 2001/04/20 16:54:08 $
|
* $Date: 2001/04/21 12:22:30 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -66,10 +66,10 @@ import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Craig McClanahan
|
* @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) {
|
public TestArrayStack(String testName) {
|
||||||
super(testName);
|
super(testName);
|
||||||
|
@ -88,10 +88,11 @@ public class TestArrayStack extends TestList {
|
||||||
return new ArrayStack();
|
return new ArrayStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayStack stack = null;
|
protected ArrayStack stack = null;
|
||||||
|
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
stack = new ArrayStack();
|
stack = (ArrayStack) makeList();
|
||||||
|
list = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNewStack() {
|
public void testNewStack() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestFastArrayList.java,v 1.2 2001/04/20 16:54:06 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2001/04/20 16:54:06 $
|
* $Date: 2001/04/21 12:22:30 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -64,13 +64,14 @@ package org.apache.commons.collections;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
* @author <a href="mailto:jvanzyl@apache.org">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)
|
public TestFastArrayList(String testName)
|
||||||
{
|
{
|
||||||
|
@ -88,43 +89,16 @@ public class TestFastArrayList extends TestList
|
||||||
junit.textui.TestRunner.main(testCaseName);
|
junit.textui.TestRunner.main(testCaseName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FastArrayList list = null;
|
|
||||||
|
|
||||||
public void setUp()
|
public void setUp()
|
||||||
{
|
{
|
||||||
list = new FastArrayList();
|
list = (ArrayList) makeList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List makeList()
|
public List makeList()
|
||||||
{
|
{
|
||||||
return new FastArrayList();
|
FastArrayList fal = new FastArrayList();
|
||||||
|
fal.setFast(false);
|
||||||
|
return (fal);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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 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 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:jvanzyl@apache.org">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,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestFastHashMap.java,v 1.2 2001/04/20 16:54:05 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2001/04/20 16:54:05 $
|
* $Date: 2001/04/21 12:22:30 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -64,13 +64,14 @@ package org.apache.commons.collections;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
* @author <a href="mailto:jvanzyl@apache.org">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)
|
public TestFastHashMap(String testName)
|
||||||
{
|
{
|
||||||
|
@ -89,27 +90,14 @@ public class TestFastHashMap extends TestMap
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map makeMap() {
|
public Map makeMap() {
|
||||||
return new FastHashMap();
|
FastHashMap fhm = new FastHashMap();
|
||||||
|
fhm.setFast(false);
|
||||||
|
return (fhm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FastHashMap map = null;
|
|
||||||
|
|
||||||
public void setUp()
|
public void setUp()
|
||||||
{
|
{
|
||||||
map = new FastHashMap();
|
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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 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 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:jvanzyl@apache.org">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,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestFastTreeMap.java,v 1.2 2001/04/20 16:54:04 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2001/04/20 16:54:04 $
|
* $Date: 2001/04/21 12:22:30 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -65,12 +65,13 @@ import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
|
* @author <a href="mailto:jvanzyl@apache.org">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)
|
public TestFastTreeMap(String testName)
|
||||||
{
|
{
|
||||||
|
@ -89,27 +90,14 @@ public class TestFastTreeMap extends TestMap
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map makeMap() {
|
public Map makeMap() {
|
||||||
return new FastTreeMap();
|
FastTreeMap ftm = new FastTreeMap();
|
||||||
|
ftm.setFast(false);
|
||||||
|
return (ftm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FastTreeMap map = null;
|
|
||||||
|
|
||||||
public void setUp()
|
public void setUp()
|
||||||
{
|
{
|
||||||
map = new FastTreeMap();
|
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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 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 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:jvanzyl@apache.org">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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/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 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 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:jvanzyl@apache.org">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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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 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 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:jvanzyl@apache.org">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");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue