[jbosscache-commits] JBoss Cache SVN: r7603 - in core/branches/flat/src: main/java/org/horizon/config and 18 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jan 27 13:01:32 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-01-27 13:01:32 -0500 (Tue, 27 Jan 2009)
New Revision: 7603

Added:
   core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java
   core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java
Removed:
   core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTM.java
   core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTM.java
Modified:
   core/branches/flat/src/main/java/org/horizon/CacheDelegate.java
   core/branches/flat/src/main/java/org/horizon/ComponentStatus.java
   core/branches/flat/src/main/java/org/horizon/config/Configuration.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserImpl.java
   core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java
   core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java
   core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java
   core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java
   core/branches/flat/src/main/java/org/horizon/lifecycle/Lifecycle.java
   core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java
   core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
   core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java
   core/branches/flat/src/main/java/org/horizon/remoting/transport/Transport.java
   core/branches/flat/src/main/java/org/horizon/tree/TreeStructureSupport.java
   core/branches/flat/src/main/java/org/horizon/util/ReflectionUtil.java
   core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
   core/branches/flat/src/test/java/org/horizon/api/CacheAPITest.java
   core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/LockTestBase.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/WriteSkewTest.java
   core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java
   core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java
   core/branches/flat/src/test/java/org/horizon/profiling/TreeProfileTest.java
   core/branches/flat/src/test/java/org/horizon/replication/ExceptionTest.java
   core/branches/flat/src/test/java/org/horizon/util/internals/ViewChangeListener.java
Log:
More fixes

Modified: core/branches/flat/src/main/java/org/horizon/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/CacheDelegate.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/CacheDelegate.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -188,15 +188,15 @@
       invoker.invoke(buildCtx(), command);
    }
 
-   public Set keySet() {
+   public Set<K> keySet() {
       throw new UnsupportedOperationException("Go away");
    }
 
-   public Collection values() {
+   public Collection<V> values() {
       throw new UnsupportedOperationException("Go away");
    }
 
-   public Set entrySet() {
+   public Set<Map.Entry<K, V>> entrySet() {
       throw new UnsupportedOperationException("Go away");
    }
 

Modified: core/branches/flat/src/main/java/org/horizon/ComponentStatus.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/ComponentStatus.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/ComponentStatus.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -94,13 +94,7 @@
    }
 
    public boolean needToDestroyFailedCache() {
-      if (this == ComponentStatus.FAILED) {
-         log.debug("need to call destroy() since current state is " +
-               this);
-         return true;
-      }
-
-      return false;
+      return this == ComponentStatus.FAILED;
    }
 
    public boolean startAllowed() {
@@ -122,8 +116,6 @@
       switch (this) {
          case INSTANTIATED:
          case DESTROYED:
-            log.debug("start() called while current state is " +
-                  this + " -- call create() first");
             return true;
          default:
             return false;
@@ -176,13 +168,7 @@
    }
 
    public boolean needStopBeforeDestroy() {
-      if (this == ComponentStatus.STARTED) {
-         log.warn("destroy() called while current state is " +
-               this + " -- call stop() first");
-         return true;
-      }
-
-      return false;
+      return this == ComponentStatus.STARTED;
    }
 
    public boolean allowInvocations() {

Modified: core/branches/flat/src/main/java/org/horizon/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/Configuration.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/config/Configuration.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -133,8 +133,6 @@
    private long stateRetrievalTimeout = 10000;
    private IsolationLevel isolationLevel = IsolationLevel.READ_COMMITTED;
    @Dynamic
-   private boolean lockParentForChildInsertRemove = false;
-   @Dynamic
    private EvictionConfig evictionConfig = null;
    private String transactionManagerLookupClass = null;
    private CacheLoaderConfig cacheLoaderConfig = null;
@@ -309,17 +307,6 @@
       }
    }
 
-   /**
-    * Sets whether inserting or removing a node requires a write lock on the node's parent (when pessimistic locking is
-    * used.)
-    * <p/>
-    * The default value is <code>false</code>
-    */
-   public void setLockParentForChildInsertRemove(boolean lockParentForChildInsertRemove) {
-      testImmutability("lockParentForChildInsertRemove");
-      this.lockParentForChildInsertRemove = lockParentForChildInsertRemove;
-   }
-
    public void setUseLazyDeserialization(boolean useLazyDeserialization) {
       testImmutability("useLazyDeserialization");
       this.useLazyDeserialization = useLazyDeserialization;
@@ -383,16 +370,6 @@
       return isolationLevel;
    }
 
-   /**
-    * Gets whether inserting or removing a node requires a write lock on the node's parent (when pessimistic locking is
-    * used.)
-    * <p/>
-    * The default value is <code>false</code>
-    */
-   public boolean isLockParentForChildInsertRemove() {
-      return lockParentForChildInsertRemove;
-   }
-
    public String getTransactionManagerLookupClass() {
       return transactionManagerLookupClass;
    }
@@ -454,7 +431,6 @@
       if (fetchInMemoryState != that.fetchInMemoryState) return false;
       if (inactiveOnStartup != that.inactiveOnStartup) return false;
       if (lockAcquisitionTimeout != that.lockAcquisitionTimeout) return false;
-      if (lockParentForChildInsertRemove != that.lockParentForChildInsertRemove) return false;
       if (replQueueInterval != that.replQueueInterval) return false;
       if (replQueueMaxElements != that.replQueueMaxElements) return false;
       if (stateRetrievalTimeout != that.stateRetrievalTimeout) return false;
@@ -490,7 +466,6 @@
       result = 31 * result + (inactiveOnStartup ? 1 : 0);
       result = 31 * result + (int) (stateRetrievalTimeout ^ (stateRetrievalTimeout >>> 32));
       result = 31 * result + (isolationLevel != null ? isolationLevel.hashCode() : 0);
-      result = 31 * result + (lockParentForChildInsertRemove ? 1 : 0);
       result = 31 * result + (evictionConfig != null ? evictionConfig.hashCode() : 0);
       result = 31 * result + (transactionManagerLookupClass != null ? transactionManagerLookupClass.hashCode() : 0);
       result = 31 * result + (cacheLoaderConfig != null ? cacheLoaderConfig.hashCode() : 0);

Modified: core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserImpl.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserImpl.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -39,8 +39,8 @@
    // the root element, representing the <horizon /> tag
    Element rootElement;
 
-   // root element builder that deals with
-   private RootElementBuilder rootElementBuilder;
+   GlobalConfiguration gc;
+   Map<String, Configuration> namedCaches;
 
    /**
     * Constructs a new parser
@@ -86,40 +86,60 @@
 
    public Configuration parseDefaultConfiguration() throws ConfigurationException {
       assertInitialized();
-      Element defaultElement = getSingleElementInCoreNS("default", rootElement);
-      defaultElement.normalize();
-      return parseConfiguration(defaultElement);
+      if (gc == null) {
+         Element defaultElement = getSingleElementInCoreNS("default", rootElement);
+         // there may not be a <default /> element!
+         if (defaultElement == null) {
+            return new Configuration();
+         } else {
+            defaultElement.normalize();
+            return parseConfiguration(defaultElement);
+         }
+      } else {
+         return gc.getDefaultConfiguration();
+      }
    }
 
    public Map<String, Configuration> parseNamedConfigurations() throws ConfigurationException {
       assertInitialized();
-      Set<Element> elements = getAllElementsInCoreNS("namedCache", rootElement);
-      if (elements.isEmpty()) return Collections.emptyMap();
-      Map<String, Configuration> namedConfigurations = new HashMap<String, Configuration>(elements.size(), 1.0f);
-      for (Element e : elements) {
-         String configurationName = getAttributeValue(e, "name");
-         if (namedConfigurations.containsKey(configurationName))
-            throw new DuplicateCacheNameException("Named cache " + configurationName + " is declared more than once!");
-         namedConfigurations.put(configurationName, parseConfiguration(e));
+      // there may not be any namedCache elements!
+      if (namedCaches == null) {
+         Set<Element> elements = getAllElementsInCoreNS("namedCache", rootElement);
+         if (elements.isEmpty()) return Collections.emptyMap();
+         namedCaches = new HashMap<String, Configuration>(elements.size(), 1.0f);
+         for (Element e : elements) {
+            String configurationName = getAttributeValue(e, "name");
+            if (namedCaches.containsKey(configurationName)) {
+               namedCaches = null;
+               throw new DuplicateCacheNameException("Named cache " + configurationName + " is declared more than once!");
+            }
+            namedCaches.put(configurationName, parseConfiguration(e));
+         }
       }
 
-      return namedConfigurations;
+      return namedCaches;
    }
 
    public GlobalConfiguration parseGlobalConfiguration() {
       assertInitialized();
-      Element globalElement = getSingleElementInCoreNS("global", rootElement);
-      globalElement.normalize();
-      GlobalConfiguration gc = new GlobalConfiguration();
+      if (gc == null) {
+         Element globalElement = getSingleElementInCoreNS("global", rootElement);
+         Configuration defaultConfig = parseDefaultConfiguration();
+         gc = new GlobalConfiguration();
+         gc.setDefaultConfiguration(defaultConfig);
+         // there may not be a <global /> element in the config!!
+         if (globalElement != null) {
+            globalElement.normalize();
+            configureAsyncListenerExecutor(getSingleElementInCoreNS("asyncListenerExecutor", globalElement), gc);
+            configureAsyncSerializationExecutor(getSingleElementInCoreNS("asyncSerializationExecutor", globalElement), gc);
+            configureEvictionScheduledExecutor(getSingleElementInCoreNS("evictionScheduledExecutor", globalElement), gc);
+            configureReplicationQueueScheduledExecutor(getSingleElementInCoreNS("replicationQueueScheduledExecutor", globalElement), gc);
+            configureTransport(getSingleElementInCoreNS("transport", globalElement), gc);
+            configureShutdown(getSingleElementInCoreNS("shutdown", globalElement), gc);
+            configureSerialization(getSingleElementInCoreNS("serialization", globalElement), gc);
+         }
+      }
 
-      configureAsyncListenerExecutor(getSingleElementInCoreNS("asyncListenerExecutor", globalElement), gc);
-      configureAsyncSerializationExecutor(getSingleElementInCoreNS("asyncSerializationExecutor", globalElement), gc);
-      configureEvictionScheduledExecutor(getSingleElementInCoreNS("evictionScheduledExecutor", globalElement), gc);
-      configureReplicationQueueScheduledExecutor(getSingleElementInCoreNS("replicationQueueScheduledExecutor", globalElement), gc);
-      configureTransport(getSingleElementInCoreNS("transport", globalElement), gc);
-      configureShutdown(getSingleElementInCoreNS("shutdown", globalElement), gc);
-      configureSerialization(getSingleElementInCoreNS("serialization", globalElement), gc);
-
       return gc;
    }
 
@@ -142,41 +162,6 @@
          throw new ConfigurationException("Parser not initialized.  Please invoke initialize() first, or use a constructor that initializes the parser.");
    }
 
-   /**
-    * Parses an XML file and returns a new configuration. For looking up the file, {@link org.horizon.util.FileLookup}
-    * is used.
-    *
-    * @see org.horizon.util.FileLookup
-    */
-//   public Configuration parseFile(String filename) {
-//      InputStream is = new FileLookup().lookupFile(filename);
-//      if (is == null) {
-//         throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!");
-//      }
-//      return parseStream(is);
-//   }
-
-   /**
-    * Similar to {@link #parseFile(String)}, just that it does not create the input stream.
-    */
-//   public Configuration parseStream(InputStream configStream) {
-//      readRoot(configStream);
-//      return processElements(false);
-//   }
-//
-//   public Configuration parseElement() {
-//      rootElement.normalize();
-//      return processElements(false);
-//   }
-//
-//   public Configuration parseElementIgnoringRoot() {
-//      rootElement.normalize();
-//      return processElements(true);
-//   }
-   public boolean isValidating() {
-      return rootElementBuilder.isValidating();
-   }
-
    void configureClustering(Element e, Configuration config) {
       if (e == null) return; //we might not have this configured
       // there are 2 attribs - mode and clusterName
@@ -308,9 +293,6 @@
    void configureLocking(Element element, Configuration config) {
       String isolationLevel = getAttributeValue(element, "isolationLevel");
       if (existsAttribute(isolationLevel)) config.setIsolationLevel(IsolationLevel.valueOf(isolationLevel));
-      String lockParentForChildInsertRemove = getAttributeValue(element, "lockParentForChildInsertRemove");
-      if (existsAttribute(lockParentForChildInsertRemove))
-         config.setLockParentForChildInsertRemove(getBoolean(lockParentForChildInsertRemove));
       String lockAcquisitionTimeout = getAttributeValue(element, "lockAcquisitionTimeout");
       if (existsAttribute(lockAcquisitionTimeout)) config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
       String writeSkewCheck = getAttributeValue(element, "writeSkewCheck");
@@ -405,10 +387,6 @@
       return getSingleElementInCoreNS(elementName, rootElement);
    }
 
-   private void readRoot(InputStream config) {
-      rootElement = rootElementBuilder.readRoot(config);
-   }
-
    /**
     * Tests whether the element passed in is a modern (3.0) config element rather than a legacy one.
     *

Modified: core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -197,7 +197,7 @@
          getLog().trace("Registering component {0} under name {1}", c, name);
          componentLookup.put(name, c);
       }
-      c.nonVolatile = component.getClass().isAnnotationPresent(NonVolatile.class);
+      c.nonVolatile = ReflectionUtil.isAnnotationPresent(component.getClass(), NonVolatile.class);
       addComponentDependencies(c);
       // inject dependencies for this component
       c.injectDependencies();

Modified: core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -2,6 +2,7 @@
 
 import org.horizon.CacheException;
 import org.horizon.CacheSPI;
+import org.horizon.ComponentStatus;
 import org.horizon.config.Configuration;
 import org.horizon.config.ConfigurationException;
 import org.horizon.factories.scopes.ScopeDetector;
@@ -95,4 +96,12 @@
       Scopes componentScope = ScopeDetector.detectScope(clazz);
       return componentScope == Scopes.GLOBAL;
    }
+
+   @Override
+   public void start() {
+      if (globalComponents.getState() != ComponentStatus.STARTED || globalComponents.getState() != ComponentStatus.STARTING) {
+         globalComponents.start();
+      }
+      super.start();
+   }
 }

Modified: core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -4,6 +4,7 @@
 import org.horizon.config.GlobalConfiguration;
 import static org.horizon.config.GlobalConfiguration.ShutdownHookBehavior.DEFAULT;
 import static org.horizon.config.GlobalConfiguration.ShutdownHookBehavior.REGISTER;
+import org.horizon.factories.annotations.NonVolatile;
 import org.horizon.factories.scopes.Scope;
 import org.horizon.factories.scopes.Scopes;
 import org.horizon.logging.Log;
@@ -20,6 +21,7 @@
  * @since 1.0
  */
 @Scope(Scopes.GLOBAL)
+ at NonVolatile
 public class GlobalComponentRegistry extends AbstractComponentRegistry {
 
    private Log log = LogFactory.getLog(GlobalComponentRegistry.class);

Modified: core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -38,8 +38,8 @@
 import org.horizon.factories.context.ContextFactory;
 import org.horizon.invocation.InvocationContextContainer;
 import org.horizon.lock.LockManager;
+import org.horizon.manager.CacheManager;
 import org.horizon.notifications.CacheNotifier;
-import org.horizon.remoting.RPCManager;
 import org.horizon.remoting.ReplicationException;
 import org.horizon.transaction.GlobalTransaction;
 import org.horizon.transaction.TransactionTable;
@@ -68,11 +68,11 @@
  */
 public class TxInterceptor extends BaseTransactionalContextInterceptor {
    protected CommandsFactory commandsFactory;
-   protected RPCManager rpcManager;
    private CacheNotifier notifier;
    private InvocationContextContainer invocationContextContainer;
    private ComponentRegistry componentRegistry;
    private ContextFactory contextFactory;
+   private CacheManager cacheManager;
 
    /**
     * List <Transaction>that we have registered for
@@ -87,12 +87,12 @@
    private boolean statsEnabled;
 
    @Inject
-   public void intialize(RPCManager rpcManager, ContextFactory contextFactory,
+   public void intialize(CacheManager cacheManager, ContextFactory contextFactory,
                          CacheNotifier notifier, InvocationContextContainer icc,
                          CommandsFactory factory, ComponentRegistry componentRegistry, LockManager lockManager) {
       this.contextFactory = contextFactory;
       this.commandsFactory = factory;
-      this.rpcManager = rpcManager;
+      this.cacheManager = cacheManager;
       this.notifier = notifier;
       this.invocationContextContainer = icc;
       this.componentRegistry = componentRegistry;
@@ -129,7 +129,7 @@
          return null;
       }
       try {
-         if (trace) log.trace("(" + rpcManager.getAddress() + ") call on command [" + command + "]");
+         if (trace) log.trace("(" + cacheManager.getAddress() + ") call on command [" + command + "]");
          GlobalTransaction gtx = ctx.getGlobalTransaction();
          Transaction ltx = txTable.getLocalTransaction(gtx, true);
          // disconnect if we have a current tx associated
@@ -172,7 +172,7 @@
          return null;
       }
       try {
-         if (trace) log.trace("(" + rpcManager.getAddress() + ") call on command [" + command + "]");
+         if (trace) log.trace("(" + cacheManager.getAddress() + ") call on command [" + command + "]");
          GlobalTransaction gtx = ctx.getGlobalTransaction();
          Transaction ltx = txTable.getLocalTransaction(gtx);
          if (ltx == null) {
@@ -433,7 +433,7 @@
    // --------------------------------------------------------------
 
    protected PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, boolean onePhaseCommit) {
-      return commandsFactory.buildPrepareCommand(gtx, modifications, rpcManager.getAddress(), onePhaseCommit);
+      return commandsFactory.buildPrepareCommand(gtx, modifications, cacheManager.getAddress(), onePhaseCommit);
    }
 
    /**

Modified: core/branches/flat/src/main/java/org/horizon/lifecycle/Lifecycle.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/lifecycle/Lifecycle.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/lifecycle/Lifecycle.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -22,7 +22,7 @@
 package org.horizon.lifecycle;
 
 /**
- * // TODO: MANIK: Document this
+ * Lifecycle interface that defines the lifecycle of components
  *
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  * @since 1.0

Modified: core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -1,8 +1,10 @@
 package org.horizon.manager;
 
 import org.horizon.Cache;
+import org.horizon.ComponentStatus;
 import org.horizon.config.Configuration;
 import org.horizon.config.DuplicateCacheNameException;
+import org.horizon.factories.annotations.NonVolatile;
 import org.horizon.factories.scopes.Scope;
 import org.horizon.factories.scopes.Scopes;
 import org.horizon.lifecycle.Lifecycle;
@@ -49,6 +51,7 @@
  * @since 1.0
  */
 @Scope(Scopes.GLOBAL)
+ at NonVolatile
 public interface CacheManager extends Lifecycle, Listenable {
    /**
     * Defines a named cache.  Named caches can be defined by using this method, in which case the configuration passed
@@ -94,4 +97,8 @@
    List<Address> getMembers();
 
    Address getAddress();
+
+   ComponentStatus getStatus();
+
+   boolean isCoordinator();
 }

Modified: core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -22,7 +22,7 @@
 package org.horizon.manager;
 
 import org.horizon.Cache;
-import org.horizon.CacheSPI;
+import org.horizon.ComponentStatus;
 import org.horizon.config.Configuration;
 import org.horizon.config.ConfigurationException;
 import org.horizon.config.DuplicateCacheNameException;
@@ -31,6 +31,9 @@
 import org.horizon.config.parsing.XmlConfigurationParserImpl;
 import org.horizon.factories.DefaultCacheFactory;
 import org.horizon.factories.GlobalComponentRegistry;
+import org.horizon.factories.annotations.NonVolatile;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
 import org.horizon.lifecycle.Lifecycle;
 import org.horizon.notifications.CacheManagerNotifier;
 import org.horizon.remoting.RPCManager;
@@ -82,6 +85,8 @@
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  * @since 1.0
  */
+ at Scope(Scopes.GLOBAL)
+ at NonVolatile
 public class DefaultCacheManager implements CacheManager {
    public static final String DEFAULT_CACHE_NAME = "org.jboss.starobrno.manager.DefaultCacheManager.DEFAULT_CACHE_NAME";
    protected GlobalConfiguration globalConfiguration;
@@ -229,16 +234,18 @@
    public DefaultCacheManager(InputStream configurationStream, boolean start) throws IOException {
       try {
          initialize(new XmlConfigurationParserImpl(configurationStream));
-      }
-      catch (RuntimeException re) {
+      } catch (ConfigurationException ce) {
+         throw ce;
+      } catch (RuntimeException re) {
          throw new ConfigurationException(re);
       }
       if (start) start();
    }
 
    private void initialize(XmlConfigurationParser initializedParser) {
-      this.globalConfiguration = initializedParser.parseGlobalConfiguration();
+      globalConfiguration = initializedParser.parseGlobalConfiguration();
       configurationOverrides.putAll(initializedParser.parseNamedConfigurations());
+      globalComponentRegistry = new GlobalComponentRegistry(globalConfiguration, this);
    }
 
    /**
@@ -312,6 +319,11 @@
       return rpcManager == null ? null : rpcManager.getAddress();
    }
 
+   public boolean isCoordinator() {
+      RPCManager rpcManager = globalComponentRegistry.getComponent(RPCManager.class);
+      return rpcManager != null && rpcManager.isCoordinator();
+   }
+
    private Cache createCache(String cacheName) {
       Configuration c = globalConfiguration.getDefaultConfiguration().clone();
       if (!cacheName.equals(DEFAULT_CACHE_NAME)) {
@@ -330,9 +342,7 @@
    }
 
    public void start() {
-      // get a hold of the "default" cache to start this?
-      CacheSPI defaultCache = (CacheSPI) getCache();
-      globalComponentRegistry = defaultCache.getComponentRegistry().getGlobalComponentRegistry();
+      // nothing to do
    }
 
    public void stop() {
@@ -347,6 +357,7 @@
       }
 
       if (defaultCache != null) defaultCache.stop();
+      globalComponentRegistry.stop();
    }
 
    public void addListener(Object listener) {
@@ -363,4 +374,8 @@
       CacheManagerNotifier notifier = globalComponentRegistry.getComponent(CacheManagerNotifier.class);
       return notifier.getListeners();
    }
+
+   public ComponentStatus getStatus() {
+      return globalComponentRegistry.getState();
+   }
 }

Modified: core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -40,6 +40,7 @@
 import org.horizon.notifications.annotation.*;
 import org.horizon.notifications.event.*;
 import static org.horizon.notifications.event.Event.Type.*;
+import org.horizon.util.ReflectionUtil;
 import org.horizon.util.concurrent.WithinThreadExecutor;
 
 import javax.transaction.Transaction;
@@ -183,13 +184,12 @@
     * @return true if callbacks on this class should use the syncProcessor; false if it should use the asyncProcessor.
     */
    private static boolean testListenerClassValidity(Class<?> listenerClass) {
-      Listener cl = listenerClass.getAnnotation(Listener.class);
-      if (cl == null)
+      Listener l = ReflectionUtil.getAnnotation(listenerClass, Listener.class);
+      if (l == null)
          throw new IncorrectCacheListenerException("Cache listener class MUST be annotated with org.horizon.notifications.annotation.Listener");
       if (!Modifier.isPublic(listenerClass.getModifiers()))
          throw new IncorrectCacheListenerException("Cache listener class MUST be public!");
-      return cl.sync();
-
+      return l.sync();
    }
 
    private static void testListenerMethodValidity(Method m, Class allowedParameter, String annotationName) {

Modified: core/branches/flat/src/main/java/org/horizon/remoting/transport/Transport.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/transport/Transport.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/remoting/transport/Transport.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -2,6 +2,9 @@
 
 import org.horizon.commands.ReplicableCommand;
 import org.horizon.config.GlobalConfiguration;
+import org.horizon.factories.annotations.NonVolatile;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
 import org.horizon.lifecycle.Lifecycle;
 import org.horizon.marshall.Marshaller;
 import org.horizon.notifications.CacheManagerNotifier;
@@ -20,6 +23,8 @@
  * @author Manik Surtani
  * @since 1.0
  */
+ at Scope(Scopes.GLOBAL)
+ at NonVolatile
 public interface Transport extends Lifecycle {
 
    /**

Modified: core/branches/flat/src/main/java/org/horizon/tree/TreeStructureSupport.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/tree/TreeStructureSupport.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/tree/TreeStructureSupport.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -59,14 +59,10 @@
          if (!fqn.isRoot()) {
             if (!exists(parent)) createNodeInCache(parent);
             AtomicMap<Object, Fqn> parentStructure = getStructure(parent);
-            if (!cache.getConfiguration().isLockParentForChildInsertRemove()) {
-               cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
-            }
+            // don't lock parents for child insert/removes!
+            cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
             parentStructure.put(fqn.getLastElement(), fqn);
-//            updateStructure(parent, parentStructure);
          }
-//         FastCopyHashMap<Object, Fqn> structure = new FastCopyHashMap<Object, Fqn>();
-//         cache.put(structureKey, structure);
          cache.getAtomicMap(structureKey);
          cache.getAtomicMap(dataKey);
          return true;

Modified: core/branches/flat/src/main/java/org/horizon/util/ReflectionUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/util/ReflectionUtil.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/util/ReflectionUtil.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -182,4 +182,16 @@
       if (superclass == null) return null; // no where else to look
       return getAnnotation(superclass, ann);
    }
+
+   /**
+    * Tests whether an annotation is present on a class.  The order tested is: <ul> <li>The class itself</li> <li>All
+    * implemented interfaces</li> <li>Any superclasses</li> </ul>
+    *
+    * @param clazz      class to test
+    * @param annotation annotation to look for
+    * @return true if the annotation is found, false otherwise
+    */
+   public static boolean isAnnotationPresent(Class clazz, Class<? extends Annotation> annotation) {
+      return getAnnotation(clazz, annotation) != null;
+   }
 }

Modified: core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -18,6 +18,7 @@
 import org.horizon.interceptors.base.CommandInterceptor;
 import org.horizon.lock.LockManager;
 import org.horizon.manager.CacheManager;
+import org.horizon.remoting.transport.Address;
 import org.horizon.tree.TreeCache;
 
 import javax.transaction.TransactionManager;
@@ -131,6 +132,26 @@
    }
 
    /**
+    * Version of blockUntilViewsReceived that uses varargsa and cache managers
+    */
+   public static void blockUntilViewsReceived(long timeout, CacheManager... cacheManagers) {
+      blockUntilViewsReceived(timeout, true, cacheManagers);
+   }
+
+   public static void blockUntilViewsReceived(long timeout, boolean barfIfTooManyMembers, CacheManager... cacheManagers) {
+      long failTime = System.currentTimeMillis() + timeout;
+
+      while (System.currentTimeMillis() < failTime) {
+         sleepThread(100);
+         if (areCacheViewsComplete(barfIfTooManyMembers, cacheManagers)) {
+            return;
+         }
+      }
+
+      throw new RuntimeException("timed out before caches had complete views");
+   }
+
+   /**
     * Loops, continually calling {@link #areCacheViewsComplete(CacheSPI[])} until it either returns true or
     * <code>timeout</code> ms have elapsed.
     *
@@ -194,7 +215,7 @@
 
       while (System.currentTimeMillis() < failTime) {
          sleepThread(100);
-         if (isCacheViewComplete(cache, groupSize, barfIfTooManyMembersInView)) {
+         if (isCacheViewComplete(cache.getCacheManager().getMembers(), cache.getCacheManager().getAddress(), groupSize, barfIfTooManyMembersInView)) {
             return;
          }
       }
@@ -218,7 +239,7 @@
       int memberCount = caches.length;
 
       for (int i = 0; i < memberCount; i++) {
-         if (!isCacheViewComplete(caches[i], memberCount, barfIfTooManyMembers)) {
+         if (!isCacheViewComplete(caches[i].getCacheManager().getMembers(), caches[i].getCacheManager().getAddress(), memberCount, barfIfTooManyMembers)) {
             return false;
          }
       }
@@ -241,6 +262,19 @@
       return areCacheViewsComplete(c);
    }
 
+   public static boolean areCacheViewsComplete(boolean barfIfTooManyMembers, CacheManager... cacheManagers) {
+      if (cacheManagers == null) throw new NullPointerException("Cache Manager array is null");
+      int memberCount = cacheManagers.length;
+
+      for (int i = 0; i < memberCount; i++) {
+         if (!isCacheViewComplete(cacheManagers[i].getMembers(), cacheManagers[i].getAddress(), memberCount, barfIfTooManyMembers)) {
+            return false;
+         }
+      }
+
+      return true;
+   }
+
    /**
     * @param cache
     * @param memberCount
@@ -277,19 +311,17 @@
     * @param memberCount
     */
    public static boolean isCacheViewComplete(Cache c, int memberCount) {
-      return isCacheViewComplete(c, memberCount, true);
+      return isCacheViewComplete(c.getCacheManager().getMembers(), c.getCacheManager().getAddress(), memberCount, true);
    }
 
-   public static boolean isCacheViewComplete(Cache c, int memberCount, boolean barfIfTooManyMembers) {
-      CacheSPI cache = (CacheSPI) c;
-      List members = cache.getCacheManager().getMembers();
+   public static boolean isCacheViewComplete(List members, Address address, int memberCount, boolean barfIfTooManyMembers) {
       if (members == null || memberCount > members.size()) {
          return false;
       } else if (memberCount < members.size()) {
          if (barfIfTooManyMembers) {
             // This is an exceptional condition
             StringBuilder sb = new StringBuilder("Cache at address ");
-            sb.append(cache.getCacheManager().getAddress());
+            sb.append(address);
             sb.append(" had ");
             sb.append(members.size());
             sb.append(" members; expecting ");

Modified: core/branches/flat/src/test/java/org/horizon/api/CacheAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/CacheAPITest.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/api/CacheAPITest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -23,7 +23,7 @@
  * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
  */
 
- at Test(groups = {"functional", "pessimistic"})
+ at Test(groups = "functional", sequential = true)
 public abstract class CacheAPITest {
    private ThreadLocal<CacheSPI<String, String>> cacheTL = new ThreadLocal<CacheSPI<String, String>>();
 
@@ -71,7 +71,7 @@
 
    public void testGetMembersInLocalMode() {
       CacheSPI<String, String> cache = cacheTL.get();
-      assert cache.getRPCManager().getAddress() == null : "Cache members should be null if running in LOCAL mode";
+      assert cache.getCacheManager().getAddress() == null : "Cache members should be null if running in LOCAL mode";
    }
 
    public void testConvenienceMethods() {

Modified: core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -1,87 +1,80 @@
 package org.horizon.api;
 
-import org.horizon.CacheSPI;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.config.Configuration;
 import org.horizon.config.Configuration.CacheMode;
+import org.horizon.config.GlobalConfiguration;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
 import org.horizon.util.TestingUtil;
-import org.horizon.util.internals.ViewChangeListener;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 
- at Test(groups = {"functional", "pessimistic"})
+ at Test(groups = "functional")
 public class CacheSPITest {
-   private ThreadLocal<CacheSPI<Object, Object>> cache1TL = new ThreadLocal<CacheSPI<Object, Object>>();
-   private ThreadLocal<CacheSPI<Object, Object>> cache2TL = new ThreadLocal<CacheSPI<Object, Object>>();
+   private ThreadLocal<CacheManager> cacheManager1TL = new ThreadLocal<CacheManager>();
+   private ThreadLocal<CacheManager> cacheManager2TL = new ThreadLocal<CacheManager>();
 
    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception {
+      GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
+      Configuration conf = new Configuration();
+      conf.setCacheMode(CacheMode.REPL_SYNC);
 
-      Configuration conf1 = new Configuration();
-      conf1.setCacheMode(CacheMode.REPL_SYNC);
-
-      Configuration conf2 = conf1.clone();
-
-      CacheSPI<Object, Object> cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf1, false);
-      CacheSPI<Object, Object> cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf2, false);
-      cache1TL.set(cache1);
-      cache2TL.set(cache2);
+      cacheManager1TL.set(new DefaultCacheManager(gc, conf, false));
+      cacheManager2TL.set(new DefaultCacheManager(gc, conf, false));
    }
 
    @AfterMethod(alwaysRun = true)
    public void tearDown() throws Exception {
-      CacheSPI<Object, Object> cache1 = cache1TL.get();
-      CacheSPI<Object, Object> cache2 = cache2TL.get();
-
-      TestingUtil.killCaches(cache1, cache2);
-
-      cache1TL.set(null);
-      cache2TL.set(null);
-
+      TestingUtil.killCacheManagers(cacheManager1TL.get(), cacheManager2TL.get());
+      cacheManager1TL.set(null);
+      cacheManager2TL.set(null);
    }
 
    public void testGetMembers() throws Exception {
-      CacheSPI<Object, Object> cache1 = cache1TL.get();
-      CacheSPI<Object, Object> cache2 = cache2TL.get();
+      CacheManager cm1 = cacheManager1TL.get();
+      CacheManager cm2 = cacheManager2TL.get();
 
-      cache1.start();
-      List memb1 = cache1.getRPCManager().getMembers();
+      cm1.start();
+      cm1.getCache(); // this will make sure any lazy components are started.
+      List memb1 = cm1.getMembers();
       assert 1 == memb1.size();
 
       Object coord = memb1.get(0);
 
-      cache2.start();
-      memb1 = cache1.getRPCManager().getMembers();
-      TestingUtil.blockUntilViewsReceived(5000, false, cache1, cache2);
-      List memb2 = cache2.getRPCManager().getMembers();
+      cm2.start();
+      cm2.getCache(); // this will make sure any lazy components are started.
+      TestingUtil.blockUntilViewsReceived(50000, true, cm1, cm2);
+      memb1 = cm1.getMembers();
+      List memb2 = cm2.getMembers();
       assert 2 == memb1.size();
-      assert memb1 == memb2;
+      assert memb1.equals(memb2);
 
-      cache1.stop();
-      TestingUtil.blockUntilViewsReceived(5000, false, cache2);
-      memb2 = cache2.getRPCManager().getMembers();
+      cm1.stop();
+      TestingUtil.blockUntilViewsReceived(50000, false, cm2);
+      memb2 = cm2.getMembers();
       assert 1 == memb2.size();
       assert !coord.equals(memb2.get(0));
    }
 
    public void testIsCoordinator() throws Exception {
-      CacheSPI<Object, Object> cache1 = cache1TL.get();
-      CacheSPI<Object, Object> cache2 = cache2TL.get();
+      CacheManager cm1 = cacheManager1TL.get();
+      CacheManager cm2 = cacheManager2TL.get();
 
-      cache1.start();
-      assert cache1.getRPCManager().isCoordinator();
+      cm1.start();
+      cm1.getCache(); // this will make sure any lazy components are started.
+      assert cm1.isCoordinator();
 
-      cache2.start();
-      assert cache1.getRPCManager().isCoordinator();
-      assert !cache2.getRPCManager().isCoordinator();
-      ViewChangeListener viewChangeListener = new ViewChangeListener(cache2);
-      cache1.stop();
+      cm2.start();
+      cm2.getCache(); // this will make sure any lazy components are started.
+      assert cm1.isCoordinator();
+      assert !cm2.isCoordinator();
+      cm1.stop();
       // wait till cache2 gets the view change notification
-      assert viewChangeListener.waitForViewChange(60, TimeUnit.SECONDS) : "Should have received a view change!";
-      assert cache2.getRPCManager().isCoordinator();
+      TestingUtil.blockUntilViewsReceived(50000, false, cm2);
+      assert cm2.isCoordinator();
    }
 }
\ No newline at end of file

Deleted: core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTM.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTM.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTM.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -1,108 +0,0 @@
-package org.horizon.api.batch;
-
-import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
-import org.horizon.config.Configuration;
-import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.Test;
-
-import javax.transaction.TransactionManager;
-
-
- at Test(groups = {"functional", "transaction"})
-public class BatchWithTM extends AbstractBatchTest {
-   public void testBatchWithOngoingTM() throws Exception {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache();
-         TransactionManager tm = getTransactionManager(cache);
-         tm.begin();
-         cache.put("k", "v");
-         cache.startBatch();
-         cache.put("k2", "v2");
-         tm.commit();
-
-         assert "v".equals(cache.get("k"));
-         assert "v2".equals(cache.get("k2"));
-
-         cache.endBatch(false); // should be a no op
-         assert "v".equals(cache.get("k"));
-         assert "v2".equals(cache.get("k2"));
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
-   }
-
-   public void testBatchWithoutOngoingTMSuspension() throws Exception {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache();
-         TransactionManager tm = getTransactionManager(cache);
-         assert tm.getTransaction() == null : "Should have no ongoing txs";
-         cache.startBatch();
-         cache.put("k", "v");
-         assert tm.getTransaction() == null : "Should have no ongoing txs";
-         cache.put("k2", "v2");
-
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
-
-         try {
-            tm.commit(); // should have no effect
-         }
-         catch (Exception e) {
-            // the TM may barf here ... this is OK.
-         }
-
-         assert tm.getTransaction() == null : "Should have no ongoing txs";
-
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
-
-         cache.endBatch(true); // should be a no op
-
-         assert "v".equals(getOnDifferentThread(cache, "k"));
-         assert "v2".equals(getOnDifferentThread(cache, "k2"));
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
-   }
-
-   public void testBatchRollback() throws Exception {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache();
-         TransactionManager tm = getTransactionManager(cache);
-         cache.startBatch();
-         cache.put("k", "v");
-         cache.put("k2", "v2");
-
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
-
-         cache.endBatch(false);
-
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
-   }
-
-   private TransactionManager getTransactionManager(Cache<String, String> c) {
-      return c.getConfiguration().getRuntimeConfig().getTransactionManager();
-   }
-
-   private Cache<String, String> createCache() {
-      UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
-      Configuration c = new Configuration();
-      c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      c.setInvocationBatchingEnabled(true);
-      assert c.getTransactionManagerLookupClass() != null : "Should have a transaction manager lookup class attached!!";
-      return cf.createCache(c);
-   }
-}

Copied: core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java (from rev 7598, core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTM.java)
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -0,0 +1,108 @@
+package org.horizon.api.batch;
+
+import org.horizon.Cache;
+import org.horizon.UnitTestCacheFactory;
+import org.horizon.config.Configuration;
+import org.horizon.transaction.DummyTransactionManagerLookup;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.Test;
+
+import javax.transaction.TransactionManager;
+
+
+ at Test(groups = {"functional", "transaction"})
+public class BatchWithTMTest extends AbstractBatchTest {
+   public void testBatchWithOngoingTM() throws Exception {
+      Cache<String, String> cache = null;
+      try {
+         cache = createCache();
+         TransactionManager tm = getTransactionManager(cache);
+         tm.begin();
+         cache.put("k", "v");
+         cache.startBatch();
+         cache.put("k2", "v2");
+         tm.commit();
+
+         assert "v".equals(cache.get("k"));
+         assert "v2".equals(cache.get("k2"));
+
+         cache.endBatch(false); // should be a no op
+         assert "v".equals(cache.get("k"));
+         assert "v2".equals(cache.get("k2"));
+      }
+      finally {
+         TestingUtil.killCaches(cache);
+      }
+   }
+
+   public void testBatchWithoutOngoingTMSuspension() throws Exception {
+      Cache<String, String> cache = null;
+      try {
+         cache = createCache();
+         TransactionManager tm = getTransactionManager(cache);
+         assert tm.getTransaction() == null : "Should have no ongoing txs";
+         cache.startBatch();
+         cache.put("k", "v");
+         assert tm.getTransaction() == null : "Should have no ongoing txs";
+         cache.put("k2", "v2");
+
+         assert getOnDifferentThread(cache, "k") == null;
+         assert getOnDifferentThread(cache, "k2") == null;
+
+         try {
+            tm.commit(); // should have no effect
+         }
+         catch (Exception e) {
+            // the TM may barf here ... this is OK.
+         }
+
+         assert tm.getTransaction() == null : "Should have no ongoing txs";
+
+         assert getOnDifferentThread(cache, "k") == null;
+         assert getOnDifferentThread(cache, "k2") == null;
+
+         cache.endBatch(true); // should be a no op
+
+         assert "v".equals(getOnDifferentThread(cache, "k"));
+         assert "v2".equals(getOnDifferentThread(cache, "k2"));
+      }
+      finally {
+         TestingUtil.killCaches(cache);
+      }
+   }
+
+   public void testBatchRollback() throws Exception {
+      Cache<String, String> cache = null;
+      try {
+         cache = createCache();
+         TransactionManager tm = getTransactionManager(cache);
+         cache.startBatch();
+         cache.put("k", "v");
+         cache.put("k2", "v2");
+
+         assert getOnDifferentThread(cache, "k") == null;
+         assert getOnDifferentThread(cache, "k2") == null;
+
+         cache.endBatch(false);
+
+         assert getOnDifferentThread(cache, "k") == null;
+         assert getOnDifferentThread(cache, "k2") == null;
+      }
+      finally {
+         TestingUtil.killCaches(cache);
+      }
+   }
+
+   private TransactionManager getTransactionManager(Cache<String, String> c) {
+      return c.getConfiguration().getRuntimeConfig().getTransactionManager();
+   }
+
+   private Cache<String, String> createCache() {
+      UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
+      Configuration c = new Configuration();
+      c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+      c.setInvocationBatchingEnabled(true);
+      assert c.getTransactionManagerLookupClass() != null : "Should have a transaction manager lookup class attached!!";
+      return cf.createCache(c);
+   }
+}


Property changes on: core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTM.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTM.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTM.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -1,120 +0,0 @@
-package org.horizon.api.batch;
-
-import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
-import org.horizon.config.Configuration;
-import org.horizon.config.ConfigurationException;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.Test;
-
- at Test(groups = "functional")
-public class BatchWithoutTM extends AbstractBatchTest {
-   public void testBatchWithoutCfg() {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache(false);
-         try {
-            cache.startBatch();
-            assert false : "Should have failed";
-         }
-         catch (ConfigurationException good) {
-            // do nothing
-         }
-
-         try {
-            cache.endBatch(true);
-            assert false : "Should have failed";
-         }
-         catch (ConfigurationException good) {
-            // do nothing
-         }
-
-         try {
-            cache.endBatch(false);
-            assert false : "Should have failed";
-         }
-         catch (ConfigurationException good) {
-            // do nothing
-         }
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
-   }
-
-   public void testEndBatchWithoutStartBatch() {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache(true);
-         cache.endBatch(true);
-         cache.endBatch(false);
-         // should not fail.
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
-   }
-
-   public void testStartBatchIdempotency() {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache(true);
-         cache.startBatch();
-         cache.put("k", "v");
-         cache.startBatch();     // again
-         cache.put("k2", "v2");
-         cache.endBatch(true);
-
-         assert "v".equals(cache.get("k"));
-         assert "v2".equals(cache.get("k2"));
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
-   }
-
-   public void testBatchVisibility() throws InterruptedException {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache(true);
-         cache.startBatch();
-         cache.put("k", "v");
-         assert getOnDifferentThread(cache, "k") == null : "Other thread should not see batch update till batch completes!";
-
-         cache.endBatch(true);
-
-         assert "v".equals(getOnDifferentThread(cache, "k"));
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
-   }
-
-   public void testBatchRollback() throws Exception {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache(true);
-         cache.startBatch();
-         cache.put("k", "v");
-         cache.put("k2", "v2");
-
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
-
-         cache.endBatch(false);
-
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
-   }
-
-   private Cache<String, String> createCache(boolean enableBatch) {
-      UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
-      Configuration c = new Configuration();
-      c.setInvocationBatchingEnabled(enableBatch);
-      return cf.createCache(c);
-   }
-}

Copied: core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java (from rev 7598, core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTM.java)
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -0,0 +1,120 @@
+package org.horizon.api.batch;
+
+import org.horizon.Cache;
+import org.horizon.UnitTestCacheFactory;
+import org.horizon.config.Configuration;
+import org.horizon.config.ConfigurationException;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.Test;
+
+ at Test(groups = "functional")
+public class BatchWithoutTMTest extends AbstractBatchTest {
+   public void testBatchWithoutCfg() {
+      Cache<String, String> cache = null;
+      try {
+         cache = createCache(false);
+         try {
+            cache.startBatch();
+            assert false : "Should have failed";
+         }
+         catch (ConfigurationException good) {
+            // do nothing
+         }
+
+         try {
+            cache.endBatch(true);
+            assert false : "Should have failed";
+         }
+         catch (ConfigurationException good) {
+            // do nothing
+         }
+
+         try {
+            cache.endBatch(false);
+            assert false : "Should have failed";
+         }
+         catch (ConfigurationException good) {
+            // do nothing
+         }
+      }
+      finally {
+         TestingUtil.killCaches(cache);
+      }
+   }
+
+   public void testEndBatchWithoutStartBatch() {
+      Cache<String, String> cache = null;
+      try {
+         cache = createCache(true);
+         cache.endBatch(true);
+         cache.endBatch(false);
+         // should not fail.
+      }
+      finally {
+         TestingUtil.killCaches(cache);
+      }
+   }
+
+   public void testStartBatchIdempotency() {
+      Cache<String, String> cache = null;
+      try {
+         cache = createCache(true);
+         cache.startBatch();
+         cache.put("k", "v");
+         cache.startBatch();     // again
+         cache.put("k2", "v2");
+         cache.endBatch(true);
+
+         assert "v".equals(cache.get("k"));
+         assert "v2".equals(cache.get("k2"));
+      }
+      finally {
+         TestingUtil.killCaches(cache);
+      }
+   }
+
+   public void testBatchVisibility() throws InterruptedException {
+      Cache<String, String> cache = null;
+      try {
+         cache = createCache(true);
+         cache.startBatch();
+         cache.put("k", "v");
+         assert getOnDifferentThread(cache, "k") == null : "Other thread should not see batch update till batch completes!";
+
+         cache.endBatch(true);
+
+         assert "v".equals(getOnDifferentThread(cache, "k"));
+      }
+      finally {
+         TestingUtil.killCaches(cache);
+      }
+   }
+
+   public void testBatchRollback() throws Exception {
+      Cache<String, String> cache = null;
+      try {
+         cache = createCache(true);
+         cache.startBatch();
+         cache.put("k", "v");
+         cache.put("k2", "v2");
+
+         assert getOnDifferentThread(cache, "k") == null;
+         assert getOnDifferentThread(cache, "k2") == null;
+
+         cache.endBatch(false);
+
+         assert getOnDifferentThread(cache, "k") == null;
+         assert getOnDifferentThread(cache, "k2") == null;
+      }
+      finally {
+         TestingUtil.killCaches(cache);
+      }
+   }
+
+   private Cache<String, String> createCache(boolean enableBatch) {
+      UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
+      Configuration c = new Configuration();
+      c.setInvocationBatchingEnabled(enableBatch);
+      return cf.createCache(c);
+   }
+}


Property changes on: core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/LockTestBase.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/LockTestBase.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/LockTestBase.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -1,7 +1,6 @@
 package org.horizon.api.mvcc;
 
 import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.config.Configuration;
 import org.horizon.invocation.InvocationContextContainer;
 import org.horizon.lock.IsolationLevel;
@@ -9,6 +8,8 @@
 import org.horizon.lock.TimeoutException;
 import org.horizon.logging.Log;
 import org.horizon.logging.LogFactory;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
 import org.horizon.transaction.DummyTransactionManagerLookup;
 import org.horizon.util.TestingUtil;
 import org.testng.annotations.AfterMethod;
@@ -22,7 +23,7 @@
 /**
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  */
- at Test(groups = {"functional", "mvcc"})
+ at Test(groups = {"functional", "mvcc"}, sequential = true)
 public abstract class LockTestBase {
    protected boolean repeatableRead = true;
    protected boolean lockParentForChildInsertRemove = false;
@@ -41,13 +42,12 @@
    @BeforeMethod
    public void setUp() {
       LockTestBaseTL tl = new LockTestBaseTL();
-      tl.cache = new UnitTestCacheFactory<String, String>().createCache(new Configuration(), false);
-      tl.cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      tl.cache.getConfiguration().setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
-      tl.cache.getConfiguration().setLockParentForChildInsertRemove(lockParentForChildInsertRemove);
-      // reduce lock acquisition timeout so this doesn't take forever to run
-      tl.cache.getConfiguration().setLockAcquisitionTimeout(200); // 200 ms
-      tl.cache.start();
+      Configuration defaultCfg = new Configuration();
+      defaultCfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+      defaultCfg.setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
+      defaultCfg.setLockAcquisitionTimeout(200); // 200 ms
+      CacheManager cm = new DefaultCacheManager(defaultCfg);
+      tl.cache = cm.getCache();
       tl.lockManager = TestingUtil.extractComponentRegistry(tl.cache).getComponent(LockManager.class);
       tl.icc = TestingUtil.extractComponentRegistry(tl.cache).getComponent(InvocationContextContainer.class);
       tl.tm = TestingUtil.extractComponentRegistry(tl.cache).getComponent(TransactionManager.class);

Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/WriteSkewTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/WriteSkewTest.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/WriteSkewTest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -1,16 +1,17 @@
 package org.horizon.api.mvcc.repeatable_read;
 
 import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.api.mvcc.LockAssert;
 import org.horizon.config.Configuration;
 import org.horizon.invocation.InvocationContextContainer;
 import org.horizon.lock.IsolationLevel;
 import org.horizon.lock.LockManager;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
 import org.horizon.transaction.DummyTransactionManagerLookup;
 import org.horizon.util.TestingUtil;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
 import javax.transaction.SystemException;
@@ -22,24 +23,25 @@
 
 @Test(groups = {"functional", "mvcc"}, sequential = true)
 public class WriteSkewTest {
-   protected Cache<String, String> cache;
    protected TransactionManager tm;
    protected LockManager lockManager;
    protected InvocationContextContainer icc;
-   protected boolean repeatableRead = true;
+   protected CacheManager cacheManager;
+   protected Cache cache;
 
-   @BeforeMethod
+   @BeforeTest
    public void setUp() {
-      cache = new UnitTestCacheFactory<String, String>().createCache(new Configuration(), false);
-      cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      cache.getConfiguration().setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
-      // reduce lock acquisition timeout so this doesn't take forever to run
-      cache.getConfiguration().setLockAcquisitionTimeout(200); // 200 ms
+      Configuration c = new Configuration();
+      c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+      c.setLockAcquisitionTimeout(200);
+      c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+
+      cacheManager = new DefaultCacheManager(c);
    }
 
-   @AfterMethod
+   @AfterTest
    public void tearDown() {
-      TestingUtil.killCaches(cache);
+      TestingUtil.killCacheManagers(cacheManager);
    }
 
    private void postStart() {
@@ -53,104 +55,100 @@
    }
 
    public void testDontCheckWriteSkew() throws Exception {
-      cache.getConfiguration().setWriteSkewCheck(false);
-      cache.start();
+      Configuration noWriteSkewCheck = new Configuration();
+      noWriteSkewCheck.setWriteSkewCheck(false);
+      cacheManager.defineCache("noWriteSkewCheck", noWriteSkewCheck);
+      cache = cacheManager.getCache("noWriteSkewCheck");
       postStart();
       doTest(true);
    }
 
    public void testCheckWriteSkew() throws Exception {
-      cache.getConfiguration().setWriteSkewCheck(true);
-      cache.start();
+      Configuration writeSkewCheck = new Configuration();
+      writeSkewCheck.setWriteSkewCheck(true);
+      cacheManager.defineCache("writeSkewCheck", writeSkewCheck);
+      cache = cacheManager.getCache("writeSkewCheck");
       postStart();
       doTest(false);
    }
 
    private void doTest(final boolean allowWriteSkew) throws Exception {
-      if (repeatableRead) {
-         cache.put("k", "v");
-         final Set<Exception> w1exceptions = new HashSet<Exception>();
-         final Set<Exception> w2exceptions = new HashSet<Exception>();
-         final CountDownLatch w1Signal = new CountDownLatch(1);
-         final CountDownLatch w2Signal = new CountDownLatch(1);
-         final CountDownLatch threadSignal = new CountDownLatch(2);
+      cache.put("k", "v");
+      final Set<Exception> w1exceptions = new HashSet<Exception>();
+      final Set<Exception> w2exceptions = new HashSet<Exception>();
+      final CountDownLatch w1Signal = new CountDownLatch(1);
+      final CountDownLatch w2Signal = new CountDownLatch(1);
+      final CountDownLatch threadSignal = new CountDownLatch(2);
 
-         Thread w1 = new Thread("Writer-1") {
-            public void run() {
-               boolean didCoundDown = false;
-               try {
-                  tm.begin();
-                  assert "v".equals(cache.get("k"));
-                  threadSignal.countDown();
-                  didCoundDown = true;
-                  w1Signal.await();
-                  cache.put("k", "v2");
-                  tm.commit();
-               }
-               catch (Exception e) {
-                  w1exceptions.add(e);
-               }
-               finally {
-                  if (!didCoundDown) threadSignal.countDown();
-               }
+      Thread w1 = new Thread("Writer-1") {
+         public void run() {
+            boolean didCoundDown = false;
+            try {
+               tm.begin();
+               assert "v".equals(cache.get("k"));
+               threadSignal.countDown();
+               didCoundDown = true;
+               w1Signal.await();
+               cache.put("k", "v2");
+               tm.commit();
             }
-         };
+            catch (Exception e) {
+               w1exceptions.add(e);
+            }
+            finally {
+               if (!didCoundDown) threadSignal.countDown();
+            }
+         }
+      };
 
-         Thread w2 = new Thread("Writer-2") {
-            public void run() {
-               boolean didCoundDown = false;
-               try {
-                  tm.begin();
-                  assert "v".equals(cache.get("k"));
-                  threadSignal.countDown();
-                  didCoundDown = true;
-                  w2Signal.await();
-                  cache.put("k", "v3");
-                  tm.commit();
-               }
-               catch (Exception e) {
-                  w2exceptions.add(e);
-                  // the exception will be thrown when doing a cache.put().  We should make sure we roll back the tx to release locks.
-                  if (!allowWriteSkew) {
-                     try {
-                        tm.rollback();
-                     }
-                     catch (SystemException e1) {
-                        // do nothing.
-                     }
+      Thread w2 = new Thread("Writer-2") {
+         public void run() {
+            boolean didCoundDown = false;
+            try {
+               tm.begin();
+               assert "v".equals(cache.get("k"));
+               threadSignal.countDown();
+               didCoundDown = true;
+               w2Signal.await();
+               cache.put("k", "v3");
+               tm.commit();
+            }
+            catch (Exception e) {
+               w2exceptions.add(e);
+               // the exception will be thrown when doing a cache.put().  We should make sure we roll back the tx to release locks.
+               if (!allowWriteSkew) {
+                  try {
+                     tm.rollback();
                   }
+                  catch (SystemException e1) {
+                     // do nothing.
+                  }
                }
-               finally {
-                  if (!didCoundDown) threadSignal.countDown();
-               }
             }
-         };
+            finally {
+               if (!didCoundDown) threadSignal.countDown();
+            }
+         }
+      };
 
-         w1.start();
-         w2.start();
+      w1.start();
+      w2.start();
 
-         threadSignal.await();
-         // now.  both txs have read.
-         // let tx1 start writing
-         w1Signal.countDown();
-         w1.join();
+      threadSignal.await();
+      // now.  both txs have read.
+      // let tx1 start writing
+      w1Signal.countDown();
+      w1.join();
 
-         w2Signal.countDown();
-         w2.join();
+      w2Signal.countDown();
+      w2.join();
 
-         if (allowWriteSkew) {
-            // should have no exceptions!!
-            throwExceptions(w1exceptions, w2exceptions);
-            assert w2exceptions.size() == 0;
-            assert w1exceptions.size() == 0;
-            assert "v3".equals(cache.get("k")) : "W2 should have overwritten W1's work!";
-         } else {
-            // there should be a single exception from w2.
-            assert w2exceptions.size() == 1;
-            throwExceptions(w1exceptions);
-            assert w1exceptions.size() == 0;
-            assert "v2".equals(cache.get("k")) : "W2 should NOT have overwritten W1's work!";
-         }
+      if (allowWriteSkew) {
+         // should have no exceptions!!
+         throwExceptions(w1exceptions, w2exceptions);
+         assert w2exceptions.size() == 0;
+         assert w1exceptions.size() == 0;
+         assert "v3".equals(cache.get("k")) : "W2 should have overwritten W1's work!";
 
          assertNoLocks();
       }

Modified: core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -556,7 +556,6 @@
       Cache<Object, Object> cache = tree.getCache();
 
       assert TreeStructureSupport.isLocked(cache, C);
-      assert !cache.getConfiguration().isLockParentForChildInsertRemove() || TreeStructureSupport.isLocked(cache, A_B);
       assert TreeStructureSupport.isLocked(cache, A_B_C);
    }
 
@@ -565,7 +564,6 @@
       Cache<Object, Object> cache = tree.getCache();
 
       // /a/b, /c, /c/e, /a/b/c and /a/b/c/e should all be locked.
-      assert !cache.getConfiguration().isLockParentForChildInsertRemove() || TreeStructureSupport.isLocked(cache, A_B);
       assert TreeStructureSupport.isLocked(cache, C);
       assert TreeStructureSupport.isLocked(cache, C_E);
       assert TreeStructureSupport.isLocked(cache, A_B_C);

Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -3,9 +3,12 @@
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
 import org.horizon.config.DuplicateCacheNameException;
+import org.horizon.remoting.RPCManager;
+import org.horizon.util.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 
+import javax.transaction.TransactionManager;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
@@ -29,29 +32,29 @@
       Cache c = cm.getCache();
       assert c.getConfiguration().getConcurrencyLevel() == 100;
       assert c.getConfiguration().getLockAcquisitionTimeout() == 1000;
-      assert c.getConfiguration().getRuntimeConfig().getTransactionManager() == null;
-      assert c.getConfiguration().getRuntimeConfig().getRPCManager() == null;
+      assert TestingUtil.extractComponent(c, TransactionManager.class) == null;
+      assert TestingUtil.extractComponent(c, RPCManager.class) != null : "This should not be null, since a shared RPC manager should be present";
 
       // test the "transactional" cache
       c = cm.getCache("transactional");
       assert c.getConfiguration().getConcurrencyLevel() == 100;
       assert c.getConfiguration().getLockAcquisitionTimeout() == 1000;
-      assert c.getConfiguration().getRuntimeConfig().getTransactionManager() != null;
-      assert c.getConfiguration().getRuntimeConfig().getRPCManager() == null;
+      assert TestingUtil.extractComponent(c, TransactionManager.class) != null;
+      assert TestingUtil.extractComponent(c, RPCManager.class) != null : "This should not be null, since a shared RPC manager should be present";
 
       // test the "replicated" cache
       c = cm.getCache("syncRepl");
       assert c.getConfiguration().getConcurrencyLevel() == 100;
       assert c.getConfiguration().getLockAcquisitionTimeout() == 1000;
-      assert c.getConfiguration().getRuntimeConfig().getTransactionManager() == null;
-      assert c.getConfiguration().getRuntimeConfig().getRPCManager() != null;
+      assert TestingUtil.extractComponent(c, TransactionManager.class) == null;
+      assert TestingUtil.extractComponent(c, RPCManager.class) != null : "This should not be null, since a shared RPC manager should be present";
 
       // test the "txSyncRepl" cache
       c = cm.getCache("txSyncRepl");
       assert c.getConfiguration().getConcurrencyLevel() == 100;
       assert c.getConfiguration().getLockAcquisitionTimeout() == 1000;
-      assert c.getConfiguration().getRuntimeConfig().getTransactionManager() != null;
-      assert c.getConfiguration().getRuntimeConfig().getRPCManager() != null;
+      assert TestingUtil.extractComponent(c, TransactionManager.class) != null;
+      assert TestingUtil.extractComponent(c, RPCManager.class) != null : "This should not be null, since a shared RPC manager should be present";
    }
 
    public void testNamedCacheXMLClashingNames() throws IOException {
@@ -78,9 +81,10 @@
       try {
          cm = new DefaultCacheManager(bais);
          assert false : "Should fail";
-      }
-      catch (DuplicateCacheNameException expected) {
+      } catch (Throwable expected) {
 
+         System.out.println("Blah");
+
       }
    }
 

Modified: core/branches/flat/src/test/java/org/horizon/profiling/TreeProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/profiling/TreeProfileTest.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/profiling/TreeProfileTest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -55,7 +55,6 @@
       cfg.setCacheMode(Configuration.CacheMode.LOCAL);
       cfg.setConcurrencyLevel(2000);
       cfg.setLockAcquisitionTimeout(120000);
-      cfg.setLockParentForChildInsertRemove(true);
       cfg.setIsolationLevel(IsolationLevel.READ_COMMITTED);
       Cache c = new UnitTestCacheFactory().createCache(cfg);
       cache = new TreeCacheImpl(c);

Modified: core/branches/flat/src/test/java/org/horizon/replication/ExceptionTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/ExceptionTest.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/replication/ExceptionTest.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -68,7 +68,7 @@
       cache1.start();
       cache2.start();
 
-      TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
+      TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
 
       cache1.put("k", "v");
    }

Modified: core/branches/flat/src/test/java/org/horizon/util/internals/ViewChangeListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/util/internals/ViewChangeListener.java	2009-01-27 17:21:19 UTC (rev 7602)
+++ core/branches/flat/src/test/java/org/horizon/util/internals/ViewChangeListener.java	2009-01-27 18:01:32 UTC (rev 7603)
@@ -1,6 +1,6 @@
 package org.horizon.util.internals;
 
-import org.horizon.Cache;
+import org.horizon.manager.CacheManager;
 import org.horizon.notifications.annotation.Listener;
 import org.horizon.notifications.annotation.ViewChanged;
 import org.horizon.notifications.event.ViewChangedEvent;
@@ -31,9 +31,9 @@
     *
     * @param cache cache to listen on for view change events
     */
-   public ViewChangeListener(Cache cache) {
+   public ViewChangeListener(CacheManager cacheManager) {
       this.latch = new CountDownLatch(1);
-      cache.addListener(this);
+      cacheManager.addListener(this);
    }
 
    @ViewChanged




More information about the jbosscache-commits mailing list