[infinispan-commits] Infinispan SVN: r1845 - in trunk: core/src/test/java/org/infinispan/api and 1 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Tue May 25 10:50:47 EDT 2010
Author: manik.surtani at jboss.com
Date: 2010-05-25 10:50:46 -0400 (Tue, 25 May 2010)
New Revision: 1845
Modified:
trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreFunctionalIntegrationTest.java
trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java
trunk/core/src/test/java/org/infinispan/api/CacheAPITest.java
trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java
Log:
CloudCacheStore fixes
Modified: trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreFunctionalIntegrationTest.java
===================================================================
--- trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreFunctionalIntegrationTest.java 2010-05-25 14:09:01 UTC (rev 1844)
+++ trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreFunctionalIntegrationTest.java 2010-05-25 14:50:46 UTC (rev 1845)
@@ -21,8 +21,11 @@
*/
package org.infinispan.loaders.cloud;
+import org.easymock.EasyMock;
+import org.infinispan.Cache;
import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
import org.infinispan.loaders.CacheStoreConfig;
+import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
@@ -63,7 +66,25 @@
System.out.printf("accessKey: %1$s, bucket: %2$s%n", accessKey, csBucket);
}
+ @AfterTest
+ private void nukeBuckets() throws Exception {
+ for (String name: cacheNames) {
+ // use JClouds to nuke the buckets
+ CloudCacheStore ccs = new CloudCacheStore();
+ Cache c = EasyMock.createNiceMock(Cache.class);
+ EasyMock.expect(c.getName()).andReturn(name).anyTimes();
+ EasyMock.replay(c);
+ ccs.init(createCacheStoreConfig(), c, null);
+ ccs.start();
+ System.out.println("**** Nuking container " + ccs.containerName);
+ ccs.blobStore.clearContainer(ccs.containerName);
+ ccs.blobStore.deleteContainer(ccs.containerName);
+ ccs.stop();
+ }
+ cacheNames.clear();
+ }
+
@Override
protected CacheStoreConfig createCacheStoreConfig() throws Exception {
CloudCacheStoreConfig cfg = new CloudCacheStoreConfig();
Modified: trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java
===================================================================
--- trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java 2010-05-25 14:09:01 UTC (rev 1844)
+++ trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java 2010-05-25 14:50:46 UTC (rev 1845)
@@ -33,6 +33,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import static org.testng.Assert.assertEquals;
@@ -68,7 +69,7 @@
secretKey = "dummy";
}
csBucket = (System.getProperty("user.name")
- + "." + this.getClass().getSimpleName()).toLowerCase();
+ + "-" + this.getClass().getSimpleName()).toLowerCase();
System.out.printf("accessKey: %1$s, bucket: %2$s%n", accessKey, csBucket);
cs2Bucket = csBucket + "2";
@@ -139,7 +140,7 @@
@SuppressWarnings("unchecked")
@Override
- @Test (enabled = false, description = "Disabled until JClouds gains a proper streaming API")
+ @Test(enabled = false, description = "Disabled until JClouds gains a proper streaming API")
public void testStreamingAPI() throws IOException, ClassNotFoundException, CacheLoaderException {
cs.store(InternalEntryFactory.create("k1", "v1", -1, -1));
cs.store(InternalEntryFactory.create("k2", "v2", -1, -1));
@@ -174,8 +175,10 @@
assert expected.isEmpty();
}
- @Test (enabled = false, description = "Much too slow to run this on a live cloud setup")
- @Override public void testConcurrency() throws Exception {}
+ @Test(enabled = false, description = "Much too slow to run this on a live cloud setup")
+ @Override
+ public void testConcurrency() throws Exception {
+ }
public void testNegativeHashCodes() throws CacheLoaderException {
ObjectWithNegativeHashcode objectWithNegativeHashcode = new ObjectWithNegativeHashcode();
@@ -204,14 +207,14 @@
}
@Override
- @Test (enabled = false, description = "Disabled until we can build the blobstore stub to retain state somewhere.")
+ @Test(enabled = false, description = "Disabled until we can build the blobstore stub to retain state somewhere.")
public void testStopStartDoesNotNukeValues() throws InterruptedException, CacheLoaderException {
}
@SuppressWarnings("unchecked")
@Override
- @Test (enabled = false, description = "Disabled until JClouds gains a proper streaming API")
+ @Test(enabled = false, description = "Disabled until JClouds gains a proper streaming API")
public void testStreamingAPIReusingStreams() throws IOException, ClassNotFoundException, CacheLoaderException {
cs.store(InternalEntryFactory.create("k1", "v1", -1, -1));
cs.store(InternalEntryFactory.create("k2", "v2", -1, -1));
@@ -259,11 +262,20 @@
assert expected.isEmpty();
}
- // TODO test that this passes before closing ISPN-334
public void testJCloudsMetadataTest() throws IOException {
String blobName = "myBlob";
- String containerName = "myContainer";
+ String containerName = (csBucket + "MetadataTest").toLowerCase();
BlobStore blobStore = ((CloudCacheStore) cs).blobStore;
+
+ try {
+ blobStore.deleteContainer(containerName);
+ TestingUtil.sleepThread(2000);
+ } catch (Exception e) {
+ }
+
+ blobStore.createContainerInLocation(null, containerName);
+ TestingUtil.sleepThread(2000);
+
Blob b = blobStore.newBlob(blobName);
b.setPayload("Hello world");
b.getMetadata().setUserMetadata(Collections.singletonMap("hello", "world"));
@@ -271,8 +283,8 @@
b = blobStore.getBlob(containerName, blobName);
assert "world".equals(b.getMetadata().getUserMetadata().get("hello"));
-
+
PageSet<? extends StorageMetadata> ps = blobStore.list(containerName, ListContainerOptions.Builder.withDetails());
- for (StorageMetadata sm: ps) assert "world".equals(sm.getUserMetadata().get("hello"));
+ for (StorageMetadata sm : ps) assert "world".equals(sm.getUserMetadata().get("hello"));
}
}
\ No newline at end of file
Modified: trunk/core/src/test/java/org/infinispan/api/CacheAPITest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/api/CacheAPITest.java 2010-05-25 14:09:01 UTC (rev 1844)
+++ trunk/core/src/test/java/org/infinispan/api/CacheAPITest.java 2010-05-25 14:50:46 UTC (rev 1845)
@@ -12,6 +12,8 @@
import org.infinispan.util.concurrent.IsolationLevel;
import org.testng.annotations.Test;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -26,7 +28,7 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
*/
@Test(groups = "functional")
-public abstract class CacheAPITest extends SingleCacheManagerTest {
+public abstract class CacheAPITest extends SingleCacheManagerTest {
protected EmbeddedCacheManager createCacheManager() throws Exception {
// start a single cache instance
@@ -40,7 +42,7 @@
}
protected abstract IsolationLevel getIsolationLevel();
-
+
protected Configuration addEviction(Configuration cfg) {
return cfg; // No eviction by default
}
@@ -448,9 +450,24 @@
for (int i = 0; i < 10; i++) {
cache.put(i, "value" + i);
}
-
+
cache.clear();
-
+
assert cache.isEmpty();
}
+
+ public void testPutIfAbsentAfterRemoveInTx() throws SystemException, NotSupportedException {
+ String key = "key_1", old_value = "old_value", new_value = "new_value";
+ cache.put(key, old_value);
+ assert cache.get(key).equals(old_value);
+
+ TestingUtil.getTransactionManager(cache).begin();
+ assert cache.remove(key).equals(old_value);
+ assert cache.get(key) == null;
+ assert cache.putIfAbsent(key, new_value) == null;
+ TestingUtil.getTransactionManager(cache).rollback();
+
+ assert cache.get(key).equals(new_value);
+
+ }
}
Modified: trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java 2010-05-25 14:09:01 UTC (rev 1844)
+++ trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java 2010-05-25 14:50:46 UTC (rev 1845)
@@ -42,6 +42,8 @@
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
@@ -55,6 +57,7 @@
protected abstract CacheStoreConfig createCacheStoreConfig() throws Exception;
protected CacheStoreConfig csConfig;
+ protected Set<String> cacheNames = new HashSet<String>();
@BeforeMethod
public void setUp() throws Exception {
@@ -76,6 +79,8 @@
localCacheManager.getDefaultConfiguration().setCacheLoaderManagerConfig(clmConfig);
localCacheManager.defineConfiguration("first", new Configuration());
localCacheManager.defineConfiguration("second", new Configuration());
+ cacheNames.add("first");
+ cacheNames.add("second");
Cache first = localCacheManager.getCache("first");
Cache second = localCacheManager.getCache("second");
@@ -106,6 +111,7 @@
CacheManager local = TestCacheManagerFactory.createCacheManager(cfg);
try {
Cache<String, String> cache = local.getCache();
+ cacheNames.add(cache.getName());
cache.start();
assert cache.getConfiguration().getCacheLoaderManagerConfig().isPreload();
@@ -134,6 +140,7 @@
CacheManager localCacheManager = TestCacheManagerFactory.createCacheManager(cfg, true);
try {
Cache<String, Object> cache = localCacheManager.getCache();
+ cacheNames.add(cache.getName());
AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, m.getName());
map.put("a", "b");
@@ -153,6 +160,7 @@
CacheManager localCacheManager = TestCacheManagerFactory.createCacheManager(cfg, true);
try {
Cache<String, Object> cache = localCacheManager.getCache();
+ cacheNames.add(cache.getName());
TransactionManager tm = cache.getAdvancedCache().getTransactionManager();
tm.begin();
final AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, m.getName());
More information about the infinispan-commits
mailing list