JBoss Cache SVN: r5926 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-06-02 11:20:57 -0400 (Mon, 02 Jun 2008)
New Revision: 5926
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
Log:
rolledback thread sleeps removals - new view propagation does not necesarily mean that state transfer is finished
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-06-02 15:05:58 UTC (rev 5925)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-06-02 15:20:57 UTC (rev 5926)
@@ -41,7 +41,7 @@
caches.add(createCache(1, "TEST", false, true));
TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
-// TestingUtil.sleepThread(getSleepTimeout());
+ TestingUtil.sleepThread(getSleepTimeout());
Fqn<String> test = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), main);
@@ -50,18 +50,17 @@
caches.add(createCache(1, "TEST", false, true));
TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
-// TestingUtil.sleepThread(getSleepTimeout());
+ TestingUtil.sleepThread(getSleepTimeout());
assertNull("State not transferred", caches.get(2).get(test, "name"));
// Make 2 the buddy of 0
caches.get(1).stop();
- caches.remove(1);
- TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
+ caches.set(1, null);
-// TestingUtil.sleepThread(getSleepTimeout());
+ TestingUtil.sleepThread(getSleepTimeout());
- assertEquals("State transferred", "Joe", caches.get(1).get(test, "name"));
+ assertEquals("State transferred", "Joe", caches.get(2).get(test, "name"));
}
public void testRegionBasedStateTransfer() throws Exception
@@ -89,7 +88,7 @@
caches.get(3).start();
TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
-// TestingUtil.sleepThread(getSleepTimeout());
+ TestingUtil.sleepThread(getSleepTimeout());
Fqn fqnA = Fqn.fromString("/a");
Fqn fqnD = Fqn.fromString("/d");
@@ -161,7 +160,7 @@
caches.get(1).start();
TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
-// TestingUtil.sleepThread(getSleepTimeout());
+ TestingUtil.sleepThread(getSleepTimeout());
Fqn test = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), main);
16 years, 6 months
JBoss Cache SVN: r5925 - in core/branches/2.1.X/src: test/java/org/jboss/cache/loader and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-02 11:05:58 -0400 (Mon, 02 Jun 2008)
New Revision: 5925
Added:
core/branches/2.1.X/src/test/java/org/jboss/cache/loader/PreloadTest.java
Modified:
core/branches/2.1.X/src/main/java/org/jboss/cache/CacheImpl.java
Log:
JBCACHE-1358: Cache Loader preloading does not happen! - Added fix and test
Modified: core/branches/2.1.X/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/branches/2.1.X/src/main/java/org/jboss/cache/CacheImpl.java 2008-06-02 15:04:47 UTC (rev 5924)
+++ core/branches/2.1.X/src/main/java/org/jboss/cache/CacheImpl.java 2008-06-02 15:05:58 UTC (rev 5925)
@@ -179,7 +179,7 @@
private void injectDependencies(Notifier notifier, RegionManager regionManager, TransactionManager transactionManager, Marshaller marshaller,
TransactionTable transactionTable, NodeFactory nodeFactory,
CacheSPI spi, @ComponentName("remoteDelegate")RemoteCacheInvocationDelegate remoteDelegate,
- Interceptor interceptorChain, BuddyManager buddyManager, RPCManager rpcManager)
+ Interceptor interceptorChain, BuddyManager buddyManager, RPCManager rpcManager, CacheLoaderManager cacheLoaderManager)
{
this.notifier = notifier;
this.regionManager = regionManager;
@@ -192,6 +192,7 @@
this.interceptorChain = interceptorChain;
this.buddyManager = buddyManager;
this.rpcManager = rpcManager;
+ this.cacheLoaderManager = cacheLoaderManager;
}
public Configuration getConfiguration()
Added: core/branches/2.1.X/src/test/java/org/jboss/cache/loader/PreloadTest.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/loader/PreloadTest.java (rev 0)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/loader/PreloadTest.java 2008-06-02 15:05:58 UTC (rev 5925)
@@ -0,0 +1,69 @@
+package org.jboss.cache.loader;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.misc.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+@Test(groups = "functional")
+public class PreloadTest extends AbstractCacheLoaderTestBase
+{
+ CacheSPI<Object, Object> cache;
+ Fqn fqn = Fqn.fromString("/a/b/c");
+ Object key = "key", value = "value";
+
+ @AfterMethod
+ public void tearDown()
+ {
+ if (cache != null) TestingUtil.killCaches(cache);
+ }
+
+ public void testPreload() throws Exception
+ {
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL);
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/a", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache.put(fqn, key, value);
+ assertExists();
+
+ cache.destroy();
+
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ assertExists();
+ }
+
+ public void testPreloadMultiRegions() throws Exception
+ {
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL);
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/a", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache.put(fqn, key, value);
+ assertExists();
+
+ cache.destroy();
+
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/c,/a,/b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ assertExists();
+
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/c, /a, /b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ assertExists();
+
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig(" /c, /a, /b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ assertExists();
+ }
+
+ private void assertExists() throws Exception
+ {
+ CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
+ assert loader.get(fqn).get(key).equals(value);
+ assert cache.peek(fqn, false).getDataDirect().get(key).equals(value);
+ }
+}
16 years, 6 months
JBoss Cache SVN: r5924 - in core/trunk/src: test/java/org/jboss/cache/loader and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-02 11:04:47 -0400 (Mon, 02 Jun 2008)
New Revision: 5924
Added:
core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
Log:
JBCACHE-1358: Cache Loader preloading does not happen! - Added fix and test
Modified: core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-06-02 14:27:00 UTC (rev 5923)
+++ core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-06-02 15:04:47 UTC (rev 5924)
@@ -442,6 +442,8 @@
loader.start();
purgeLoaders(false);
+
+ preloadCache();
}
catch (Exception e)
{
Added: core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java 2008-06-02 15:04:47 UTC (rev 5924)
@@ -0,0 +1,69 @@
+package org.jboss.cache.loader;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+@Test(groups = "functional")
+public class PreloadTest extends AbstractCacheLoaderTestBase
+{
+ CacheSPI<Object, Object> cache;
+ Fqn fqn = Fqn.fromString("/a/b/c");
+ Object key = "key", value = "value";
+
+ @AfterMethod
+ public void tearDown()
+ {
+ if (cache != null) TestingUtil.killCaches(cache);
+ }
+
+ public void testPreload() throws Exception
+ {
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL);
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/a", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache.put(fqn, key, value);
+ assertExists();
+
+ cache.destroy();
+
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ assertExists();
+ }
+
+ public void testPreloadMultiRegions() throws Exception
+ {
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL);
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/a", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache.put(fqn, key, value);
+ assertExists();
+
+ cache.destroy();
+
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/c,/a,/b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ assertExists();
+
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/c, /a, /b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ assertExists();
+
+ c.setCacheLoaderConfig(getSingleCacheLoaderConfig(" /c, /a, /b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ assertExists();
+ }
+
+ private void assertExists() throws Exception
+ {
+ CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
+ assert loader.get(fqn).get(key).equals(value);
+ assert cache.peek(fqn, false).getDataDirect().get(key).equals(value);
+ }
+}
16 years, 6 months
JBoss Cache SVN: r5923 - in core/trunk/src: test/java/org/jboss/cache/util and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-06-02 10:27:00 -0400 (Mon, 02 Jun 2008)
New Revision: 5923
Modified:
core/trunk/src/main/java/org/jboss/cache/util/BitEncodedIntegerSet.java
core/trunk/src/test/java/org/jboss/cache/util/BitEncodedIntegerSetTest.java
Log:
Added to test class.
Modified: core/trunk/src/main/java/org/jboss/cache/util/BitEncodedIntegerSet.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/BitEncodedIntegerSet.java 2008-06-02 11:20:46 UTC (rev 5922)
+++ core/trunk/src/main/java/org/jboss/cache/util/BitEncodedIntegerSet.java 2008-06-02 14:27:00 UTC (rev 5923)
@@ -53,8 +53,9 @@
@Override
public boolean equals(Object o)
{
+ if (o == this) return true;
if (o == null || getClass() != o.getClass()) return false;
-
+
BitEncodedIntegerSet that = (BitEncodedIntegerSet) o;
return encoded == that.encoded;
Modified: core/trunk/src/test/java/org/jboss/cache/util/BitEncodedIntegerSetTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/BitEncodedIntegerSetTest.java 2008-06-02 11:20:46 UTC (rev 5922)
+++ core/trunk/src/test/java/org/jboss/cache/util/BitEncodedIntegerSetTest.java 2008-06-02 14:27:00 UTC (rev 5923)
@@ -2,6 +2,8 @@
import org.testng.annotations.Test;
+import java.util.HashSet;
+
/**
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
@@ -136,6 +138,11 @@
{
BitEncodedIntegerSet set = new BitEncodedIntegerSet();
assert set.isEmpty();
+
+ set.add(1);
+
+ assert !set.isEmpty();
+
}
public void testEquals()
@@ -160,7 +167,29 @@
assert !set1.equals(set2);
assert !set2.equals(set1);
+
+ assert set1.equals(set1);
+ assert !set1.equals(null);
+ assert !set1.equals(new HashSet());
}
+ public void testHashCode()
+ {
+ BitEncodedIntegerSet set = new BitEncodedIntegerSet();
+ int hash = set.hashCode();
+
+ assert hash >= Integer.MIN_VALUE;
+ assert hash <= Integer.MAX_VALUE;
+
+ }
+
+ public void testToString()
+ {
+ BitEncodedIntegerSet set = new BitEncodedIntegerSet();
+
+ assert set.toString() != null;
+
+ }
+
}
16 years, 6 months