Author: manik.surtani(a)jboss.com
Date: 2008-10-14 09:26:25 -0400 (Tue, 14 Oct 2008)
New Revision: 6933
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
Added test for JBCACHE-1426
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-14
12:35:58 UTC (rev 6932)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-14
13:26:25 UTC (rev 6933)
@@ -8,6 +8,7 @@
import org.jboss.cache.Modification;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
@@ -34,8 +35,6 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
-import org.jboss.cache.UnitTestCacheFactory;
-import org.testng.annotations.Test;
/**
* Commons tests for all CacheLoaders
@@ -59,23 +58,23 @@
private static final Fqn BUDDY_PLUS_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, FQN);
private static final Fqn BUDDY_PLUS_SUBTREE_FQN = Fqn.fromRelativeFqn(BUDDY_BASE,
SUBTREE_FQN);
-
+
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
try
{
CacheSPI<Object, Object> cache =
- (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false);
+ (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false);
cacheTL.set(cache);
-
+
Configuration c = cache.getConfiguration();
c.setCacheMode(Configuration.CacheMode.LOCAL);
- c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
configureCache();
cache.start();
- CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
- loaderTL.set(loader);
+ CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
+ loaderTL.set(loader);
postConfigure();
}
catch (Exception e)
@@ -221,6 +220,34 @@
assertEquals("combined", 4, cache.getNode(NODE).getData().size());
}
+ public void testPutNullDataMap() throws Exception
+ {
+ Fqn f = Fqn.fromString("/a");
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+ assert !cache.exists(f);
+ assert !loader.exists(f);
+ cache.put(f, null);
+ Map fromLoader = loader.get(f);
+ assert fromLoader != null : "Node should exist in the loader";
+ assert fromLoader.isEmpty() : "Should not contain any data";
+ }
+
+ public void testPutNullDataMapNodeHasData() throws Exception
+ {
+ Fqn f = Fqn.fromString("/a");
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+ cache.put(f, "key", "value");
+ assert cache.exists(f);
+ assert loader.exists(f);
+ cache.put(f, null);
+ Map fromLoader = loader.get(f);
+ assert fromLoader != null : "Node should exist in the loader";
+ assert fromLoader.size() == 1 : "Should contain original data";
+ }
+
+
public void testShallowMove() throws Exception
{
CacheSPI<Object, Object> cache = cacheTL.get();
@@ -338,7 +365,7 @@
public void testGetNode() throws CacheException
{
CacheSPI<Object, Object> cache = cacheTL.get();
-
+
final String NODE = "/a/b/c";
Node<Object, Object> retval;
cache.removeNode(NODE);
@@ -1530,7 +1557,7 @@
{
CacheLoader loader = loaderTL.get();
-
+
Set set = loader.getChildrenNames(fqn);
if (names != null)
{
@@ -1626,7 +1653,7 @@
{
CacheLoader loader = loaderTL.get();
-
+
List<Modification> mods = createUpdates();
loader.prepare(null, mods, true);
checkModifications(mods);
@@ -1640,7 +1667,7 @@
{
CacheLoader loader = loaderTL.get();
-
+
// Object txnKey = new Object();
TransactionManager mgr = getTransactionManager();
mgr.begin();
@@ -1659,7 +1686,7 @@
*/
public void testTransactionRollback() throws Exception
{
- CacheLoader loader = loaderTL.get();
+ CacheLoader loader = loaderTL.get();
loader.remove(Fqn.fromString("/"));
int num;
try
@@ -1801,7 +1828,7 @@
{
CacheLoader loader = loaderTL.get();
-
+
loader.put(FQN, null, "x");
addDelay();
assertEquals("x", loader.get(FQN).get(null));
Show replies by date