merged with HEAD

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/branches/collections_1_x_branch@130605 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Morgan James Delagrange 2002-02-26 20:23:10 +00:00
parent 37f759c0a8
commit a1fdbead61
14 changed files with 177 additions and 99 deletions

View File

@ -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.15.2.3 2002/02/26 06:17:51 morgand Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestAll.java,v 1.15.2.4 2002/02/26 20:23:10 morgand Exp $
* $Revision: 1.15.2.3 $ * $Revision: 1.15.2.4 $
* $Date: 2002/02/26 06:17:51 $ * $Date: 2002/02/26 20:23:10 $
* *
* ==================================================================== * ====================================================================
* *
@ -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.15.2.3 2002/02/26 06:17:51 morgand Exp $ * @version $Id: TestAll.java,v 1.15.2.4 2002/02/26 20:23:10 morgand Exp $
*/ */
public class TestAll extends TestCase { public class TestAll extends TestCase {
public TestAll(String testName) { public TestAll(String testName) {
@ -76,7 +76,6 @@ public class TestAll extends TestCase {
public static Test suite() { public static Test suite() {
TestSuite suite = new TestSuite(); TestSuite suite = new TestSuite();
suite.addTest(TestArrayIterator.suite()); suite.addTest(TestArrayIterator.suite());
suite.addTest(TestArrayList.suite());
suite.addTest(TestArrayStack.suite()); suite.addTest(TestArrayStack.suite());
suite.addTest(TestCollectionUtils.suite()); suite.addTest(TestCollectionUtils.suite());
suite.addTest(TestCursorableLinkedList.suite()); suite.addTest(TestCursorableLinkedList.suite());

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestArrayList.java,v 1.2 2001/07/14 23:33:26 craigmcc Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestArrayList.java,v 1.2.2.1 2002/02/26 20:23:10 morgand Exp $
* $Revision: 1.2 $ * $Revision: 1.2.2.1 $
* $Date: 2001/07/14 23:33:26 $ * $Date: 2002/02/26 20:23:10 $
* *
* ==================================================================== * ====================================================================
* *
@ -69,9 +69,9 @@ 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: TestArrayList.java,v 1.2 2001/07/14 23:33:26 craigmcc Exp $ * @version $Id: TestArrayList.java,v 1.2.2.1 2002/02/26 20:23:10 morgand Exp $
*/ */
public class TestArrayList extends TestList public abstract class TestArrayList extends TestList
{ {
public TestArrayList(String testName) public TestArrayList(String testName)
{ {
@ -93,13 +93,7 @@ public class TestArrayList extends TestList
public void setUp() public void setUp()
{ {
list = (ArrayList) makeList(); list = (ArrayList) makeEmptyList();
}
public List makeList()
{
ArrayList al = new ArrayList();
return (al);
} }
public void testNewArrayList() public void testNewArrayList()

View File

@ -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.5 2001/07/14 23:33:26 craigmcc Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestArrayStack.java,v 1.5.2.1 2002/02/26 20:23:10 morgand Exp $
* $Revision: 1.5 $ * $Revision: 1.5.2.1 $
* $Date: 2001/07/14 23:33:26 $ * $Date: 2002/02/26 20:23:10 $
* *
* ==================================================================== * ====================================================================
* *
@ -66,7 +66,7 @@ import java.util.*;
/** /**
* @author Craig McClanahan * @author Craig McClanahan
* @version $Id: TestArrayStack.java,v 1.5 2001/07/14 23:33:26 craigmcc Exp $ * @version $Id: TestArrayStack.java,v 1.5.2.1 2002/02/26 20:23:10 morgand Exp $
*/ */
public class TestArrayStack extends TestArrayList { public class TestArrayStack extends TestArrayList {
@ -84,14 +84,14 @@ public class TestArrayStack extends TestArrayList {
junit.textui.TestRunner.main(testCaseName); junit.textui.TestRunner.main(testCaseName);
} }
public List makeList() { public List makeEmptyList() {
return new ArrayStack(); return new ArrayStack();
} }
protected ArrayStack stack = null; protected ArrayStack stack = null;
public void setUp() { public void setUp() {
stack = (ArrayStack) makeList(); stack = (ArrayStack) makeEmptyList();
list = stack; list = stack;
} }

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestCursorableLinkedList.java,v 1.3 2001/07/14 23:33:27 craigmcc Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestCursorableLinkedList.java,v 1.3.2.1 2002/02/26 20:23:10 morgand Exp $
* $Revision: 1.3 $ * $Revision: 1.3.2.1 $
* $Date: 2001/07/14 23:33:27 $ * $Date: 2002/02/26 20:23:10 $
* *
* ==================================================================== * ====================================================================
* *
@ -66,7 +66,7 @@ import java.util.*;
/** /**
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @version $Id: TestCursorableLinkedList.java,v 1.3 2001/07/14 23:33:27 craigmcc Exp $ * @version $Id: TestCursorableLinkedList.java,v 1.3.2.1 2002/02/26 20:23:10 morgand Exp $
*/ */
public class TestCursorableLinkedList extends TestList { public class TestCursorableLinkedList extends TestList {
public TestCursorableLinkedList(String testName) { public TestCursorableLinkedList(String testName) {
@ -88,7 +88,7 @@ public class TestCursorableLinkedList extends TestList {
list = new CursorableLinkedList(); list = new CursorableLinkedList();
} }
public List makeList() { public List makeEmptyList() {
return new CursorableLinkedList(); return new CursorableLinkedList();
} }

View File

@ -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.3 2001/04/21 12:22:30 craigmcc 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.2.1 2002/02/26 20:23:10 morgand Exp $
* $Revision: 1.3 $ * $Revision: 1.3.2.1 $
* $Date: 2001/04/21 12:22:30 $ * $Date: 2002/02/26 20:23:10 $
* *
* ==================================================================== * ====================================================================
* *
@ -69,7 +69,7 @@ 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.3 2001/04/21 12:22:30 craigmcc Exp $ * @version $Id: TestFastArrayList.java,v 1.3.2.1 2002/02/26 20:23:10 morgand Exp $
*/ */
public class TestFastArrayList extends TestArrayList public class TestFastArrayList extends TestArrayList
{ {
@ -91,10 +91,10 @@ public class TestFastArrayList extends TestArrayList
public void setUp() public void setUp()
{ {
list = (ArrayList) makeList(); list = (ArrayList) makeEmptyList();
} }
public List makeList() public List makeEmptyList()
{ {
FastArrayList fal = new FastArrayList(); FastArrayList fal = new FastArrayList();
fal.setFast(false); fal.setFast(false);

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestList.java,v 1.5 2001/07/14 23:33:27 craigmcc Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestList.java,v 1.5.2.1 2002/02/26 20:23:10 morgand Exp $
* $Revision: 1.5 $ * $Revision: 1.5.2.1 $
* $Date: 2001/07/14 23:33:27 $ * $Date: 2002/02/26 20:23:10 $
* *
* ==================================================================== * ====================================================================
* *
@ -62,6 +62,8 @@
package org.apache.commons.collections; package org.apache.commons.collections;
import junit.framework.*; import junit.framework.*;
import java.io.IOException;
import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Collection; import java.util.Collection;
import java.util.Arrays; import java.util.Arrays;
@ -80,7 +82,7 @@ import java.util.ListIterator;
* test case (method) your {@link List} fails. * test case (method) your {@link List} fails.
* *
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @version $Id: TestList.java,v 1.5 2001/07/14 23:33:27 craigmcc Exp $ * @version $Id: TestList.java,v 1.5.2.1 2002/02/26 20:23:10 morgand Exp $
*/ */
public abstract class TestList extends TestCollection { public abstract class TestList extends TestCollection {
public TestList(String testName) { public TestList(String testName) {
@ -90,14 +92,30 @@ public abstract class TestList extends TestCollection {
/** /**
* Return a new, empty {@link List} to used for testing. * Return a new, empty {@link List} to used for testing.
*/ */
public abstract List makeList(); public abstract List makeEmptyList();
public List makeFullList() {
// only works if list supports optional "add(Object)"
// and "add(int,Object)" operations
List list = makeEmptyList();
list.add("1");
// must be able to add to the end this way
list.add(list.size(),"4");
// must support duplicates
list.add("1");
// must support insertions
list.add(1,"3");
// resultant list: 1, 3, 4, 1
return list;
}
public Collection makeCollection() { public Collection makeCollection() {
return makeList(); return makeEmptyList();
} }
public void testListAddByIndexBoundsChecking() { public void testListAddByIndexBoundsChecking() {
List list = makeList(); List list = makeEmptyList();
try { try {
list.add(Integer.MIN_VALUE,"element"); list.add(Integer.MIN_VALUE,"element");
@ -153,7 +171,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListAddByIndexBoundsChecking2() { public void testListAddByIndexBoundsChecking2() {
List list = makeList(); List list = makeEmptyList();
boolean added = tryToAdd(list,"element"); boolean added = tryToAdd(list,"element");
try { try {
@ -184,7 +202,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListAddByIndex() { public void testListAddByIndex() {
List list = makeList(); List list = makeEmptyList();
assertEquals(0,list.size()); assertEquals(0,list.size());
if(tryToAdd(list,0,"element2")) { if(tryToAdd(list,0,"element2")) {
assertEquals(1,list.size()); assertEquals(1,list.size());
@ -201,7 +219,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListAdd() { public void testListAdd() {
List list = makeList(); List list = makeEmptyList();
if(tryToAdd(list,"1")) { if(tryToAdd(list,"1")) {
assertTrue(list.contains("1")); assertTrue(list.contains("1"));
if(tryToAdd(list,"2")) { if(tryToAdd(list,"2")) {
@ -223,7 +241,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListEqualsSelf() { public void testListEqualsSelf() {
List list = makeList(); List list = makeEmptyList();
assertTrue(list.equals(list)); assertTrue(list.equals(list));
tryToAdd(list,"elt"); tryToAdd(list,"elt");
assertTrue(list.equals(list)); assertTrue(list.equals(list));
@ -232,7 +250,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListEqualsArrayList() { public void testListEqualsArrayList() {
List list1 = makeList(); List list1 = makeEmptyList();
List list2 = new ArrayList(); List list2 = new ArrayList();
assertTrue(list1.equals(list2)); assertTrue(list1.equals(list2));
assertEquals(list1.hashCode(),list2.hashCode()); assertEquals(list1.hashCode(),list2.hashCode());
@ -252,8 +270,8 @@ public abstract class TestList extends TestCollection {
} }
public void testListEquals() { public void testListEquals() {
List list1 = makeList(); List list1 = makeEmptyList();
List list2 = makeList(); List list2 = makeEmptyList();
assertTrue(list1.equals(list2)); assertTrue(list1.equals(list2));
if(tryToAdd(list1,"a") && tryToAdd(list2,"a")) { if(tryToAdd(list1,"a") && tryToAdd(list2,"a")) {
assertTrue(list1.equals(list2)); assertTrue(list1.equals(list2));
@ -270,7 +288,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListGetByIndex() { public void testListGetByIndex() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"a"); tryToAdd(list,"a");
tryToAdd(list,"b"); tryToAdd(list,"b");
tryToAdd(list,"c"); tryToAdd(list,"c");
@ -284,7 +302,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListGetByIndexBoundsChecking() { public void testListGetByIndexBoundsChecking() {
List list = makeList(); List list = makeEmptyList();
try { try {
list.get(Integer.MIN_VALUE); list.get(Integer.MIN_VALUE);
@ -323,7 +341,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListGetByIndexBoundsChecking2() { public void testListGetByIndexBoundsChecking2() {
List list = makeList(); List list = makeEmptyList();
boolean added = tryToAdd(list,"a"); boolean added = tryToAdd(list,"a");
try { try {
@ -356,7 +374,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListIndexOf() { public void testListIndexOf() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"a"); tryToAdd(list,"a");
tryToAdd(list,"b"); tryToAdd(list,"b");
tryToAdd(list,"c"); tryToAdd(list,"c");
@ -371,7 +389,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListLastIndexOf1() { public void testListLastIndexOf1() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"a"); tryToAdd(list,"a");
tryToAdd(list,"b"); tryToAdd(list,"b");
tryToAdd(list,"c"); tryToAdd(list,"c");
@ -386,7 +404,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListLastIndexOf2() { public void testListLastIndexOf2() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"a"); tryToAdd(list,"a");
tryToAdd(list,"b"); tryToAdd(list,"b");
tryToAdd(list,"c"); tryToAdd(list,"c");
@ -434,7 +452,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListSetByIndexBoundsChecking() { public void testListSetByIndexBoundsChecking() {
List list = makeList(); List list = makeEmptyList();
try { try {
list.set(Integer.MIN_VALUE,"a"); list.set(Integer.MIN_VALUE,"a");
@ -503,7 +521,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListSetByIndexBoundsChecking2() { public void testListSetByIndexBoundsChecking2() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"element"); tryToAdd(list,"element");
tryToAdd(list,"element2"); tryToAdd(list,"element2");
@ -561,7 +579,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListSetByIndex() { public void testListSetByIndex() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"element"); tryToAdd(list,"element");
tryToAdd(list,"element2"); tryToAdd(list,"element2");
tryToAdd(list,"element3"); tryToAdd(list,"element3");
@ -586,7 +604,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListRemoveByIndex() { public void testListRemoveByIndex() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"element"); tryToAdd(list,"element");
tryToAdd(list,"element2"); tryToAdd(list,"element2");
tryToAdd(list,"element3"); tryToAdd(list,"element3");
@ -615,7 +633,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListRemoveByValue() { public void testListRemoveByValue() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"element1"); tryToAdd(list,"element1");
tryToAdd(list,"element2"); tryToAdd(list,"element2");
tryToAdd(list,"element3"); tryToAdd(list,"element3");
@ -637,7 +655,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListListIteratorNextPrev() { public void testListListIteratorNextPrev() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"element1"); tryToAdd(list,"element1");
tryToAdd(list,"element2"); tryToAdd(list,"element2");
tryToAdd(list,"element3"); tryToAdd(list,"element3");
@ -667,7 +685,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListListIteratorNextIndexPrevIndex() { public void testListListIteratorNextIndexPrevIndex() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"element1"); tryToAdd(list,"element1");
tryToAdd(list,"element2"); tryToAdd(list,"element2");
tryToAdd(list,"element3"); tryToAdd(list,"element3");
@ -689,7 +707,7 @@ public abstract class TestList extends TestCollection {
} }
public void testListListIteratorSet() { public void testListListIteratorSet() {
List list = makeList(); List list = makeEmptyList();
tryToAdd(list,"element1"); tryToAdd(list,"element1");
tryToAdd(list,"element2"); tryToAdd(list,"element2");
tryToAdd(list,"element3"); tryToAdd(list,"element3");
@ -782,4 +800,66 @@ public abstract class TestList extends TestCollection {
} }
} }
public void testEmptyListSerialization()
throws IOException, ClassNotFoundException {
List list = makeEmptyList();
if (!(list instanceof Serializable)) return;
byte[] objekt = writeExternalFormToBytes((Serializable) list);
List list2 = (List) readExternalFormFromBytes(objekt);
assertTrue("Both lists are empty",list.size() == 0);
assertTrue("Both lists are empty",list2.size() == 0);
}
public void testFullListSerialization()
throws IOException, ClassNotFoundException {
List list = makeFullList();
if (!(list instanceof Serializable)) return;
byte[] objekt = writeExternalFormToBytes((Serializable) list);
List list2 = (List) readExternalFormFromBytes(objekt);
assertEquals("Both lists are same size",list.size(), 4);
assertEquals("Both lists are same size",list2.size(),4);
}
/**
* Compare the current serialized form of the List
* against the canonical version in CVS.
*/
public void testEmptyListCompatibility() throws IOException, ClassNotFoundException {
/**
* Create canonical objects with this code
List list = makeEmptyList();
if (!(list instanceof Serializable)) return;
writeExternalFormToDisk((Serializable) list, getCanonicalEmptyCollectionName(list));
*/
// test to make sure the canonical form has been preserved
if (!(makeEmptyList() instanceof Serializable)) return;
List list = (List) readExternalFormFromDisk(getCanonicalEmptyCollectionName(makeEmptyList()));
assertTrue("List is empty",list.size() == 0);
}
/**
* Compare the current serialized form of the List
* against the canonical version in CVS.
*/
public void testFullListCompatibility() throws IOException, ClassNotFoundException {
/**
* Create canonical objects with this code
List list = makeFullList();
if (!(list instanceof Serializable)) return;
writeExternalFormToDisk((Serializable) list, getCanonicalFullCollectionName(list));
*/
// test to make sure the canonical form has been preserved
if (!(makeFullList() instanceof Serializable)) return;
List list = (List) readExternalFormFromDisk(getCanonicalFullCollectionName(makeFullList()));
assertEquals("List is the right size",list.size(), 4);
}
} }

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.3.2.3 2002/02/26 06:28:41 morgand Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.3.2.4 2002/02/26 20:18:53 morgand Exp $
* $Revision: 1.3.2.3 $ * $Revision: 1.3.2.4 $
* $Date: 2002/02/26 06:28:41 $ * $Date: 2002/02/26 20:18:53 $
* *
* ==================================================================== * ====================================================================
* *
@ -87,7 +87,7 @@ import java.util.NoSuchElementException;
* *
* @author Michael Smith * @author Michael Smith
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @version $Id: TestMap.java,v 1.3.2.3 2002/02/26 06:28:41 morgand Exp $ * @version $Id: TestMap.java,v 1.3.2.4 2002/02/26 20:18:53 morgand Exp $
*/ */
public abstract class TestMap extends TestObject { public abstract class TestMap extends TestObject {
@ -929,31 +929,6 @@ public abstract class TestMap extends TestObject {
assertEquals("Both maps are same size",map2.size(),getSampleKeys().length); assertEquals("Both maps are same size",map2.size(),getSampleKeys().length);
} }
public String getCanonicalEmptyMapName(Map map) {
StringBuffer retval = new StringBuffer();
retval.append("data/test/");
String mapName = map.getClass().getName();
mapName = mapName.substring(mapName.lastIndexOf(".")+1,mapName.length());
retval.append(mapName);
retval.append(".emptyMap.version");
retval.append(getCompatibilityVersion());
retval.append(".obj");
return retval.toString();
}
public String getCanonicalFullMapName(Map map) {
StringBuffer retval = new StringBuffer();
retval.append("data/test/");
String mapName = map.getClass().getName();
mapName = mapName.substring(mapName.lastIndexOf(".")+1,mapName.length());
retval.append(mapName);
retval.append(".fullMap.version");
retval.append(getCompatibilityVersion());
retval.append(".obj");
return retval.toString();
}
/** /**
* Compare the current serialized form of the Map * Compare the current serialized form of the Map
* against the canonical version in CVS. * against the canonical version in CVS.
@ -965,12 +940,12 @@ public abstract class TestMap extends TestObject {
map = makeEmptyMap(); map = makeEmptyMap();
if (!(map instanceof Serializable)) return; if (!(map instanceof Serializable)) return;
writeExternalFormToDisk((Serializable) map, getCanonicalEmptyMapName(map)); writeExternalFormToDisk((Serializable) map, getCanonicalEmptyCollectionName(map));
*/ */
// test to make sure the canonical form has been preserved // test to make sure the canonical form has been preserved
if (!(makeEmptyMap() instanceof Serializable)) return; if (!(makeEmptyMap() instanceof Serializable)) return;
map = (Map) readExternalFormFromDisk(getCanonicalEmptyMapName(makeEmptyMap())); map = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(makeEmptyMap()));
assertTrue("Map is empty",map.isEmpty() == true); assertTrue("Map is empty",map.isEmpty() == true);
} }
@ -986,12 +961,12 @@ public abstract class TestMap extends TestObject {
map = makeFullMap(); map = makeFullMap();
if (!(map instanceof Serializable)) return; if (!(map instanceof Serializable)) return;
writeExternalFormToDisk((Serializable) map, getCanonicalFullMapName(map)); writeExternalFormToDisk((Serializable) map, getCanonicalFullCollectionName(map));
*/ */
// test to make sure the canonical form has been preserved // test to make sure the canonical form has been preserved
if (!(makeFullMap() instanceof Serializable)) return; if (!(makeFullMap() instanceof Serializable)) return;
map = (Map) readExternalFormFromDisk(getCanonicalFullMapName(makeFullMap())); map = (Map) readExternalFormFromDisk(getCanonicalFullCollectionName(makeFullMap()));
assertEquals("Map is the right size",map.size(), getSampleKeys().length); assertEquals("Map is the right size",map.size(), getSampleKeys().length);
} }

View File

@ -1,7 +1,13 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestObject.java,v 1.1.2.1 2002/02/26 00:48:14 morgand Exp $ <<<<<<< TestObject.java
* $Revision: 1.1.2.1 $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestObject.java,v 1.1.2.2 2002/02/26 20:18:53 morgand Exp $
* $Date: 2002/02/26 00:48:14 $ * $Revision: 1.1.2.2 $
* $Date: 2002/02/26 20:18:53 $
=======
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestObject.java,v 1.1.2.2 2002/02/26 20:18:53 morgand Exp $
* $Revision: 1.1.2.2 $
* $Date: 2002/02/26 20:18:53 $
>>>>>>> 1.8
* *
* ==================================================================== * ====================================================================
* *
@ -90,7 +96,7 @@ import java.util.NoSuchElementException;
* test case (method) your {@link Object} fails. * test case (method) your {@link Object} fails.
* *
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @version $Id: TestObject.java,v 1.1.2.1 2002/02/26 00:48:14 morgand Exp $ * @version $Id: TestObject.java,v 1.1.2.2 2002/02/26 20:18:53 morgand Exp $
*/ */
public abstract class TestObject extends TestCase { public abstract class TestObject extends TestCase {
public TestObject(String testName) { public TestObject(String testName) {
@ -235,4 +241,28 @@ public abstract class TestObject extends TestCase {
Object p = readExternalFormFromBytes(objekt); Object p = readExternalFormFromBytes(objekt);
} }
} }
public String getCanonicalEmptyCollectionName(Object object) {
StringBuffer retval = new StringBuffer();
retval.append("data/test/");
String colName = object.getClass().getName();
colName = colName.substring(colName.lastIndexOf(".")+1,colName.length());
retval.append(colName);
retval.append(".emptyCollection.version");
retval.append(getCompatibilityVersion());
retval.append(".obj");
return retval.toString();
}
public String getCanonicalFullCollectionName(Object object) {
StringBuffer retval = new StringBuffer();
retval.append("data/test/");
String colName = object.getClass().getName();
colName = colName.substring(colName.lastIndexOf(".")+1,colName.length());
retval.append(colName);
retval.append(".fullCollection.version");
retval.append(getCompatibilityVersion());
retval.append(".obj");
return retval.toString();
}
} }