[infinispan-commits] Infinispan SVN: r1327 - in trunk: cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary and 15 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Thu Dec 24 09:05:04 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-12-24 09:05:03 -0500 (Thu, 24 Dec 2009)
New Revision: 1327

Modified:
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/TableNameUniquenessTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/BinaryStoreWithManagedConnectionTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/MixedStoreWithManagedConnectionTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/StringStoreWithManagedConnectionTest.java
   trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java
   trunk/core/src/test/java/org/infinispan/api/NoFlushFailureTest.java
   trunk/core/src/test/java/org/infinispan/config/CustomInterceptorConfigTest.java
   trunk/core/src/test/java/org/infinispan/config/SampleConfigFilesCorrectnessTest.java
   trunk/core/src/test/java/org/infinispan/config/StringPropertyReplacementTest.java
   trunk/core/src/test/java/org/infinispan/config/parsing/Coherence2InfinispanTransformerTest.java
   trunk/core/src/test/java/org/infinispan/config/parsing/EHCache2InfinispanTransformerTest.java
   trunk/core/src/test/java/org/infinispan/manager/CacheManagerXmlConfigurationTest.java
   trunk/core/src/test/java/org/infinispan/profiling/AbstractProfileTest.java
   trunk/core/src/test/java/org/infinispan/profiling/MemConsumptionTest.java
   trunk/core/src/test/java/org/infinispan/remoting/jgroups/ChannelLookupTest.java
   trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
   trunk/core/src/test/java/org/infinispan/tx/OnePhaseXATest.java
   trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java
   trunk/query/src/test/java/org/infinispan/query/backend/QueryHelperTest.java
   trunk/query/src/test/java/org/infinispan/query/config/DeclarativeConfigTest.java
   trunk/tree/src/test/java/org/infinispan/profiling/TreeProfileTest.java
Log:
Ensure all tests use the TestCacheManagerFactory to create cache managers, to minimize memory footprint!!

Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/TableNameUniquenessTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/TableNameUniquenessTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/TableNameUniquenessTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -31,8 +31,8 @@
 import org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore;
 import org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStoreConfig;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.Test;
 
 import java.io.Serializable;
@@ -47,7 +47,7 @@
 public class TableNameUniquenessTest {
 
    public void testForJdbcStringBasedCacheStore() throws Exception {
-      CacheManager cm = new DefaultCacheManager("configs/string-based.xml");
+      CacheManager cm = TestCacheManagerFactory.fromXml("configs/string-based.xml");
       Cache<String, String> first = cm.getCache("first");
       Cache<String, String> second = cm.getCache("second");
 
@@ -67,7 +67,7 @@
    }
 
    public void testForJdbcBinaryCacheStore() throws Exception {
-      CacheManager cm = new DefaultCacheManager("configs/binary.xml");
+      CacheManager cm = TestCacheManagerFactory.fromXml("configs/binary.xml");
       Cache<String, String> first = cm.getCache("first");
       Cache<String, String> second = cm.getCache("second");
 
@@ -81,7 +81,7 @@
 
    @SuppressWarnings("unchecked")
    public void testForMixedCacheStore() throws Exception {
-      CacheManager cm = new DefaultCacheManager("configs/mixed.xml");
+      CacheManager cm = TestCacheManagerFactory.fromXml("configs/mixed.xml");
       Cache first = cm.getCache("first");
       Cache second = cm.getCache("second");
 

Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/BinaryStoreWithManagedConnectionTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/BinaryStoreWithManagedConnectionTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/BinaryStoreWithManagedConnectionTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -31,8 +31,8 @@
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
 import org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.infinispan.test.fwk.UnitTestDatabaseManager;
 import org.testng.annotations.Test;
 
@@ -58,7 +58,7 @@
    public void testLoadFromFile() throws Exception {
       CacheManager cm = null;
       try {
-         cm = new DefaultCacheManager("configs/managed/binary-managed-connection-factory.xml");
+         cm = TestCacheManagerFactory.fromXml("configs/managed/binary-managed-connection-factory.xml");
          Cache<String, String> first = cm.getCache("first");
          Cache<String, String> second = cm.getCache("second");
 

Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/MixedStoreWithManagedConnectionTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/MixedStoreWithManagedConnectionTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/MixedStoreWithManagedConnectionTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -31,8 +31,8 @@
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
 import org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.infinispan.test.fwk.UnitTestDatabaseManager;
 import org.testng.annotations.Test;
 
@@ -62,7 +62,7 @@
    public void testLoadFromFile() throws Exception {
       CacheManager cm = null;
       try {
-         cm = new DefaultCacheManager("configs/managed/mixed-managed-connection-factory.xml");
+         cm = TestCacheManagerFactory.fromXml("configs/managed/mixed-managed-connection-factory.xml");
          Cache<String, String> first = cm.getCache("first");
          Cache<String, String> second = cm.getCache("second");
 

Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/StringStoreWithManagedConnectionTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/StringStoreWithManagedConnectionTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/StringStoreWithManagedConnectionTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -31,8 +31,8 @@
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
 import org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.infinispan.test.fwk.UnitTestDatabaseManager;
 import org.testng.annotations.Test;
 
@@ -57,7 +57,7 @@
    public void testLoadFromFile() throws Exception {
       CacheManager cm = null;
       try {
-         cm = new DefaultCacheManager("configs/managed/str-managed-connection-factory.xml");
+         cm = TestCacheManagerFactory.fromXml("configs/managed/str-managed-connection-factory.xml");
          Cache<String, String> first = cm.getCache("first");
          Cache<String, String> second = cm.getCache("second");
 

Modified: trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -28,9 +28,9 @@
 import org.infinispan.factories.annotations.ComponentName;
 import org.infinispan.factories.annotations.DefaultFactoryFor;
 import org.infinispan.factories.annotations.Inject;
-import org.infinispan.factories.annotations.SurvivesRestarts;
 import org.infinispan.factories.annotations.Start;
 import org.infinispan.factories.annotations.Stop;
+import org.infinispan.factories.annotations.SurvivesRestarts;
 import org.infinispan.factories.scopes.Scope;
 import org.infinispan.factories.scopes.Scopes;
 import org.infinispan.lifecycle.ComponentStatus;
@@ -41,6 +41,7 @@
 import org.infinispan.util.logging.Log;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -639,7 +640,11 @@
     */
    private void handleLifecycleTransitionFailure(Throwable t) {
       state = ComponentStatus.FAILED;
-      if (t instanceof CacheException)
+      if (t.getCause() != null && t.getCause() instanceof ConfigurationException)
+         throw (ConfigurationException) t.getCause();
+      else if (t.getCause() != null && t.getCause() instanceof InvocationTargetException && t.getCause().getCause() != null && t.getCause().getCause() instanceof ConfigurationException)
+         throw (ConfigurationException) t.getCause().getCause();
+      else if (t instanceof CacheException)
          throw (CacheException) t;
       else if (t instanceof RuntimeException)
          throw (RuntimeException) t;

Modified: trunk/core/src/test/java/org/infinispan/api/NoFlushFailureTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/api/NoFlushFailureTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/api/NoFlushFailureTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -1,8 +1,8 @@
 package org.infinispan.api;
 
-import org.infinispan.Cache;
+import org.infinispan.config.ConfigurationException;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.Test;
 
 /**
@@ -14,20 +14,12 @@
 public class NoFlushFailureTest {
 
    CacheManager cm1;
-   CacheManager cm2;
    private static final String FILE = "configs/no-flush.xml";
-   private Cache<Object,Object> c1;
-   private Cache<Object,Object> c2;
 
-   @Test
+   @Test (expectedExceptions = ConfigurationException.class)
    public void simpleTest() throws Exception {
-      cm1 = new DefaultCacheManager(FILE);
-      try {
-         cm1.getCache();
-         assert false : "Exception expected!";
-      } catch (Exception e) {
-         //expected
-      }
+      cm1 = TestCacheManagerFactory.fromXml(FILE);
+      cm1.getCache();
    }
 }
 

Modified: trunk/core/src/test/java/org/infinispan/config/CustomInterceptorConfigTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/CustomInterceptorConfigTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/config/CustomInterceptorConfigTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -4,8 +4,8 @@
 import org.infinispan.interceptors.InvocationContextInterceptor;
 import org.infinispan.interceptors.base.CommandInterceptor;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 
@@ -26,7 +26,7 @@
             "</customInterceptors> </default></infinispan>";
 
       InputStream stream = new ByteArrayInputStream(xml.getBytes());
-      cm = new DefaultCacheManager(stream);
+      cm = TestCacheManagerFactory.fromStream(stream);
       c = cm.getCache();
       DummyInterceptor i = TestingUtil.findInterceptor(c, DummyInterceptor.class);
       assert i != null;

Modified: trunk/core/src/test/java/org/infinispan/config/SampleConfigFilesCorrectnessTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/SampleConfigFilesCorrectnessTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/config/SampleConfigFilesCorrectnessTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -4,9 +4,9 @@
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.log4j.spi.LoggingEvent;
-import org.infinispan.Cache;
-import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.CacheManager;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -47,10 +47,9 @@
 
    public void testConfigWarnings() throws Exception {
       for (String aConfFile : getConfigFileNames()) {
-         System.out.println("Testing config file " + getRootFolder() + "/" + aConfFile);
-         DefaultCacheManager dcm = new DefaultCacheManager(getRootFolder() + "/" + aConfFile);
+         CacheManager dcm = TestCacheManagerFactory.fromXml(getRootFolder() + "/" + aConfFile);
          try {
-            Cache defaultCache = dcm.getCache();
+            dcm.getCache();
             assert !appender.isFoundUnknownWarning();
             for (String cacheName : dcm.getCacheNames()) {
                dcm.getCache(cacheName);

Modified: trunk/core/src/test/java/org/infinispan/config/StringPropertyReplacementTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/StringPropertyReplacementTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/config/StringPropertyReplacementTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -1,10 +1,10 @@
 package org.infinispan.config;
 
-import org.testng.annotations.Test;
+import org.infinispan.manager.CacheManager;
 import org.infinispan.test.SingleCacheManagerTest;
-import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.infinispan.util.concurrent.IsolationLevel;
+import org.testng.annotations.Test;
 
 import java.util.Properties;
 
@@ -24,7 +24,7 @@
       System.setProperty("test.property.IsolationLevel","READ_COMMITTED");
       System.setProperty("test.property.writeSkewCheck","true");
       System.setProperty("test.property.SyncCommitPhase","true");
-      return new DefaultCacheManager("configs/string-property-replaced.xml");
+      return TestCacheManagerFactory.fromXml("configs/string-property-replaced.xml");
    }
 
    public void testGlobalConfig() {

Modified: trunk/core/src/test/java/org/infinispan/config/parsing/Coherence2InfinispanTransformerTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/parsing/Coherence2InfinispanTransformerTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/config/parsing/Coherence2InfinispanTransformerTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -1,9 +1,10 @@
 package org.infinispan.config.parsing;
 
 import org.infinispan.Cache;
-import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.CacheManager;
 import org.infinispan.test.AbstractInfinispanTest;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.Test;
 
 import java.io.ByteArrayInputStream;
@@ -32,7 +33,7 @@
     */
    private void testAllFile(String coherenceFileName) throws Exception {
       ClassLoader existingCl = Thread.currentThread().getContextClassLoader();
-      DefaultCacheManager dcm = null;
+      CacheManager dcm = null;
       Cache<Object, Object> sampleDistributedCache2 = null;
       try {
          ClassLoader delegatingCl = new Jbc2InfinispanTransformerTest.TestClassLoader(existingCl);
@@ -50,7 +51,7 @@
          baos.close();
          fos.close();
 
-         dcm = new DefaultCacheManager(new ByteArrayInputStream(baos.toByteArray()));
+         dcm = TestCacheManagerFactory.fromStream(new ByteArrayInputStream(baos.toByteArray()));
          Cache<Object,Object> defaultCache = dcm.getCache();
          defaultCache.put("key", "value");
 

Modified: trunk/core/src/test/java/org/infinispan/config/parsing/EHCache2InfinispanTransformerTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/parsing/EHCache2InfinispanTransformerTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/config/parsing/EHCache2InfinispanTransformerTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -8,7 +8,7 @@
 import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.test.AbstractInfinispanTest;
 import org.infinispan.test.TestingUtil;
-import static org.testng.Assert.assertEquals;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.Test;
 
 import java.io.ByteArrayInputStream;
@@ -16,6 +16,8 @@
 import java.io.File;
 import java.io.FileOutputStream;
 
+import static org.testng.Assert.assertEquals;
+
 /**
  * @author Mircea.Markus at jboss.com
  */
@@ -58,7 +60,7 @@
          baos.close();
          fos.close();
 
-         dcm = new DefaultCacheManager(new ByteArrayInputStream(baos.toByteArray()));
+         dcm = (DefaultCacheManager) TestCacheManagerFactory.fromStream(new ByteArrayInputStream(baos.toByteArray()));
          Cache<Object,Object> defaultCache = dcm.getCache();
          defaultCache.put("key", "value");
          Configuration configuration = defaultCache.getConfiguration();

Modified: trunk/core/src/test/java/org/infinispan/manager/CacheManagerXmlConfigurationTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/manager/CacheManagerXmlConfigurationTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/manager/CacheManagerXmlConfigurationTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -5,6 +5,7 @@
 import org.infinispan.test.TestingUtil;
 import org.infinispan.config.Configuration;
 import org.infinispan.remoting.rpc.RpcManager;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 
@@ -18,7 +19,7 @@
  */
 @Test(groups = "functional", testName = "manager.CacheManagerXmlConfigurationTest")
 public class CacheManagerXmlConfigurationTest extends AbstractInfinispanTest {
-   DefaultCacheManager cm;
+   CacheManager cm;
 
    @AfterMethod
    public void tearDown() {
@@ -27,7 +28,7 @@
    }
 
    public void testNamedCacheXML() throws IOException {
-      cm = new DefaultCacheManager("configs/named-cache-test.xml");
+      cm = TestCacheManagerFactory.fromXml("configs/named-cache-test.xml");
 
       // test default cache
       Cache c = cm.getCache();
@@ -80,7 +81,7 @@
 
       ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
       try {
-         cm = new DefaultCacheManager(bais);
+         cm = TestCacheManagerFactory.fromStream(bais);
          assert false : "Should fail";
       } catch (Throwable expected) {
 
@@ -106,7 +107,7 @@
             "</infinispan>";
 
       ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
-      cm = new DefaultCacheManager(bais);
+      cm = TestCacheManagerFactory.fromStream(bais);
 
       assert cm.getCache() != null;
       assert cm.getCache("c1") != null;

Modified: trunk/core/src/test/java/org/infinispan/profiling/AbstractProfileTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/profiling/AbstractProfileTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/profiling/AbstractProfileTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -1,19 +1,20 @@
 package org.infinispan.profiling;
 
 import org.infinispan.config.Configuration;
-import static org.infinispan.config.Configuration.CacheMode.*;
 import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.executors.ExecutorFactory;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
 import org.infinispan.util.concurrent.WithinThreadExecutor;
-import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
 import org.testng.annotations.Test;
 
 import java.util.Properties;
 import java.util.concurrent.ExecutorService;
 
+import static org.infinispan.config.Configuration.CacheMode.*;
+
 @Test(groups = "profiling", enabled = false, testName = "profiling.AbstractProfileTest")
 public abstract class AbstractProfileTest extends SingleCacheManagerTest {
 
@@ -56,7 +57,7 @@
    protected CacheManager createCacheManager() throws Exception {
       GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
       gc.setAsyncTransportExecutorFactoryClass(WTE.class.getName());
-      cacheManager = new DefaultCacheManager(gc);
+      cacheManager = TestCacheManagerFactory.createCacheManager(gc);
 
       cacheManager.defineConfiguration(LOCAL_CACHE_NAME, getBaseCfg());
 

Modified: trunk/core/src/test/java/org/infinispan/profiling/MemConsumptionTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/profiling/MemConsumptionTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/profiling/MemConsumptionTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -23,9 +23,10 @@
 
 import org.infinispan.Cache;
 import org.infinispan.CacheException;
-import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.config.Configuration;
 import org.infinispan.test.AbstractInfinispanTest;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.Test;
 
 import java.io.IOException;
@@ -53,7 +54,7 @@
       int kBytesCached = (bytesPerCharacter * numEntries * (payloadSize + keySize)) / 1024;
       System.out.println("Bytes to be cached: " + NumberFormat.getIntegerInstance().format(kBytesCached) + " kb");
 
-      Cache c = new DefaultCacheManager().getCache();
+      Cache c = TestCacheManagerFactory.createCacheManager(new Configuration()).getCache();
       for (int i = 0; i < numEntries; i++) {
          switch (payloadType) {
             case STRINGS:

Modified: trunk/core/src/test/java/org/infinispan/remoting/jgroups/ChannelLookupTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/remoting/jgroups/ChannelLookupTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/remoting/jgroups/ChannelLookupTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -4,12 +4,12 @@
 import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.factories.GlobalComponentRegistry;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.remoting.transport.Transport;
 import org.infinispan.remoting.transport.jgroups.JGroupsChannelLookup;
 import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
 import org.infinispan.test.AbstractInfinispanTest;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.jgroups.Address;
 import org.jgroups.Channel;
 import org.jgroups.JChannel;
@@ -24,7 +24,7 @@
       Properties p = new Properties();
       p.setProperty("channelLookup", DummyLookup.class.getName());
       gc.setTransportProperties(p);
-      CacheManager cm = new DefaultCacheManager(gc);
+      CacheManager cm = TestCacheManagerFactory.createCacheManager(gc);
       cm.start();
       cm.getCache();
       GlobalComponentRegistry gcr = TestingUtil.extractGlobalComponentRegistry(cm);

Modified: trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -1,7 +1,9 @@
 package org.infinispan.test.fwk;
 
 import org.infinispan.config.Configuration;
+import org.infinispan.config.ConfigurationValidatingVisitor;
 import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.config.InfinispanConfiguration;
 import org.infinispan.jmx.PerThreadMBeanServerLookup;
 import org.infinispan.manager.CacheManager;
 import org.infinispan.manager.DefaultCacheManager;
@@ -10,6 +12,9 @@
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
 import java.util.Properties;
 
 /**
@@ -27,6 +32,34 @@
       return new DefaultCacheManager(gc, c);
    }
 
+   public static CacheManager fromXml(String xmlFile) throws IOException {
+      InfinispanConfiguration parser = InfinispanConfiguration.newInfinispanConfiguration(
+               xmlFile,
+               InfinispanConfiguration.resolveSchemaPath(),
+               new ConfigurationValidatingVisitor());
+      return fromConfigFileParser(parser);
+   }
+
+   public static CacheManager fromStream(InputStream is) throws IOException {
+      InfinispanConfiguration parser = InfinispanConfiguration.newInfinispanConfiguration(
+               is, InfinispanConfiguration.findSchemaInputStream(),
+               new ConfigurationValidatingVisitor());
+      return fromConfigFileParser(parser);      
+   }
+
+   private static CacheManager fromConfigFileParser(InfinispanConfiguration parser) {
+      GlobalConfiguration gc = parser.parseGlobalConfiguration();
+      Map<String, Configuration> named = parser.parseNamedConfigurations();
+      Configuration c = parser.parseDefaultConfiguration();
+
+      minimizeThreads(gc);
+
+      CacheManager cm = new DefaultCacheManager(gc, c, false);
+      for (Map.Entry<String, Configuration> e: named.entrySet()) cm.defineConfiguration(e.getKey(), e.getValue());
+      cm.start();
+      return cm;
+   }
+
    /**
     * Creates an cache manager that does not support clustering or transactions.
     */
@@ -117,9 +150,14 @@
    }
 
    public static CacheManager createCacheManager(GlobalConfiguration configuration, Configuration defaultCfg) {
+      return createCacheManager(configuration, defaultCfg, false);
+   }
+
+   public static CacheManager createCacheManager(GlobalConfiguration configuration, Configuration defaultCfg, boolean transactional) {
       minimizeThreads(configuration);
       amendMarshaller(configuration);
       amendTransport(configuration);
+      if (transactional) amendJTA(defaultCfg);
       return newDefaultCacheManager(configuration, defaultCfg);
    }
 

Modified: trunk/core/src/test/java/org/infinispan/tx/OnePhaseXATest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/tx/OnePhaseXATest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/core/src/test/java/org/infinispan/tx/OnePhaseXATest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -4,10 +4,9 @@
 import org.infinispan.config.Configuration;
 import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.test.AbstractInfinispanTest;
 import org.infinispan.test.TestingUtil;
-import org.infinispan.test.fwk.TransactionSetup;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -63,9 +62,7 @@
       c.setLockAcquisitionTimeout(60000);
       c.setUseLockStriping(false);
       c.setSyncCommitPhase(true);
-      c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
-
-      CacheManager manager = new DefaultCacheManager(gc, c);
+      CacheManager manager = TestCacheManagerFactory.createCacheManager(gc, c, true);
       return manager.getCache("TestCache");
    }
 }
\ No newline at end of file

Modified: trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java
===================================================================
--- trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -21,34 +21,33 @@
  */
 package org.infinispan.lucene;
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Random;
-
 import org.apache.lucene.document.DateTools;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriter.MaxFieldLength;
 import org.apache.lucene.index.SerialMergeScheduler;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.index.IndexWriter.MaxFieldLength;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.LockObtainFailedException;
-import org.infinispan.util.logging.Log;
-import org.infinispan.util.logging.LogFactory;
-import org.infinispan.test.fwk.TestCacheManagerFactory;
-import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
 import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.lucene.testutils.LuceneSettings;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
 
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Random;
+
 public abstract class CacheTestSupport {
 
    private static final Log log = LogFactory.getLog(CacheTestSupport.class);
@@ -139,8 +138,7 @@
       cfg.setExposeJmxStatistics(false);
       cfg.setL1CacheEnabled(false);
       cfg.setWriteSkewCheck(false);
-      cfg.setTransactionManagerLookupClass(JBossStandaloneJTAManagerLookup.class.getName());
-      return new DefaultCacheManager(globalConfiguration, cfg);
+      return TestCacheManagerFactory.createCacheManager(globalConfiguration, cfg, true);
    }
    
    public static void initializeDirectory(Directory directory) throws IOException {

Modified: trunk/query/src/test/java/org/infinispan/query/backend/QueryHelperTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/backend/QueryHelperTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/query/src/test/java/org/infinispan/query/backend/QueryHelperTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -4,9 +4,9 @@
 import org.infinispan.CacheException;
 import org.infinispan.config.Configuration;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.query.test.Person;
 import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -41,7 +41,7 @@
    }
 
    private Cache<?, ?> createCache(Configuration c) {
-      CacheManager cm = new DefaultCacheManager(c);
+      CacheManager cm = TestCacheManagerFactory.createCacheManager(c);
       cacheManagers.add(cm);
       return cm.getCache();
    }

Modified: trunk/query/src/test/java/org/infinispan/query/config/DeclarativeConfigTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/config/DeclarativeConfigTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/query/src/test/java/org/infinispan/query/config/DeclarativeConfigTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -9,6 +9,7 @@
 import org.infinispan.query.helper.TestQueryHelperFactory;
 import org.infinispan.query.test.Person;
 import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.Test;
 
 import java.io.ByteArrayInputStream;
@@ -31,7 +32,7 @@
             "</infinispan>";
 
       InputStream is = new ByteArrayInputStream(config.getBytes());
-      cacheManager = new DefaultCacheManager(is, true);
+      cacheManager = TestCacheManagerFactory.fromStream(is);
       cache = cacheManager.getCache();
       QueryHelper qh = TestQueryHelperFactory.createTestQueryHelperInstance(cache, Person.class);
       qf = new QueryFactory(cache, qh);

Modified: trunk/tree/src/test/java/org/infinispan/profiling/TreeProfileTest.java
===================================================================
--- trunk/tree/src/test/java/org/infinispan/profiling/TreeProfileTest.java	2009-12-24 01:40:24 UTC (rev 1326)
+++ trunk/tree/src/test/java/org/infinispan/profiling/TreeProfileTest.java	2009-12-24 14:05:03 UTC (rev 1327)
@@ -3,12 +3,12 @@
 import org.infinispan.Cache;
 import org.infinispan.config.Configuration;
 import org.infinispan.manager.CacheManager;
-import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.profiling.testinternals.FqnGenerator;
 import org.infinispan.profiling.testinternals.Generator;
 import org.infinispan.profiling.testinternals.TaskRunner;
 import org.infinispan.test.TestingUtil;
 import org.infinispan.test.TreeTestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.infinispan.transaction.tm.DummyTransactionManager;
 import org.infinispan.tree.Fqn;
 import org.infinispan.tree.TreeCache;
@@ -66,7 +66,7 @@
       cfg.setConcurrencyLevel(2000);
       cfg.setLockAcquisitionTimeout(120000);
       cfg.setIsolationLevel(IsolationLevel.READ_COMMITTED);
-      cacheManager = new DefaultCacheManager(cfg);
+      cacheManager = TestCacheManagerFactory.createCacheManager(cfg);
       Cache c = cacheManager.getCache();
       cache = new TreeCacheImpl(c);
    }



More information about the infinispan-commits mailing list