[jbosscache-commits] JBoss Cache SVN: r4945 - in core/trunk/src/test/java/org/jboss/cache: buddyreplication and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Jan 2 14:32:14 EST 2008
Author: manik.surtani at jboss.com
Date: 2008-01-02 14:32:14 -0500 (Wed, 02 Jan 2008)
New Revision: 4945
Added:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
Log:
Updated existing tests, added new test to ensure correct classpath scanning
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-01-02 19:08:11 UTC (rev 4944)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-01-02 19:32:14 UTC (rev 4945)
@@ -14,6 +14,7 @@
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.NodeLock;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -27,7 +28,6 @@
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
-import java.lang.reflect.Method;
import java.util.List;
@Test(groups = {"functional", "jgroups", "transaction"})
@@ -179,7 +179,7 @@
// specify what we expect called on the mock Rpc Manager. For params we don't care about, just use ANYTHING.
// setting the mock object to expect the "sync" param to be false.
expect(rpcManager.getReplicationQueue()).andReturn(null);
- expect(rpcManager.callRemoteMethods(anyAddresses(), (Method) anyObject(), (Object[]) anyObject(), eq(false), anyBoolean(), anyInt())).andReturn(null);
+ expect(rpcManager.callRemoteMethods(anyAddresses(), (MethodCall) anyObject(), eq(false), anyBoolean(), anyInt())).andReturn(null);
}
replay(rpcManager);
@@ -237,7 +237,8 @@
{
RPCManager barfingRpcManager = new RPCManagerImpl()
{
- public List callRemoteMethods(List<Address> recipients, Method method, Object[] arguments, boolean synchronous, boolean excludeSelf, long timeout)
+ @Override
+ public List callRemoteMethods(List<Address> recipients, MethodCall method, boolean synchronous, boolean excludeSelf, int timeout)
{
throw new RuntimeException("Barf");
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-01-02 19:08:11 UTC (rev 4944)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-01-02 19:32:14 UTC (rev 4945)
@@ -259,13 +259,21 @@
protected List<CacheSPI<Object, Object>> createCaches(int numBuddies, int numCaches, boolean useBuddyPool, boolean useDataGravitation, boolean optimisticLocks) throws Exception
{
+ return createCaches(numBuddies, numCaches, useBuddyPool, useDataGravitation, optimisticLocks, true);
+ }
+
+ protected List<CacheSPI<Object, Object>> createCaches(int numBuddies, int numCaches, boolean useBuddyPool, boolean useDataGravitation, boolean optimisticLocks, boolean start) throws Exception
+ {
List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(numCaches);
for (int i = 0; i < numCaches; i++)
- caches.add(createCache(optimisticLocks, numBuddies, useBuddyPool ? Character.toString((char) ('A' + i)) : null, useDataGravitation, true));
+ caches.add(createCache(optimisticLocks, numBuddies, useBuddyPool ? Character.toString((char) ('A' + i)) : null, useDataGravitation, start));
- // allow some time for the caches to start up and discover each other
- TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), VIEW_BLOCK_TIMEOUT);
- TestingUtil.sleepThread(getSleepTimeout());
+ if (start)
+ {
+ // allow some time for the caches to start up and discover each other
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), VIEW_BLOCK_TIMEOUT);
+ TestingUtil.sleepThread(getSleepTimeout());
+ }
return caches;
}
Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java 2008-01-02 19:32:14 UTC (rev 4945)
@@ -0,0 +1,67 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.util.CachePrinter;
+import org.testng.annotations.Test;
+
+/**
+ * This is to test JBCACHE-1229
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.1.0
+ */
+ at Test(groups = "functional")
+public class DisabledStateTransferTest extends BuddyReplicationTestsBase
+{
+ public void testCachesWithoutStateTransfer() throws Exception
+ {
+ caches = createCaches(1, 3, false, false, false, false);
+
+ int cacheNumber = 0;
+ for (CacheSPI c : caches)
+ {
+ c.getConfiguration().setFetchInMemoryState(false);
+ c.start();
+ c.put("/" + cacheNumber++, "k", "v");
+ }
+
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 60000);
+
+ for (CacheSPI c : caches)
+ System.out.println("Cache (local address " + c.getLocalAddress() + ") contents: " + CachePrinter.printCacheLockingInfo(c));
+
+ for (int i = 0; i < 3; i++)
+ {
+ int backupIndex = i == 2 ? 0 : i + 1;
+
+ assert caches.get(i).exists("/" + i) : "Data should exist on owner (cache #" + i + ")";
+ Fqn backup = BuddyManager.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i));
+
+ assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
+ boolean backupStatePropagated = caches.get(backupIndex).exists(backup);
+ boolean backupOlderThanOwner = backupIndex < i;
+ assert (!backupStatePropagated && !backupOlderThanOwner) || (backupStatePropagated && backupOlderThanOwner) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
+ }
+
+ // now NEW state should transfer just fine.
+
+ cacheNumber = 0;
+ for (CacheSPI c : caches)
+ {
+ c.put("/" + (cacheNumber++) + "_NEW", "k", "v");
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ int backupIndex = i == 2 ? 0 : i + 1;
+
+ assert caches.get(i).exists("/" + i + "_NEW") : "Data should exist on owner (cache #" + i + ")";
+ Fqn backup = BuddyManager.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i + "_NEW"));
+
+ assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
+ assert caches.get(backupIndex).exists(backup) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
+ }
+ }
+}
More information about the jbosscache-commits
mailing list