[infinispan-commits] Infinispan SVN: r1915 - in branches/4.1.x/cachestore/remote/src/test/java: org and 3 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Jun 16 03:17:18 EDT 2010


Author: galder.zamarreno at jboss.com
Date: 2010-06-16 03:17:17 -0400 (Wed, 16 Jun 2010)
New Revision: 1915

Added:
   branches/4.1.x/cachestore/remote/src/test/java/org/
   branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/
   branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/
   branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/
   branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreConfigTest.java
   branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreFunctionalTest.java
   branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreTest.java
Removed:
   branches/4.1.x/cachestore/remote/src/test/java/org.infinispan.loaders.remote/
Log:
[ISPN-495] (Incorrect directory structure in cachestore/remote) Fixed.

Copied: branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreConfigTest.java (from rev 1904, branches/4.1.x/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreConfigTest.java)
===================================================================
--- branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreConfigTest.java	                        (rev 0)
+++ branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreConfigTest.java	2010-06-16 07:17:17 UTC (rev 1915)
@@ -0,0 +1,64 @@
+package org.infinispan.loaders.remote;
+
+import org.infinispan.Cache;
+import org.infinispan.loaders.CacheLoader;
+import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.server.hotrod.test.HotRodTestingUtil;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * Simple test to sample how remote cache store is configured.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test(testName = "loaders.remote.RemoteCacheStoreConfigTest", groups = "functional")
+public class RemoteCacheStoreConfigTest {
+
+   public static final String CACHE_LOADER_CONFIG = "remote-cl-config.xml";
+   private EmbeddedCacheManager cacheManager;
+   private HotRodServer hotRodServer;
+
+   @BeforeTest
+   public void startUp() {
+      cacheManager = TestCacheManagerFactory.createLocalCacheManager();
+      assertEquals(cacheManager.getCache().size(), 0);
+      hotRodServer = HotRodTestingUtil.startHotRodServer(cacheManager, 19711);
+   }
+
+   public void simpleTest() throws IOException {
+      CacheContainer cm = new DefaultCacheManager(CACHE_LOADER_CONFIG);
+      Cache<Object, Object> cache = cm.getCache();
+      CacheLoader cacheLoader = TestingUtil.getCacheLoader(cache);
+      assert cacheLoader != null;
+      assert cacheLoader instanceof RemoteCacheStore;
+
+
+      cache.put("k", "v");
+
+      assertEquals(1, cacheManager.getCache().size());
+      cache.stop();
+      assertEquals(1, cacheManager.getCache().size());
+      cm.stop();
+      cm = new DefaultCacheManager(CACHE_LOADER_CONFIG);
+      cache = cm.getCache();
+      assertEquals("v", cache.get("k"));
+   }
+
+   @AfterTest
+   public void tearDown() {
+      hotRodServer.stop();
+      cacheManager.stop();
+   }
+}

Copied: branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreFunctionalTest.java (from rev 1904, branches/4.1.x/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreFunctionalTest.java)
===================================================================
--- branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreFunctionalTest.java	                        (rev 0)
+++ branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreFunctionalTest.java	2010-06-16 07:17:17 UTC (rev 1915)
@@ -0,0 +1,53 @@
+package org.infinispan.loaders.remote;
+
+import org.infinispan.client.hotrod.TestHelper;
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test(testName = "loaders.remote.RemoteCacheStoreFunctionalTest", groups = "functional")
+public class RemoteCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
+   private EmbeddedCacheManager localCacheManager;
+   private HotRodServer hrServer;
+
+   @Override
+   protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+      RemoteCacheStoreConfig remoteCacheStoreConfig = new RemoteCacheStoreConfig();
+      localCacheManager = TestCacheManagerFactory.createLocalCacheManager();
+      hrServer = TestHelper.startHotRodServer(localCacheManager);
+
+      remoteCacheStoreConfig.setRemoteCacheName(DefaultCacheManager.DEFAULT_CACHE_NAME);
+      Properties properties = new Properties();
+      properties.put("hotrod-servers", "localhost:"+ hrServer.getPort());
+      remoteCacheStoreConfig.setHotRodClientProperties(properties);
+
+      return remoteCacheStoreConfig;
+   }
+
+   @AfterTest
+   public void tearDown() {
+      hrServer.stop();
+      localCacheManager.stop();
+   }
+
+   @Override
+   public void testPreloadAndExpiry() {
+      assert true : "Remote cache store does not support preload";
+   }
+
+   @Override
+   public void testTwoCachesSameCacheStore() {
+      //not applicable
+   }
+}

Copied: branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreTest.java (from rev 1904, branches/4.1.x/cachestore/remote/src/test/java/org.infinispan.loaders.remote/RemoteCacheStoreTest.java)
===================================================================
--- branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreTest.java	                        (rev 0)
+++ branches/4.1.x/cachestore/remote/src/test/java/org/infinispan/loaders/remote/RemoteCacheStoreTest.java	2010-06-16 07:17:17 UTC (rev 1915)
@@ -0,0 +1,99 @@
+package org.infinispan.loaders.remote;
+
+import org.infinispan.client.hotrod.TestHelper;
+import org.infinispan.config.Configuration;
+import org.infinispan.container.entries.InternalCacheEntry;
+import org.infinispan.container.entries.InternalEntryFactory;
+import org.infinispan.eviction.EvictionStrategy;
+import org.infinispan.loaders.BaseCacheStoreTest;
+import org.infinispan.loaders.CacheLoaderException;
+import org.infinispan.loaders.CacheStore;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test(testName = "loaders.remote.RemoteCacheStoreTest", groups = "functional")
+public class RemoteCacheStoreTest extends BaseCacheStoreTest {
+
+   private EmbeddedCacheManager localCacheManager;
+   private HotRodServer hrServer;
+
+   @Override
+   protected CacheStore createCacheStore() throws Exception {
+      RemoteCacheStoreConfig remoteCacheStoreConfig = new RemoteCacheStoreConfig();
+      remoteCacheStoreConfig.setUseDefaultRemoteCache(true);
+      assert remoteCacheStoreConfig.isUseDefaultRemoteCache();
+      
+      localCacheManager = TestCacheManagerFactory.createLocalCacheManager();
+      Configuration configuration = localCacheManager.getDefaultConfiguration();
+      configuration.setEvictionWakeUpInterval(10);
+      configuration.setEvictionStrategy(EvictionStrategy.UNORDERED);
+      hrServer = TestHelper.startHotRodServer(localCacheManager);
+      Properties properties = new Properties();
+      properties.put("hotrod-servers", "localhost:" + hrServer.getPort());
+      remoteCacheStoreConfig.setHotRodClientProperties(properties);
+
+      RemoteCacheStore remoteCacheStore = new RemoteCacheStore();
+      remoteCacheStore.init(remoteCacheStoreConfig, getCache(), getMarshaller());
+      remoteCacheStore.start();
+      super.supportsLoadAll = false;
+      return remoteCacheStore;
+   }
+
+   @AfterTest
+   public void tearDown() {
+      hrServer.stop();
+      localCacheManager.stop();
+   }
+
+   @Override
+   public void testLoadKeys() throws CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   @Override
+   protected void purgeExpired() throws CacheLoaderException {
+      localCacheManager.getCache().clear();
+   }
+
+   @Override
+   public void testPreload() throws CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   @Override
+   public void testPreloadWithMaxSize() throws CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   protected void sleepForStopStartTest() throws InterruptedException {
+      Thread.sleep(3000);
+   }
+
+
+   @Override
+   public void testStoreAndRemoveAll() throws CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   @Override
+   public void testStreamingAPI() throws IOException, ClassNotFoundException, CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+
+   @Override
+   public void testStreamingAPIReusingStreams() throws IOException, ClassNotFoundException, CacheLoaderException {
+      //not applicable as relies on loadAll
+   }
+}



More information about the infinispan-commits mailing list