You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by fr...@apache.org on 2002/01/21 23:02:25 UTC
cvs commit: jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore TestStore.java TestJispFilesystemStore.java TestSoftRefMemoryStore.java TestMRUMemoryStore.java TestAll.java TestMap.java
froehlich 02/01/21 14:02:25
Modified: simplestore/src/test/org/apache/commons/simplestore
TestSoftRefMemoryStore.java TestMRUMemoryStore.java
TestAll.java
Added: simplestore/src/test/org/apache/commons/simplestore
TestStore.java TestJispFilesystemStore.java
Removed: simplestore/src/test/org/apache/commons/simplestore
TestMap.java
Log:
some new features (or bugs):
a) added TestJispFilesystemstore junit test case
b) changed the Store interface, extending from java.util.Map
was to much, indeed (thx Juozas)
c) added a constructor in the JispFilesystemStore, because -well-
Revision Changes Path
1.3 +17 -17 jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestSoftRefMemoryStore.java
Index: TestSoftRefMemoryStore.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestSoftRefMemoryStore.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestSoftRefMemoryStore.java 20 Jan 2002 14:30:20 -0000 1.2
+++ TestSoftRefMemoryStore.java 21 Jan 2002 22:02:25 -0000 1.3
@@ -17,9 +17,9 @@
/**
* @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
* g-froehlich@gmx.de</a>
- * @version $Id: TestSoftRefMemoryStore.java,v 1.2 2002/01/20 14:30:20 froehlich Exp $
+ * @version $Id: TestSoftRefMemoryStore.java,v 1.3 2002/01/21 22:02:25 froehlich Exp $
*/
-public class TestSoftRefMemoryStore extends TestMap
+public class TestSoftRefMemoryStore extends TestStore
{
public TestSoftRefMemoryStore(String testName) {
super(testName);
@@ -34,34 +34,34 @@
junit.textui.TestRunner.main(testCaseName);
}
- public Map makeMap() {
+ public Store makeStore() {
MRUMemoryStore mrustore = new MRUMemoryStore(10);
- SoftRefMemoryStore store = new SoftRefMemoryStore(mrustore,10);
- return store;
+ SoftRefMemoryStore softstore = new SoftRefMemoryStore(mrustore,10);
+ return softstore;
}
public void setUp() {
- map = makeMap();
+ store = makeStore();
}
- public void testNewMap() {
- assertTrue("New map is empty", map.isEmpty());
- assertEquals("New map has size zero", map.size(), 0);
+ public void testNewStore() {
+ assertTrue("New store is empty", store.isEmpty());
+ assertEquals("New store has size zero", store.size(), 0);
}
public void testSearch() {
System.out.println("Testing MRUMemoryStore with WeakReferences");
- map.put("first", "First Item");
- map.put("second", "Second Item");
+ store.put("first", "First Item");
+ store.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");
+ assertEquals("Top item is 'Second Item'", store.get("first"), "First Item");
+ assertEquals("Next Item is 'First Item'", store.get("second"), "Second Item");
- map.remove("first");
- map.remove("second");
+ store.remove("first");
+ store.remove("second");
- assertTrue("Map is empty, now", map.isEmpty());
- assertEquals("Map has size zero, now", map.size(), 0);
+ assertTrue("Map is empty, now", store.isEmpty());
+ assertEquals("Map has size zero, now", store.size(), 0);
}
}
1.3 +13 -13 jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestMRUMemoryStore.java
Index: TestMRUMemoryStore.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestMRUMemoryStore.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestMRUMemoryStore.java 20 Jan 2002 14:25:47 -0000 1.2
+++ TestMRUMemoryStore.java 21 Jan 2002 22:02:25 -0000 1.3
@@ -17,9 +17,9 @@
/**
* @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
* g-froehlich@gmx.de</a>
- * @version $Id: TestMRUMemoryStore.java,v 1.2 2002/01/20 14:25:47 froehlich Exp $
+ * @version $Id: TestMRUMemoryStore.java,v 1.3 2002/01/21 22:02:25 froehlich Exp $
*/
-public class TestMRUMemoryStore extends TestMap
+public class TestMRUMemoryStore extends TestStore
{
public TestMRUMemoryStore(String testName) {
super(testName);
@@ -34,26 +34,26 @@
junit.textui.TestRunner.main(testCaseName);
}
- public Map makeMap() {
- MRUMemoryStore store = new MRUMemoryStore(10);
- return store;
+ public Store makeStore() {
+ MRUMemoryStore mrustore = new MRUMemoryStore(10);
+ return mrustore;
}
public void setUp() {
- map = makeMap();
+ store = makeStore();
}
- public void testNewMap() {
- assertTrue("New map is empty", map.isEmpty());
- assertEquals("New map has size zero", map.size(), 0);
+ public void testNewStore() {
+ assertTrue("New store is empty", store.isEmpty());
+ assertEquals("New store has size zero", store.size(), 0);
}
public void testSearch() {
System.out.println("Testing MRUMemoryStore plain");
- 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");
+ store.put("first", "First Item");
+ store.put("second", "Second Item");
+ assertEquals("Top item is 'Second Item'", store.get("first"), "First Item");
+ assertEquals("Next Item is 'First Item'", store.get("second"), "Second Item");
}
}
1.3 +2 -2 jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestAll.java
Index: TestAll.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestAll.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestAll.java 20 Jan 2002 14:25:47 -0000 1.2
+++ TestAll.java 21 Jan 2002 22:02:25 -0000 1.3
@@ -13,7 +13,7 @@
/**
* @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
* g-froehlich@gmx.de</a>
- * @version $Id: TestAll.java,v 1.2 2002/01/20 14:25:47 froehlich Exp $
+ * @version $Id: TestAll.java,v 1.3 2002/01/21 22:02:25 froehlich Exp $
*/
public class TestAll extends TestCase {
public TestAll(String testName) {
@@ -24,7 +24,7 @@
TestSuite suite = new TestSuite();
suite.addTest(TestSoftRefMemoryStore.suite());
suite.addTest(TestMRUMemoryStore.suite());
- //suite.addTest(JispFilesystemStore.suite());
+ suite.addTest(TestJispFilesystemStore.suite());
return suite;
}
1.1 jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestStore.java
Index: TestStore.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.commons.simplestore;
import junit.framework.*;
import java.util.Map;
import java.util.Collection;
/**
* @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
* g-froehlich@gmx.de</a>
*
* @version $Id: TestStore.java,v 1.1 2002/01/21 22:02:25 froehlich Exp $
*/
public abstract class TestStore extends TestObject {
public TestStore(String testName) {
super(testName);
}
protected Store store = null;
/**
* Return a new, empty {@link Map} to used for testing.
*/
public abstract Store makeStore();
public Object makeObject() {
return makeStore();
}
/**
* Try to put the given pair into the given Collection.
*
* Fails any Throwable except UnsupportedOperationException,
* ClassCastException, or IllegalArgumentException
* or NullPointerException is thrown.
*/
protected void tryToPut(Store store, Object key, Object val) {
try {
store.put(key,val);
} catch(UnsupportedOperationException e) {
} catch(ClassCastException e) {
} catch(IllegalArgumentException e) {
} catch(NullPointerException e) {
} catch(Throwable t) {
t.printStackTrace();
fail("Store.put should only throw UnsupportedOperationException, ClassCastException, IllegalArgumentException or NullPointerException. Found " + t.toString());
}
}
}
1.1 jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestJispFilesystemStore.java
Index: TestJispFilesystemStore.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.commons.simplestore;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.util.Map;
import java.util.HashMap;
/**
* @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
* g-froehlich@gmx.de</a>
* @version $Id: TestJispFilesystemStore.java,v 1.1 2002/01/21 22:02:25 froehlich Exp $
*/
public class TestJispFilesystemStore extends TestStore
{
public TestJispFilesystemStore(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestJispFilesystemStore.class);
}
public static void main(String args[]) {
String[] testCaseName = { TestJispFilesystemStore.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
public Store makeStore() {
JispFilesystemStore jispstore = new JispFilesystemStore("c:\\temp",
"data.dat",
"index.idx",
11);
return jispstore;
}
public void setUp() {
store = makeStore();
}
public void testNewStore() {
//assertTrue("New store is empty", store.isEmpty());
//assertEquals("New store has size zero", store.size(), 0);
}
public void testSearch() {
System.out.println("Testing JispFilesystemStore plain");
store.put("first", "First Item");
store.put("second", "Second Item");
assertEquals("Top item is 'Second Item'", store.get("first"), "First Item");
assertEquals("Next Item is 'First Item'", store.get("second"), "Second Item");
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>