[infinispan-commits] Infinispan SVN: r1711 - trunk/core/src/test/java/org/infinispan/loaders.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu Apr 22 05:34:32 EDT 2010
Author: manik.surtani at jboss.com
Date: 2010-04-22 05:34:31 -0400 (Thu, 22 Apr 2010)
New Revision: 1711
Modified:
trunk/core/src/test/java/org/infinispan/loaders/CacheLoaderFunctionalTest.java
Log:
Added test
Modified: trunk/core/src/test/java/org/infinispan/loaders/CacheLoaderFunctionalTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/CacheLoaderFunctionalTest.java 2010-04-21 15:01:41 UTC (rev 1710)
+++ trunk/core/src/test/java/org/infinispan/loaders/CacheLoaderFunctionalTest.java 2010-04-22 09:34:31 UTC (rev 1711)
@@ -103,6 +103,29 @@
assertNotInCacheAndStore(cache, store, keys);
}
+ private void assertInStoreNotInCache(Object... keys) throws CacheLoaderException {
+ assertInStoreNotInCache(cache, store, keys);
+ }
+
+ private void assertInStoreNotInCache(Cache cache, CacheStore store, Object... keys) throws CacheLoaderException {
+ for (Object key : keys) {
+ assert !cache.getAdvancedCache().getDataContainer().containsKey(key) : "Cache should not contain key " + key;
+ assert store.containsKey(key) : "Store should contain key " + key;
+ }
+ }
+
+ private void assertInCacheAndNotInStore(Object... keys) throws CacheLoaderException {
+ assertInCacheAndNotInStore(cache, store, keys);
+ }
+
+ private void assertInCacheAndNotInStore(Cache cache, CacheStore store, Object... keys) throws CacheLoaderException {
+ for (Object key : keys) {
+ assert cache.getAdvancedCache().getDataContainer().containsKey(key) : "Cache should not contain key " + key;
+ assert !store.containsKey(key) : "Store should contain key " + key;
+ }
+ }
+
+
public void testStoreAndRetrieve() throws CacheLoaderException {
assertNotInCacheAndStore("k1", "k2", "k3", "k4", "k5", "k6", "k7");
@@ -379,4 +402,25 @@
assert "v1".equals(cache.remove("k1"));
assert "v2".equals(cache.remove("k2"));
}
+
+ public void testLoadingToMemory() throws CacheLoaderException {
+ assertNotInCacheAndStore("k1", "k2");
+ store.store(InternalEntryFactory.create("k1", "v1"));
+ store.store(InternalEntryFactory.create("k2", "v2"));
+
+ assertInStoreNotInCache("k1", "k2");
+
+ assert "v1".equals(cache.get("k1"));
+ assert "v2".equals(cache.get("k2"));
+
+ assertInCacheAndStore("k1", "v1");
+ assertInCacheAndStore("k2", "v2");
+
+ store.remove("k1");
+ store.remove("k2");
+
+ assertInCacheAndNotInStore("k1", "k2");
+ assert "v1".equals(cache.get("k1"));
+ assert "v2".equals(cache.get("k2"));
+ }
}
More information about the infinispan-commits
mailing list