[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/loader ...
Manik Surtani
msurtani at jboss.com
Fri Sep 22 12:27:56 EDT 2006
User: msurtani
Date: 06/09/22 12:27:56
Modified: tests/functional/org/jboss/cache/loader
AsyncFileCacheLoaderTest.java BdbjeTest.java
CacheLoaderTestsBase.java
Log:
- Modification types to Enums.
- Abstracted put(List)
Revision Changes Path
1.14 +140 -135 JBossCache/tests/functional/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AsyncFileCacheLoaderTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- AsyncFileCacheLoaderTest.java 31 Aug 2006 14:56:46 -0000 1.13
+++ AsyncFileCacheLoaderTest.java 22 Sep 2006 16:27:56 -0000 1.14
@@ -5,8 +5,8 @@
import junit.framework.TestSuite;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
-import org.jboss.cache.TreeCache;
import org.jboss.cache.Modification;
+import org.jboss.cache.TreeCache;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.invocation.MarshalledValueInputStream;
@@ -14,9 +14,8 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.util.Map;
-import java.util.HashMap;
import java.util.Collections;
+import java.util.HashMap;
public class AsyncFileCacheLoaderTest extends AbstractCacheLoaderTestBase
{
@@ -39,14 +38,18 @@
cache.start();
}
- public static Test suite() {
+ public static Test suite()
+ {
return new TestSuite(AsyncFileCacheLoaderTest.class);
}
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
if (cache != null)
+ {
cache.stop();
}
+ }
public void testRestrictionOnAddingToQueue() throws Exception
{
@@ -87,7 +90,7 @@
HashMap map = new HashMap();
map.put("c", "d");
// Three kinds of puts!
- Modification mod = new Modification(Modification.PUT_KEY_VALUE, fqn, "e", "f");
+ Modification mod = new Modification(Modification.ModificationType.PUT_KEY_VALUE, fqn, "e", "f");
loader.put(fqn, "a", "b");
loader.put(fqn, map);
loader.put(Collections.singletonList(mod));
@@ -106,7 +109,9 @@
loader.remove(fqn);
// You can't really see it block though :-/
for (int i = 0; i < 100; i++)
+ {
cache.put(fqn, "key" + i, "value1");
+ }
Thread.sleep(1000);
assertEquals(100, loader.get(fqn).size());
loader.remove(fqn);
1.10 +133 -57 JBossCache/tests/functional/org/jboss/cache/loader/BdbjeTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BdbjeTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/BdbjeTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- BdbjeTest.java 12 Sep 2006 20:16:56 -0000 1.9
+++ BdbjeTest.java 22 Sep 2006 16:27:56 -0000 1.10
@@ -35,7 +35,7 @@
* directory. Any scratch directory will do, but beware that all files in
* the directory will be deleted by setUp().</p>
*
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public class BdbjeTest extends TestCase
{
@@ -104,7 +104,9 @@
{
loader.stop();
}
- catch (Exception ignored) {}
+ catch (Exception ignored)
+ {
+ }
loader = null;
}
if (treeCache != null)
@@ -113,7 +115,9 @@
{
treeCache.stop();
}
- catch (Exception ignored) {}
+ catch (Exception ignored)
+ {
+ }
treeCache = null;
}
}
@@ -605,7 +609,7 @@
/* REMOVE_KEY_VALUE */
list = new ArrayList();
Modification mod = new Modification();
- mod.setType(Modification.REMOVE_KEY_VALUE);
+ mod.setType(Modification.ModificationType.REMOVE_KEY_VALUE);
mod.setFqn(FQN);
mod.setKey("one");
list.add(mod);
@@ -615,7 +619,7 @@
/* REMOVE_NODE */
list = new ArrayList();
mod = new Modification();
- mod.setType(Modification.REMOVE_NODE);
+ mod.setType(Modification.ModificationType.REMOVE_NODE);
mod.setFqn(FQN);
list.add(mod);
loader.put(list);
@@ -626,7 +630,7 @@
loader.put(FQN, "one", "two");
list = new ArrayList();
mod = new Modification();
- mod.setType(Modification.REMOVE_DATA);
+ mod.setType(Modification.ModificationType.REMOVE_DATA);
mod.setFqn(FQN);
list.add(mod);
loader.put(list);
@@ -670,7 +674,9 @@
checkModifications(mods);
fail("Expected lock timeout");
}
- catch (DeadlockException expected) {}
+ catch (DeadlockException expected)
+ {
+ }
loader.commit(txnKey);
checkModifications(mods);
@@ -707,14 +713,14 @@
List list = new ArrayList();
Modification mod = new Modification();
- mod.setType(Modification.PUT_KEY_VALUE);
+ mod.setType(Modification.ModificationType.PUT_KEY_VALUE);
mod.setFqn(FQN);
mod.setKey("one");
mod.setValue("two");
list.add(mod);
mod = new Modification();
- mod.setType(Modification.PUT_KEY_VALUE);
+ mod.setType(Modification.ModificationType.PUT_KEY_VALUE);
mod.setFqn(FQN);
mod.setKey("three");
mod.setValue("four");
@@ -724,7 +730,7 @@
map.put("five", "six");
map.put("seven", "eight");
mod = new Modification();
- mod.setType(Modification.PUT_DATA);
+ mod.setType(Modification.ModificationType.PUT_DATA);
mod.setFqn(FQN);
mod.setData(map);
list.add(mod);
@@ -745,10 +751,10 @@
Fqn fqn = mod.getFqn();
switch (mod.getType())
{
- case Modification.PUT_KEY_VALUE:
+ case PUT_KEY_VALUE:
assertEquals(mod.getValue(), loader.get(fqn).get(mod.getKey()));
break;
- case Modification.PUT_DATA:
+ case PUT_DATA:
Map map = mod.getData();
for (Iterator iter = map.keySet().iterator(); iter.hasNext();)
{
@@ -756,15 +762,15 @@
assertEquals(map.get(key), loader.get(fqn).get(key));
}
break;
- case Modification.REMOVE_KEY_VALUE:
+ case REMOVE_KEY_VALUE:
assertEquals(null, loader.get(fqn).get(mod.getKey()));
break;
- case Modification.REMOVE_DATA:
+ case REMOVE_DATA:
assertTrue(loader.exists(fqn));
assertNotNull(loader.get(fqn));
assertEquals(0, loader.get(fqn).size());
break;
- case Modification.REMOVE_NODE:
+ case REMOVE_NODE:
assertTrue(!loader.exists(fqn));
assertEquals(null, loader.get(fqn));
break;
@@ -815,7 +821,9 @@
loader.start();
// fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
// loader.setCache(null);
Properties props = new Properties();
@@ -826,7 +834,9 @@
loader.start();
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
loader.setCache(new TreeCache().getCacheSPI());
props = new Properties();
@@ -837,77 +847,99 @@
loader.start();
fail();
}
- catch (DatabaseException expected) {}
+ catch (DatabaseException expected)
+ {
+ }
try
{
loader.put(FQN, "one", "two");
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.put(FQN, new HashMap());
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.put(new ArrayList());
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.get(FQN).get("one");
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.get(FQN);
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.remove(FQN);
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.remove(FQN, "one");
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.prepare(new Object(), new ArrayList(), false);
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.commit(new Object());
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.rollback(new Object());
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
@@ -916,7 +948,9 @@
loader.loadEntireState(os);
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
@@ -925,7 +959,9 @@
loader.storeEntireState(is);
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
/* Redundant stop and destroy are allowed. */
loader.stop();
@@ -944,90 +980,116 @@
loader.create();
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.start();
fail();
}
- catch (IllegalStateException expected) {}
+ catch (IllegalStateException expected)
+ {
+ }
try
{
loader.put(null, "one", "two");
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.put(null, new HashMap());
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.put(null);
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.get(null).get("one");
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.get(null);
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.remove(null);
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.remove(null, "one");
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.prepare(null, new ArrayList(), false);
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.prepare(new Object(), null, false);
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.commit(null);
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
try
{
loader.rollback(null);
fail();
}
- catch (NullPointerException expected) {}
+ catch (NullPointerException expected)
+ {
+ }
}
/**
@@ -1046,7 +1108,9 @@
loader.prepare(new Object(), mods, false);
fail();
}
- catch (UnsupportedOperationException expected) {}
+ catch (UnsupportedOperationException expected)
+ {
+ }
stopLoader();
startLoader(true, null);
@@ -1057,13 +1121,17 @@
loader.commit(new Object());
fail();
}
- catch (IllegalArgumentException expected) {}
+ catch (IllegalArgumentException expected)
+ {
+ }
try
{
loader.rollback(new Object());
fail();
}
- catch (IllegalArgumentException expected) {}
+ catch (IllegalArgumentException expected)
+ {
+ }
/* Commit and rollback after commit. */
@@ -1085,13 +1153,17 @@
loader.commit(txnKey);
fail();
}
- catch (IllegalArgumentException expected) {}
+ catch (IllegalArgumentException expected)
+ {
+ }
try
{
loader.rollback(txnKey);
fail();
}
- catch (IllegalArgumentException expected) {}
+ catch (IllegalArgumentException expected)
+ {
+ }
/* Commit and rollback after rollback. */
bais = new ByteArrayInputStream(baos.toByteArray());
@@ -1106,13 +1178,17 @@
loader.rollback(txnKey);
fail();
}
- catch (IllegalArgumentException expected) {}
+ catch (IllegalArgumentException expected)
+ {
+ }
try
{
loader.rollback(txnKey);
fail();
}
- catch (IllegalArgumentException expected) {}
+ catch (IllegalArgumentException expected)
+ {
+ }
stopLoader();
}
1.31 +26 -16 JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderTestsBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheLoaderTestsBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderTestsBase.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- CacheLoaderTestsBase.java 11 Sep 2006 13:54:11 -0000 1.30
+++ CacheLoaderTestsBase.java 22 Sep 2006 16:27:56 -0000 1.31
@@ -30,7 +30,7 @@
* Commons tests for all CacheLoaders
*
* @author Bela Ban
- * @version $Id: CacheLoaderTestsBase.java,v 1.30 2006/09/11 13:54:11 vblagojevic Exp $
+ * @version $Id: CacheLoaderTestsBase.java,v 1.31 2006/09/22 16:27:56 msurtani Exp $
*/
abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
{
@@ -290,7 +290,9 @@
{
Map m = new HashMap();
for (int i = 0; i < 10; i++)
+ {
m.put("key" + i, "val" + i);
+ }
cache.put("/a/b/c", m);
cache.load("/1/2/3/4/5");
cache.put("/1/2/3/4/5", null);
@@ -449,7 +451,9 @@
try
{
if (!cache.exists("/a/b/c"))
+ {
cache.put("/a/b/c", null);
+ }
Set children = cache.getChildrenNames((Fqn) null);
assertNull(children);
}
@@ -1380,7 +1384,7 @@
/* REMOVE_KEY_VALUE */
list = new ArrayList();
Modification mod = new Modification();
- mod.setType(Modification.REMOVE_KEY_VALUE);
+ mod.setType(Modification.ModificationType.REMOVE_KEY_VALUE);
mod.setFqn(FQN);
mod.setKey("one");
list.add(mod);
@@ -1391,7 +1395,7 @@
/* REMOVE_NODE */
list = new ArrayList();
mod = new Modification();
- mod.setType(Modification.REMOVE_NODE);
+ mod.setType(Modification.ModificationType.REMOVE_NODE);
mod.setFqn(FQN);
list.add(mod);
loader.put(list);
@@ -1403,7 +1407,7 @@
loader.put(FQN, "one", "two");
list = new ArrayList();
mod = new Modification();
- mod.setType(Modification.REMOVE_DATA);
+ mod.setType(Modification.ModificationType.REMOVE_DATA);
mod.setFqn(FQN);
list.add(mod);
loader.put(list);
@@ -1506,14 +1510,14 @@
List list = new ArrayList();
Modification mod = new Modification();
- mod.setType(Modification.PUT_KEY_VALUE);
+ mod.setType(Modification.ModificationType.PUT_KEY_VALUE);
mod.setFqn(FQN);
mod.setKey("one");
mod.setValue("two");
list.add(mod);
mod = new Modification();
- mod.setType(Modification.PUT_KEY_VALUE);
+ mod.setType(Modification.ModificationType.PUT_KEY_VALUE);
mod.setFqn(FQN);
mod.setKey("three");
mod.setValue("four");
@@ -1523,7 +1527,7 @@
map.put("five", "six");
map.put("seven", "eight");
mod = new Modification();
- mod.setType(Modification.PUT_DATA);
+ mod.setType(Modification.ModificationType.PUT_DATA);
mod.setFqn(FQN);
mod.setData(map);
list.add(mod);
@@ -1544,10 +1548,10 @@
Fqn fqn = mod.getFqn();
switch (mod.getType())
{
- case Modification.PUT_KEY_VALUE:
+ case PUT_KEY_VALUE:
assertEquals(mod.getValue(), loader.get(fqn).get(mod.getKey()));
break;
- case Modification.PUT_DATA:
+ case PUT_DATA:
Map map = mod.getData();
for (Iterator iter = map.keySet().iterator(); iter.hasNext();)
{
@@ -1555,15 +1559,15 @@
assertEquals(map.get(key), loader.get(fqn).get(key));
}
break;
- case Modification.REMOVE_KEY_VALUE:
+ case REMOVE_KEY_VALUE:
assertNull(loader.get(fqn).get(mod.getKey()));
break;
- case Modification.REMOVE_DATA:
+ case REMOVE_DATA:
map = loader.get(fqn);
assertNotNull(map);
assertEquals(0, map.size());
break;
- case Modification.REMOVE_NODE:
+ case REMOVE_NODE:
assertNull(loader.get(fqn));
break;
default:
@@ -1684,7 +1688,7 @@
}
/* Restore state. */
- MarshalledValueInputStream is =null;
+ MarshalledValueInputStream is = null;
try
{
ByteArrayInputStream bais = new ByteArrayInputStream(state);
@@ -1727,7 +1731,9 @@
public boolean equals(Object o)
{
if (!(o instanceof Complex))
+ {
return false;
+ }
Complex x = (Complex) o;
return (nested != null) ? nested.equals(x.nested)
: (x.nested == null);
@@ -1736,11 +1742,15 @@
public int hashCode()
{
if (nested == null)
+ {
return super.hashCode();
+ }
else
+ {
return 13 + nested.hashCode();
}
}
+ }
public void testRemoveInTransactionCommit() throws Exception
{
More information about the jboss-cvs-commits
mailing list