[infinispan-commits] Infinispan SVN: r634 - in trunk: cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc and 7 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Wed Aug 5 12:06:51 EDT 2009
Author: galder.zamarreno at jboss.com
Date: 2009-08-05 12:06:50 -0400 (Wed, 05 Aug 2009)
New Revision: 634
Added:
trunk/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreFunctionalIntegrationTest.java
trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java
trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreFunctionalTest.java
trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreFunctionalTest.java
trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreFunctionalTest.java
trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreFunctionalIntegrationTest.java
trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java
trunk/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreFunctionalTest.java
Modified:
trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java
trunk/core/src/test/java/org/infinispan/loaders/decorators/ChainingCacheLoaderTest.java
Log:
[ISPN-106] (JdbcXyzCacheStore should honor cache name) Factored out testTwoCachesSameCacheStore into BaseCacheStoreFuntionalTest where we can add Cache/CacheManager related cache store functional tests and created respective tests for each cache store implementation.
Added: trunk/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreFunctionalIntegrationTest.java
===================================================================
--- trunk/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreFunctionalIntegrationTest.java (rev 0)
+++ trunk/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreFunctionalIntegrationTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.bdbje;
+
+import java.io.File;
+
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.test.TestingUtil;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+ at Test(groups = "unit", enabled = true, testName = "loaders.bdbje.BdbjeCacheStoreFunctionalIntegrationTest")
+public class BdbjeCacheStoreFunctionalIntegrationTest extends BaseCacheStoreFunctionalTest {
+
+ private String tmpDirectory;
+
+ @BeforeTest
+ @Parameters({"basedir"})
+ protected void setUpTempDir(String basedir) {
+ tmpDirectory = basedir + TestingUtil.TEST_PATH + File.separator + getClass().getSimpleName();
+ }
+
+ @AfterTest
+ protected void clearTempDir() {
+ TestingUtil.recursiveFileRemove(tmpDirectory);
+ new File(tmpDirectory).mkdirs();
+ }
+
+ @Override
+ protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+ BdbjeCacheStoreConfig cfg = new BdbjeCacheStoreConfig();
+ cfg.setLocation(tmpDirectory);
+ cfg.setPurgeSynchronously(true);
+ return cfg;
+ }
+
+}
Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.jdbc;
+
+import org.infinispan.CacheDelegate;
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStore;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStore;
+import org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStoreConfig;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.testng.annotations.Test;
+
+/**
+ * JdbcBinaryCacheStoreFunctionalTest.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.JdbcBinaryCacheStoreFunctionalTest")
+public class JdbcBinaryCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
+
+ @Override
+ protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+ ConnectionFactoryConfig connectionFactoryConfig = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
+ TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+ JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(connectionFactoryConfig, tm);
+ return config;
+// JdbcBinaryCacheStore jdbcBucketCacheStore = new JdbcBinaryCacheStore();
+// jdbcBucketCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
+// jdbcBucketCacheStore.start();
+// assert jdbcBucketCacheStore.getConnectionFactory() != null;
+// return jdbcBucketCacheStore;
+ }
+}
Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreFunctionalTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreFunctionalTest.java (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreFunctionalTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.jdbc.mixed;
+
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.loaders.jdbc.TableManipulation;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.testng.annotations.Test;
+
+ at Test(groups = "functional", testName = "loaders.jdbc.mixed.JdbcMixedCacheStoreFunctionalTest")
+public class JdbcMixedCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
+
+ @Override
+ protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+ JdbcMixedCacheStoreConfig jdbcCacheStoreConfig = new JdbcMixedCacheStoreConfig();
+ TableManipulation stringsTm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+ stringsTm.setTableNamePrefix("STRINGS_TABLE");
+ TableManipulation binaryTm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+ binaryTm.setTableNamePrefix("BINARY_TABLE");
+ ConnectionFactoryConfig cfc = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
+ jdbcCacheStoreConfig.setConnectionFactoryConfig(cfc);
+ jdbcCacheStoreConfig.setStringsTableManipulation(stringsTm);
+ jdbcCacheStoreConfig.setBinaryTableManipulation(binaryTm);
+ return jdbcCacheStoreConfig;
+ }
+
+}
Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreFunctionalTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreFunctionalTest.java (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreFunctionalTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.jdbc.stringbased;
+
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.loaders.jdbc.TableManipulation;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.testng.annotations.Test;
+
+ at Test(groups = "functional", testName = "loaders.jdbc.stringbased.JdbcStringBasedCacheStoreFunctionalTest")
+public class JdbcStringBasedCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
+
+ @Override
+ protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+ ConnectionFactoryConfig connectionFactoryConfig = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
+ TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+ JdbcStringBasedCacheStoreConfig config = new JdbcStringBasedCacheStoreConfig(connectionFactoryConfig, tm);
+ return config;
+ }
+
+}
Added: trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreFunctionalTest.java
===================================================================
--- trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreFunctionalTest.java (rev 0)
+++ trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreFunctionalTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.jdbm;
+
+import java.io.File;
+
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.test.TestingUtil;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+ at Test(groups = "unit", testName = "loaders.jdbm.JdbmCacheStoreFunctionalTest")
+public class JdbmCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
+
+ private String tmpDirectory;
+
+ @BeforeTest
+ @Parameters({"basedir"})
+ protected void setUpTempDir(String basedir) {
+ tmpDirectory = basedir + TestingUtil.TEST_PATH + File.separator + getClass().getSimpleName();
+ }
+
+ @AfterTest
+ protected void clearTempDir() {
+ TestingUtil.recursiveFileRemove(tmpDirectory);
+ new File(tmpDirectory).mkdirs();
+ }
+
+ @Override
+ protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+ JdbmCacheStoreConfig cfg = new JdbmCacheStoreConfig();
+ cfg.setLocation(tmpDirectory);
+ cfg.setPurgeSynchronously(true); // for more accurate unit testing
+ return cfg;
+ }
+
+}
Added: trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreFunctionalIntegrationTest.java
===================================================================
--- trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreFunctionalIntegrationTest.java (rev 0)
+++ trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreFunctionalIntegrationTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.s3;
+
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+ at Test(groups = "unit", sequential = true, testName = "loaders.s3.S3CacheStoreFunctionalIntegrationTest")
+public class S3CacheStoreFunctionalIntegrationTest extends BaseCacheStoreFunctionalTest {
+
+ private String proxyHost;
+ private int proxyPort = -1;
+ private int maxConnections = 20;
+ private boolean isSecure = false;
+ private String csBucket;
+ private String accessKey;
+ private String secretKey;
+
+ private static final String sysAWSAccessKeyId = System
+ .getProperty("jclouds.aws.accesskeyid");
+ private static final String sysAWSSecretAccessKey = System
+ .getProperty("jclouds.aws.secretaccesskey");
+
+ @BeforeTest
+ @Parameters({"jclouds.aws.accesskeyid", "jclouds.aws.secretaccesskey"})
+ protected void setUpClient(@Optional String AWSAccessKeyId,
+ @Optional String AWSSecretAccessKey) throws Exception {
+
+ accessKey = (AWSAccessKeyId == null) ? sysAWSAccessKeyId : AWSAccessKeyId;
+ secretKey = (AWSSecretAccessKey == null) ? sysAWSSecretAccessKey : AWSSecretAccessKey;
+
+ if (accessKey == null || accessKey.trim().equals("") ||
+ secretKey == null || secretKey.trim().equals("")) {
+ accessKey = "dummy";
+ secretKey = "dummy";
+ } else {
+ proxyHost = "localhost"; // TODO not yet used
+ proxyPort = 8888; // TODO not yet used
+ }
+ csBucket = (System.getProperty("user.name")
+ + "." + this.getClass().getSimpleName()).toLowerCase();
+ System.out.printf("accessKey: %1$s, bucket: %2$s%n", accessKey, csBucket);
+ }
+
+ @Override
+ protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+ S3CacheStoreConfig cfg = new S3CacheStoreConfig();
+ cfg.setBucket(csBucket);
+ cfg.setAwsAccessKey(accessKey);
+ cfg.setAwsSecretKey(secretKey);
+ cfg.setProxyHost(proxyHost);
+ cfg.setProxyPort(proxyPort);
+ cfg.setSecure(isSecure);
+ cfg.setMaxConnections(maxConnections);
+ cfg.setPurgeSynchronously(true); // for more accurate unit testing
+ return cfg;
+ }
+
+}
Added: trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java (rev 0)
+++ trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreFunctionalTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders;
+
+import java.util.Collections;
+
+import org.infinispan.Cache;
+import org.infinispan.config.CacheLoaderManagerConfig;
+import org.infinispan.config.Configuration;
+import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * This is a base functional test class containing tests that should be executed for each cache store/loader
+ * implementation. As these are functional tests, they should interact against Cache/CacheManager only and
+ * any access to the underlying cache store/loader should be done to verify contents.
+ */
+ at Test(groups = "unit", testName = "loaders.BaseCacheStoreFunctionalTest")
+public abstract class BaseCacheStoreFunctionalTest {
+
+ protected abstract CacheStoreConfig createCacheStoreConfig() throws Exception;
+
+ protected CacheStoreConfig csc;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ try {
+ csc = createCacheStoreConfig();
+ } catch (Exception e) {
+ //in IDEs this won't be printed which makes debugging harder
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ public void testTwoCachesSameCacheStore() {
+ CacheManager localCacheManager = TestCacheManagerFactory.createLocalCacheManager();
+ GlobalConfiguration configuration = localCacheManager.getGlobalConfiguration();
+ CacheStoreConfig config = csc;
+ assert config != null;
+ CacheLoaderManagerConfig clmConfig = new CacheLoaderManagerConfig();
+ clmConfig.setCacheLoaderConfigs(Collections.singletonList((CacheLoaderConfig)config));
+ configuration.getDefaultConfiguration().setCacheLoaderManagerConfig(clmConfig);
+ localCacheManager.defineCache("first", new Configuration());
+ localCacheManager.defineCache("second", new Configuration());
+
+ Cache first = localCacheManager.getCache("first");
+ Cache second = localCacheManager.getCache("second");
+ assert first.getConfiguration().getCacheLoaderManagerConfig().getCacheLoaderConfigs().size() == 1;
+ assert second.getConfiguration().getCacheLoaderManagerConfig().getCacheLoaderConfigs().size() == 1;
+
+ first.start();
+ second.start();
+
+ first.put("key", "val");
+ assert first.get("key").equals("val");
+ assert second.get("key") == null;
+
+ second.put("key2","val2");
+ assert second.get("key2").equals("val2");
+ assert first.get("key2") == null;
+
+ TestingUtil.killCacheManagers(localCacheManager);
+ }
+}
Modified: trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java 2009-08-05 15:13:44 UTC (rev 633)
+++ trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -2,9 +2,6 @@
import org.easymock.EasyMock;
import org.infinispan.Cache;
-import org.infinispan.config.CacheLoaderManagerConfig;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
import org.infinispan.container.entries.InternalCacheEntry;
import org.infinispan.container.entries.InternalEntryFactory;
import org.infinispan.io.UnclosableObjectInputStream;
@@ -13,12 +10,8 @@
import org.infinispan.loaders.modifications.Modification;
import org.infinispan.loaders.modifications.Remove;
import org.infinispan.loaders.modifications.Store;
-import org.infinispan.manager.CacheManager;
import org.infinispan.marshall.Marshaller;
import org.infinispan.marshall.TestObjectStreamMarshaller;
-import org.infinispan.marshall.VersionAwareMarshaller;
-import org.infinispan.test.TestingUtil;
-import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.infinispan.transaction.xa.GlobalTransaction;
import org.infinispan.transaction.xa.GlobalTransactionFactory;
import org.infinispan.util.Util;
@@ -32,13 +25,17 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
+/**
+ * This is a base class containing various unit tests for each and every different CacheStore implementations.
+ * If you need to add Cache/CacheManager tests that need to be run for each cache store/loader implementation,
+ * then use BaseCacheStoreFunctionalTest.
+ */
@SuppressWarnings("unchecked")
// this needs to be here for the test to run in an IDE
@Test(groups = "unit", testName = "loaders.BaseCacheStoreTest")
@@ -590,37 +587,4 @@
if (!exceptions.isEmpty()) throw exceptions.get(0);
}
- public void testTwoCachesSameCacheStore() {
- CacheManager localCacheManager = TestCacheManagerFactory.createLocalCacheManager();
- GlobalConfiguration configuration = localCacheManager.getGlobalConfiguration();
- CacheStoreConfig config = cs.getCacheStoreConfig();
- assert config != null;
- CacheLoaderManagerConfig clmConfig = new CacheLoaderManagerConfig();
- clmConfig.setCacheLoaderConfigs(Collections.singletonList((CacheLoaderConfig)config));
- configuration.getDefaultConfiguration().setCacheLoaderManagerConfig(clmConfig);
- localCacheManager.defineCache("first", new Configuration());
- localCacheManager.defineCache("second", new Configuration());
-
- Cache first = localCacheManager.getCache("first");
- Cache second = localCacheManager.getCache("second");
- assert first.getConfiguration().getCacheLoaderManagerConfig().getCacheLoaderConfigs().size() == 1;
- assert second.getConfiguration().getCacheLoaderManagerConfig().getCacheLoaderConfigs().size() == 1;
-
- //TODO - this is a hack as VAM.start does not get called, for some reason. This should be removed.
- VersionAwareMarshaller firstVam = (VersionAwareMarshaller) TestingUtil.extractComponent(first, Marshaller.class);
- firstVam.start();
- VersionAwareMarshaller secondVam = (VersionAwareMarshaller) TestingUtil.extractComponent(first, Marshaller.class);
- secondVam.start();
-
-
- first.put("key", "val");
- assert first.get("key").equals("val");
- assert second.get("key") == null;
-
- second.put("key2","val2");
- assert second.get("key2").equals("val2");
- assert first.get("key2") == null;
-
- TestingUtil.killCacheManagers(localCacheManager);
- }
}
\ No newline at end of file
Modified: trunk/core/src/test/java/org/infinispan/loaders/decorators/ChainingCacheLoaderTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/decorators/ChainingCacheLoaderTest.java 2009-08-05 15:13:44 UTC (rev 633)
+++ trunk/core/src/test/java/org/infinispan/loaders/decorators/ChainingCacheLoaderTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -283,9 +283,5 @@
// no op
}
- @Override
- public void testTwoCachesSameCacheStore() {
- //this does not apply
- }
}
Added: trunk/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreFunctionalTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreFunctionalTest.java (rev 0)
+++ trunk/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreFunctionalTest.java 2009-08-05 16:06:50 UTC (rev 634)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.file;
+
+import java.io.File;
+
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.test.TestingUtil;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+ at Test(groups = "unit", testName = "loaders.file.FileCacheStoreFunctionalTest")
+public class FileCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
+
+ private String tmpDirectory;
+
+ @BeforeTest
+ @Parameters({"basedir"})
+ protected void setUpTempDir(String basedir) {
+ tmpDirectory = basedir + TestingUtil.TEST_PATH + File.separator + getClass().getSimpleName();
+ }
+
+ @AfterTest
+ protected void clearTempDir() {
+ TestingUtil.recursiveFileRemove(tmpDirectory);
+ new File(tmpDirectory).mkdirs();
+ }
+
+ @Override
+ protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+ FileCacheStoreConfig cfg = new FileCacheStoreConfig();
+ cfg.setLocation(tmpDirectory);
+ cfg.setPurgeSynchronously(true); // for more accurate unit testing
+ return cfg;
+ }
+
+}
More information about the infinispan-commits
mailing list