You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2004/02/02 17:55:10 UTC
cvs commit: avalon-excalibur/store/src/test/org/apache/excalibur/store/impl ClearJispFilesystemStoreTestCase.java
leosutic 2004/02/02 08:55:10
Modified: store/src/test/org/apache/excalibur/store/impl
ClearJispFilesystemStoreTestCase.java
Log:
Applied patches for bug 25482
Revision Changes Path
1.2 +54 -80 avalon-excalibur/store/src/test/org/apache/excalibur/store/impl/ClearJispFilesystemStoreTestCase.java
Index: ClearJispFilesystemStoreTestCase.java
===================================================================
RCS file: /home/cvs/avalon-excalibur/store/src/test/org/apache/excalibur/store/impl/ClearJispFilesystemStoreTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClearJispFilesystemStoreTestCase.java 13 Dec 2003 04:18:41 -0000 1.1
+++ ClearJispFilesystemStoreTestCase.java 2 Feb 2004 16:55:10 -0000 1.2
@@ -1,52 +1,3 @@
-/*
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Jakarta", "Apache Avalon", "Avalon Framework" 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 name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, 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.excalibur.store.impl;
import java.io.File;
@@ -61,61 +12,56 @@
/**
* This TestCase fills a Jisp store with <code>MAX_ENTRIES</code>
- * and then clears it.
- * The test is sucsessful if we have 0 entries after cleaning the store.
+ * and then tests the remove() and clear() methods.
*
- * @author Charles Borges, charlesborges_dev at yahoo.fr
+ * @author borgesc
*/
public class ClearJispFilesystemStoreTestCase extends TestCase {
-
+
/** permanent Jisp store */
private JispFilesystemStore m_store;
-
+
/** logger for this test */
private final Logger m_logger =
new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
-
+
/** max entries to fill the store */
private int MAX_ENTRIES = 100;
-
+
/** temp dir for this test */
private File m_tempDir;
-
+
/**
- * TestCase Constructor
- * @param methodName
- */
- public ClearJispFilesystemStoreTestCase(String methodName) {
- super(methodName);
- }
-
- /**
- * Set up the the jisp database to the clear test.
+ * Set up the the jisp database before running each test
*/
public void setUp() throws Exception {
+ m_logger.debug("-BGN--> setUp() fixture for " + getName());
+
m_tempDir = File.createTempFile("jisp", "test");
m_tempDir.delete();
m_tempDir.mkdir();
-
+
m_store = new JispFilesystemStore();
-
+
//enable logging
m_store.enableLogging(new NullLogger());
-
+
//parameters
final Parameters params = new Parameters();
params.setParameter("directory", m_tempDir.toString());
params.makeReadOnly();
-
+
//parameterize it
m_store.parameterize(params);
-
+
//fill the store
fillStore();
-
+
+ m_logger.debug("-END--> setUp() fixture for " + getName());
+
}
-
+
/**
* Fills the store
* @throws IOException
@@ -125,18 +71,41 @@
String value = null;
m_logger.debug("filling the database...");
for (int i = 0; i < MAX_ENTRIES; i++) {
- key = key + i;
- value = value + i;
+ key = "key" + i;
+ value = "value" + i;
m_store.store(key, value);
}
m_logger.debug("filling the database...OK");
}
-
+
+ /**
+ * Test remove() on <code>JispFilesystemStore</code>
+ * This test succeeds if the a removed item points to null.
+ */
+ public void testRemove() {
+ m_logger.debug("-BGN--> testRemove()");
+ //get a key to remove
+ final String key = "key" + (MAX_ENTRIES - 10);
+ m_logger.debug("removing key: " + key);
+ m_store.remove(key);
+ // check that the item for the removed key is null
+ Object item = m_store.get(key);
+ if (item != null) {
+ assertTrue("The store item for key=" + key + " has value of " + item.toString(), item == null);
+ } else {
+ assertTrue(item == null);
+ }
+ m_logger.debug("-END--> testRemove()");
+
+ }
+
/**
* Test clear() on <code>JispFilesystemStore</code>
+ * This test succeeds if the store size after cleaning is 0.
* @throws Exception
*/
public void testClear() throws Exception {
+ m_logger.debug("-BGN--> testClear()");
final int sizeBefore = m_store.size();
m_logger.debug("store size before clear:" + sizeBefore);
m_logger.debug("index count before clear:" + m_store.m_Index.count());
@@ -145,16 +114,19 @@
m_logger.debug("store size after clear:" + sizeAfter);
m_logger.debug("index count after clear:" + m_store.m_Index.count());
assertTrue(sizeAfter == 0);
+ m_logger.debug("-END--> testClear()");
}
-
+
/**
- * Clean the resources after <code>testClear()</code>
+ * Clean the resources after running each test
*/
protected void tearDown() throws Exception {
+ m_logger.debug("-BGN--> tearUp() fixture for test " + getName());
m_logger.debug("deleting index and database");
deleteAll(m_tempDir);
+ m_logger.debug("-END--> tearUp() fixture for test " + getName());
}
-
+
/**
* Deletes files in directory recursively
* @param f
@@ -166,7 +138,9 @@
deleteAll(children[i]);
}
}
-
+
f.delete();
}
}
+
+
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org