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

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Feb 17 09:38:40 EST 2009


Author: mircea.markus
Date: 2009-02-17 09:38:40 -0500 (Tue, 17 Feb 2009)
New Revision: 7699

Added:
   core/branches/flat/src/main/java/org/horizon/remoting/ReplicationQueue.java
   core/branches/flat/src/test/java/org/horizon/test/
   core/branches/flat/src/test/java/org/horizon/test/AbstractCacheTest.java
   core/branches/flat/src/test/java/org/horizon/test/JGroupsConfigBuilder.java
   core/branches/flat/src/test/java/org/horizon/test/MultipleCacheManagersTest.java
   core/branches/flat/src/test/java/org/horizon/test/ReplListener.java
   core/branches/flat/src/test/java/org/horizon/test/SingleCacheManagerTest.java
   core/branches/flat/src/test/java/org/horizon/test/TestNameVerifier.java
   core/branches/flat/src/test/java/org/horizon/test/TestingUtil.java
   core/branches/flat/src/test/java/org/horizon/test/testng/
   core/branches/flat/src/test/java/org/horizon/test/testng/SuiteResourcesAndLogTest.java
   core/branches/flat/src/test/java/org/horizon/test/testng/UnitTestTestNGListener.java
   core/branches/flat/src/test/resources/stacks/
   core/branches/flat/src/test/resources/stacks/tcp.xml
   core/branches/flat/src/test/resources/stacks/udp.xml
Removed:
   core/branches/flat/src/main/java/org/horizon/cluster/
   core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
   core/branches/flat/src/test/java/org/horizon/BaseClusteredTest.java
   core/branches/flat/src/test/java/org/horizon/UnitTestCacheFactory.java
   core/branches/flat/src/test/java/org/horizon/UnitTestCacheManager.java
   core/branches/flat/src/test/java/org/horizon/util/UnitTestTestNGListener.java
   core/branches/flat/src/test/java/org/horizon/util/internals/
Modified:
   core/branches/flat/pom.xml
   core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
   core/branches/flat/src/main/java/org/horizon/factories/KnownComponentNames.java
   core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java
   core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java
   core/branches/flat/src/main/java/org/horizon/interceptors/base/BaseRpcInterceptor.java
   core/branches/flat/src/main/resources/config-samples/all.xml
   core/branches/flat/src/test/java/org/horizon/api/CacheAPITest.java
   core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
   core/branches/flat/src/test/java/org/horizon/api/MixedModeTest.java
   core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java
   core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/LockAssert.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/LockTestBase.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/read_committed/CacheAPIMVCCTest.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/read_committed/ReadCommittedLockTest.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/CacheAPIMVCCTest.java
   core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/RepeatableReadLockTest.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/NodeAPITest.java
   core/branches/flat/src/test/java/org/horizon/api/tree/NodeLockSupport.java
   core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java
   core/branches/flat/src/test/java/org/horizon/api/tree/NodeReplicatedMoveTest.java
   core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTest.java
   core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTxTest.java
   core/branches/flat/src/test/java/org/horizon/api/tree/TreeCacheAPITest.java
   core/branches/flat/src/test/java/org/horizon/api/tree/TreeStructureHashCodeTest.java
   core/branches/flat/src/test/java/org/horizon/atomic/APITest.java
   core/branches/flat/src/test/java/org/horizon/atomic/AtomicHashMapTest.java
   core/branches/flat/src/test/java/org/horizon/atomic/ClusteredAPITest.java
   core/branches/flat/src/test/java/org/horizon/config/parsing/ConfigurationParserTest.java
   core/branches/flat/src/test/java/org/horizon/config/parsing/GlobalConfigurationParserTest.java
   core/branches/flat/src/test/java/org/horizon/config/parsing/XmlFileParsingTest.java
   core/branches/flat/src/test/java/org/horizon/container/DataContainerTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/EvictionFunctionalTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/EvictionManagerTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/algorithms/fifo/FifoAlgorithmTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/algorithms/fifo/FifoQueueTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lfu/LfuAlgorithmTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lfu/LfuQueueTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lru/LruAlgorithmTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lru/LruQueueTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/algorithms/mru/MruAlgorithmTest.java
   core/branches/flat/src/test/java/org/horizon/eviction/algorithms/mru/MruQueueTest.java
   core/branches/flat/src/test/java/org/horizon/expiry/ExpiryTest.java
   core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java
   core/branches/flat/src/test/java/org/horizon/factories/scopes/ScopeDetectorTest.java
   core/branches/flat/src/test/java/org/horizon/interceptors/MarshalledValueInterceptorTest.java
   core/branches/flat/src/test/java/org/horizon/invalidation/AsyncInvalidationTest.java
   core/branches/flat/src/test/java/org/horizon/invalidation/BaseInvalidationTest.java
   core/branches/flat/src/test/java/org/horizon/invalidation/SyncInvalidationTest.java
   core/branches/flat/src/test/java/org/horizon/loader/BaseCacheLoaderTest.java
   core/branches/flat/src/test/java/org/horizon/loader/CacheLoaderFunctionalTest.java
   core/branches/flat/src/test/java/org/horizon/loader/decorators/AsyncTest.java
   core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java
   core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java
   core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheLoaderTest.java
   core/branches/flat/src/test/java/org/horizon/lock/LockContainerHashingTest.java
   core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java
   core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java
   core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java
   core/branches/flat/src/test/java/org/horizon/marshall/MarshalledValueTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/AsyncNotificationTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerPassivationTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerRemovalTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierImplTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/ListenerRegistrationTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java
   core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java
   core/branches/flat/src/test/java/org/horizon/profiling/AbstractProfileTest.java
   core/branches/flat/src/test/java/org/horizon/profiling/MemConsumptionTest.java
   core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java
   core/branches/flat/src/test/java/org/horizon/profiling/TreeProfileTest.java
   core/branches/flat/src/test/java/org/horizon/replication/AsyncReplTest.java
   core/branches/flat/src/test/java/org/horizon/replication/AsyncReplicatedAPITest.java
   core/branches/flat/src/test/java/org/horizon/replication/BaseReplicatedAPITest.java
   core/branches/flat/src/test/java/org/horizon/replication/ReplicationExceptionTest.java
   core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java
   core/branches/flat/src/test/java/org/horizon/replication/SyncReplTest.java
   core/branches/flat/src/test/java/org/horizon/replication/SyncReplicatedAPITest.java
   core/branches/flat/src/test/java/org/horizon/tx/LocalModeTxTest.java
   core/branches/flat/src/test/java/org/horizon/tx/MarkAsRollbackTest.java
   core/branches/flat/src/test/java/org/horizon/util/BidirectionalLinkedHashMapTest.java
   core/branches/flat/src/test/java/org/horizon/util/VisitableLinkedHashSetTest.java
Log:
added support for parallel test execution

Modified: core/branches/flat/pom.xml
===================================================================
--- core/branches/flat/pom.xml	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/pom.xml	2009-02-17 14:38:40 UTC (rev 7699)
@@ -148,16 +148,30 @@
             <!--<version>2.4.3-JBOSS</version>-->
             <version>2.4.3</version>
             <configuration>
-               <!--<parallel>methods</parallel>-->
-               <!--<threadCount>1</threadCount>-->
+               <parallel>tests</parallel>
+               <threadCount>10</threadCount>
                <forkMode>none</forkMode>
-               <!--<trimStackTrace>false</trimStackTrace>-->
-               <!--<properties>-->
-               <!--<property>-->
-               <!--<name>listener</name>-->
-               <!--<value>org.horizon.util.UnitTestTestNGListener</value>-->
-               <!--</property>-->
-               <!--</properties>-->
+               <systemProperties>
+                  <property>
+                     <name>jgroups.stack</name>
+                     <value>${protocol.stack}</value>
+                  </property>
+                  <property>
+                     <name>bind.address</name>
+                     <value>127.0.0.1</value>
+                  </property>
+                  <property>
+                     <name>java.net.preferIPv4Stack</name>
+                     <value>true</value>
+                  </property>                  
+               </systemProperties>
+               <trimStackTrace>false</trimStackTrace>
+               <properties>
+                  <property>
+                     <name>listener</name>
+                     <value>org.horizon.test.testng.UnitTestTestNGListener</value>
+                  </property>
+               </properties>
             </configuration>
          </plugin>
          <plugin>
@@ -410,8 +424,12 @@
 
       <profile>
          <id>test-hudson</id>
+         <activation>
+             <activeByDefault>true</activeByDefault>
+         </activation>
          <properties>
             <defaultTestGroup>functional,unit</defaultTestGroup>
+            <protocol.stack>tcp</protocol.stack>
          </properties>
       </profile>
 
@@ -419,6 +437,7 @@
          <id>test-functional</id>
          <properties>
             <defaultTestGroup>functional</defaultTestGroup>
+            <protocol.stack>tcp</protocol.stack>
          </properties>
       </profile>
 

Modified: core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -350,7 +350,7 @@
 
    /**
     * Helper method that gets you a default constructed GlobalConfiguration, preconfigured to use the default clustering
-    * stack
+    * stack.
     *
     * @return a new global configuration
     */
@@ -372,6 +372,4 @@
       gc.setTransportProperties((Properties) null);
       return gc;
    }
-
-
 }

Modified: core/branches/flat/src/main/java/org/horizon/factories/KnownComponentNames.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/KnownComponentNames.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/main/java/org/horizon/factories/KnownComponentNames.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -11,4 +11,5 @@
    public static final String ASYNC_SERIALIZATION_EXECUTOR = "org.horizon.executors.serialization";
    public static final String ASYNC_NOTIFICATION_EXECUTOR = "org.horizon.executors.notification";
    public static final String EVICTION_SCHEDULED_EXECUTOR = "org.horizon.executors.eviction";
+   public static final String ASYNC_REPLICATION_QUEUE_EXECUTOR = "org.horizon.executors.replicationQueue";
 }

Modified: core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -32,6 +32,9 @@
          } else if (componentName.equals(KnownComponentNames.EVICTION_SCHEDULED_EXECUTOR)) {
             return (T) buildAndConfigureScheduledExecutorService(globalConfiguration.getEvictionScheduledExecutorFactoryClass(),
                                                                  globalConfiguration.getEvictionScheduledExecutorProperties());
+         } else if (componentName.equals(KnownComponentNames.ASYNC_REPLICATION_QUEUE_EXECUTOR)) {
+            return (T) buildAndConfigureScheduledExecutorService(globalConfiguration.getReplicationQueueScheduledExecutorFactoryClass(),
+                                                                 globalConfiguration.getReplicationQueueScheduledExecutorProperties());
          } else {
             throw new ConfigurationException("Unknown named executor " + componentName);
          }

Modified: core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -21,12 +21,11 @@
  */
 package org.horizon.factories;
 
-import org.horizon.cluster.ReplicationQueue;
-import org.horizon.config.Configuration;
 import org.horizon.factories.annotations.DefaultFactoryFor;
+import org.horizon.remoting.ReplicationQueue;
 
 /**
- * RPCManager factory
+ * Factory for ReplicationQueue.
  *
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  * @since 1.0
@@ -35,8 +34,7 @@
 public class ReplicationQueueFactory extends EmptyConstructorNamedCacheFactory implements AutoInstantiableFactory {
    @Override
    public <T> T construct(Class<T> componentType) {
-      if ((configuration.getCacheMode() == Configuration.CacheMode.REPL_ASYNC || configuration.getCacheMode() == Configuration.CacheMode.INVALIDATION_ASYNC)
-            && configuration.isUseReplQueue()) {
+      if ((!configuration.getCacheMode().isSynchronous()) && configuration.isUseReplQueue()) {
          return super.construct(componentType);
       } else {
          return null;

Modified: core/branches/flat/src/main/java/org/horizon/interceptors/base/BaseRpcInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/base/BaseRpcInterceptor.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/base/BaseRpcInterceptor.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -21,7 +21,7 @@
  */
 package org.horizon.interceptors.base;
 
-import org.horizon.cluster.ReplicationQueue;
+import org.horizon.remoting.ReplicationQueue;
 import org.horizon.commands.CommandsFactory;
 import org.horizon.commands.RPCCommand;
 import org.horizon.commands.ReplicableCommand;

Copied: core/branches/flat/src/main/java/org/horizon/remoting/ReplicationQueue.java (from rev 7681, core/branches/flat/src/main/java/org/horizon/cluster/ReplicationQueue.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/ReplicationQueue.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/remoting/ReplicationQueue.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.horizon.remoting;
+
+import org.horizon.commands.CommandsFactory;
+import org.horizon.commands.RPCCommand;
+import org.horizon.commands.ReplicableCommand;
+import org.horizon.commands.remote.ReplicateCommand;
+import org.horizon.config.Configuration;
+import org.horizon.factories.KnownComponentNames;
+import org.horizon.factories.annotations.ComponentName;
+import org.horizon.factories.annotations.Inject;
+import org.horizon.factories.annotations.Start;
+import org.horizon.factories.annotations.Stop;
+import org.horizon.logging.Log;
+import org.horizon.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Periodically (or when certain size is exceeded) takes elements and replicates them.
+ *
+ * @author <a href="mailto:bela at jboss.org">Bela Ban</a>
+ * @author Mircea.Markus at jboss.com
+ * @since 1.0
+ */
+public class ReplicationQueue {
+   private static final Log log = LogFactory.getLog(ReplicationQueue.class);
+
+   /**
+    * Max elements before we flush
+    */
+   private long maxElements = 500;
+
+   /**
+    * Holds the replication jobs.
+    */
+   final List<RPCCommand> elements = new LinkedList<RPCCommand>();
+
+   /**
+    * For periodical replication
+    */
+   private ScheduledExecutorService scheduledExecutor = null;
+   private RPCManager rpcManager;
+   private Configuration configuration;
+   private boolean enabled;
+   private CommandsFactory commandsFactory;
+   private final AtomicInteger counter = new AtomicInteger(0);
+
+   public boolean isEnabled() {
+      return enabled;
+   }
+
+   @Inject
+   private void injectDependencies(@ComponentName(KnownComponentNames.ASYNC_REPLICATION_QUEUE_EXECUTOR) ScheduledExecutorService executor,
+                                   RPCManager rpcManager, Configuration configuration, CommandsFactory commandsFactory) {
+      this.rpcManager = rpcManager;
+      this.configuration = configuration;
+      this.commandsFactory = commandsFactory;
+      this.scheduledExecutor = executor;
+   }
+
+   /**
+    * Starts the asynchronous flush queue.
+    */
+   @Start
+   public synchronized void start() {
+      long interval = configuration.getReplQueueInterval();
+      this.maxElements = configuration.getReplQueueMaxElements();
+      // check again
+      enabled = configuration.isUseReplQueue();
+      if (enabled && interval > 0) {
+         scheduledExecutor.scheduleWithFixedDelay(new Runnable() {
+            public void run() {
+               flush();
+            }
+         }, 500l, interval, TimeUnit.MILLISECONDS);
+      }
+   }
+
+   /**
+    * Stops the asynchronous flush queue.
+    */
+   @Stop
+   public synchronized void stop() {
+      if (scheduledExecutor != null) {
+         scheduledExecutor.shutdownNow();
+      }
+      scheduledExecutor = null;
+   }
+
+
+   /**
+    * Adds a new method call.
+    */
+   public void add(RPCCommand job) {
+      if (job == null)
+         throw new NullPointerException("job is null");
+      synchronized (elements) {
+         elements.add(job);
+         if (elements.size() >= maxElements)
+            flush();
+      }
+   }
+
+   /**
+    * Flushes existing method calls.
+    */
+   public void flush() {
+      List<ReplicableCommand> toReplicate;
+      synchronized (elements) {
+         if (log.isTraceEnabled())
+            log.trace("flush(): flushing repl queue (num elements=" + elements.size() + ")");
+         toReplicate = new ArrayList<ReplicableCommand>(elements);
+         elements.clear();
+      }
+
+      if (toReplicate.size() > 0) {
+         try {
+            ReplicateCommand replicateCommand = commandsFactory.buildReplicateCommand(toReplicate);
+            // send to all live nodes in the cluster
+            rpcManager.invokeRemotely(null, replicateCommand, ResponseMode.ASYNCHRONOUS, configuration.getSyncReplTimeout());
+         }
+         catch (Throwable t) {
+            log.error("failed replicating " + toReplicate.size() + " elements in replication queue", t);
+         }
+      }
+   }
+}
\ No newline at end of file


Property changes on: core/branches/flat/src/main/java/org/horizon/remoting/ReplicationQueue.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,605 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.horizon.util;
-
-import org.horizon.AdvancedCache;
-import org.horizon.Cache;
-import org.horizon.CacheDelegate;
-import org.horizon.commands.CommandsFactory;
-import org.horizon.commands.VisitableCommand;
-import org.horizon.factories.ComponentRegistry;
-import org.horizon.factories.GlobalComponentRegistry;
-import org.horizon.interceptors.InterceptorChain;
-import org.horizon.interceptors.base.CommandInterceptor;
-import org.horizon.lifecycle.ComponentStatus;
-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;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Random;
-
-/**
- * Utilities for unit testing JBossCache.
- *
- * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
- * @since 1.0
- */
-public class TestingUtil {
-   private static Random random = new Random();
-
-   /**
-    * Extracts the value of a field in a given target instance using reflection, able to extract private fields as
-    * well.
-    *
-    * @param target    object to extract field from
-    * @param fieldName name of field to extract
-    * @return field value
-    */
-   public static Object extractField(Object target, String fieldName) {
-      return extractField(target.getClass(), target, fieldName);
-   }
-
-   public static void replaceField(Object newValue, String fieldName, Object owner, Class baseType) {
-      Field field;
-      try {
-         field = baseType.getDeclaredField(fieldName);
-         field.setAccessible(true);
-         field.set(owner, newValue);
-      }
-      catch (Exception e) {
-         throw new RuntimeException(e);//just to simplify exception handeling
-      }
-   }
-
-
-   public static Object extractField(Class type, Object target, String fieldName) {
-      Field field;
-      try {
-         field = type.getDeclaredField(fieldName);
-         field.setAccessible(true);
-         return field.get(target);
-      }
-      catch (Exception e) {
-         if (type.equals(Object.class)) {
-            e.printStackTrace();
-            return null;
-         } else {
-            // try with superclass!!
-            return extractField(type.getSuperclass(), target, fieldName);
-         }
-      }
-   }
-
-   public static <T extends CommandInterceptor> T findInterceptor(Cache<?, ?> cache, Class<T> interceptorToFind) {
-      for (CommandInterceptor i : cache.getAdvancedCache().getInterceptorChain()) {
-         if (interceptorToFind.isInstance(i)) return interceptorToFind.cast(i);
-      }
-      return null;
-   }
-
-   /**
-    * Loops, continually calling {@link #areCacheViewsComplete(Cache[])} until it either returns true or
-    * <code>timeout</code> ms have elapsed.
-    *
-    * @param caches  caches which must all have consistent views
-    * @param timeout max number of ms to loop
-    * @throws RuntimeException if <code>timeout</code> ms have elapse without all caches having the same number of
-    *                          members.
-    */
-   public static void blockUntilViewsReceived(Cache[] caches, long timeout) {
-      long failTime = System.currentTimeMillis() + timeout;
-
-      while (System.currentTimeMillis() < failTime) {
-         sleepThread(100);
-         if (areCacheViewsComplete(caches)) {
-            return;
-         }
-      }
-
-      throw new RuntimeException("timed out before caches had complete views");
-   }
-
-   /**
-    * Version of blockUntilViewsReceived that uses varargs
-    */
-   public static void blockUntilViewsReceived(long timeout, Cache... caches) {
-      blockUntilViewsReceived(caches, timeout);
-   }
-
-   /**
-    * 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.
-    *
-    * @param caches  caches which must all have consistent views
-    * @param timeout max number of ms to loop
-    * @throws RuntimeException if <code>timeout</code> ms have elapse without all caches having the same number of
-    *                          members.
-    */
-//   public static void blockUntilViewsReceived(Cache[] caches, long timeout) {
-//      long failTime = System.currentTimeMillis() + timeout;
-//
-//      while (System.currentTimeMillis() < failTime) {
-//         sleepThread(100);
-//         if (areCacheViewsComplete(caches)) {
-//            return;
-//         }
-//      }
-//
-//      throw new RuntimeException("timed out before caches had complete views");
-//   }
-
-
-   /**
-    * An overloaded version of {@link #blockUntilViewsReceived(long,Cache[])} that allows for 'shrinking' clusters.
-    * I.e., the usual method barfs if there are more members than expected.  This one takes a param
-    * (barfIfTooManyMembers) which, if false, will NOT barf but will wait until the cluster 'shrinks' to the desired
-    * size.  Useful if in tests, you kill a member and want to wait until this fact is known across the cluster.
-    *
-    * @param timeout
-    * @param barfIfTooManyMembers
-    * @param caches
-    */
-   public static void blockUntilViewsReceived(long timeout, boolean barfIfTooManyMembers, Cache... caches) {
-      long failTime = System.currentTimeMillis() + timeout;
-
-      while (System.currentTimeMillis() < failTime) {
-         sleepThread(100);
-         if (areCacheViewsComplete(caches, barfIfTooManyMembers)) {
-            return;
-         }
-      }
-
-      throw new RuntimeException("timed out before caches had complete views");
-   }
-
-   /**
-    * Loops, continually calling {@link #areCacheViewsComplete(Cache[])} until it either returns true or
-    * <code>timeout</code> ms have elapsed.
-    *
-    * @param groupSize number of caches expected in the group
-    * @param timeout   max number of ms to loop
-    * @throws RuntimeException if <code>timeout</code> ms have elapse without all caches having the same number of
-    *                          members.
-    */
-   public static void blockUntilViewReceived(Cache cache, int groupSize, long timeout) {
-      blockUntilViewReceived(cache, groupSize, timeout, true);
-   }
-
-   public static void blockUntilViewReceived(Cache cache, int groupSize, long timeout, boolean barfIfTooManyMembersInView) {
-      long failTime = System.currentTimeMillis() + timeout;
-
-      while (System.currentTimeMillis() < failTime) {
-         sleepThread(100);
-         if (isCacheViewComplete(cache.getCacheManager().getMembers(), cache.getCacheManager().getAddress(), groupSize, barfIfTooManyMembersInView)) {
-            return;
-         }
-      }
-
-      throw new RuntimeException("timed out before caches had complete views");
-   }
-
-   /**
-    * Checks each cache to see if the number of elements in the array returned by {@link CacheManager#getMembers()}
-    * matches the size of the <code>caches</code> parameter.
-    *
-    * @param caches caches that should form a View
-    * @return <code>true</code> if all caches have <code>caches.length</code> members; false otherwise
-    * @throws IllegalStateException if any of the caches have MORE view members than caches.length
-    */
-   public static boolean areCacheViewsComplete(Cache[] caches) {
-      return areCacheViewsComplete(caches, true);
-   }
-
-   public static boolean areCacheViewsComplete(Cache[] caches, boolean barfIfTooManyMembers) {
-      int memberCount = caches.length;
-
-      for (int i = 0; i < memberCount; i++) {
-         if (!isCacheViewComplete(caches[i].getCacheManager().getMembers(), caches[i].getCacheManager().getAddress(), memberCount, barfIfTooManyMembers)) {
-            return false;
-         }
-      }
-
-      return true;
-   }
-
-   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
-//    */
-//   public static boolean isCacheViewComplete(Cache cache, int memberCount) {
-//      List members = cache.getCacheManager().getMembers();
-//      if (members == null || memberCount > members.size()) {
-//         return false;
-//      } else if (memberCount < members.size()) {
-//         // This is an exceptional condition
-//         StringBuilder sb = new StringBuilder("Cache at address ");
-//         sb.append(cache.getCacheManager().getAddress());
-//         sb.append(" had ");
-//         sb.append(members.size());
-//         sb.append(" members; expecting ");
-//         sb.append(memberCount);
-//         sb.append(". Members were (");
-//         for (int j = 0; j < members.size(); j++) {
-//            if (j > 0) {
-//               sb.append(", ");
-//            }
-//            sb.append(members.get(j));
-//         }
-//         sb.append(')');
-//
-//         throw new IllegalStateException(sb.toString());
-//      }
-//
-//      return true;
-//   }
-
-   /**
-    * @param c
-    * @param memberCount
-    */
-   public static boolean isCacheViewComplete(Cache c, int memberCount) {
-      return isCacheViewComplete(c.getCacheManager().getMembers(), c.getCacheManager().getAddress(), memberCount, true);
-   }
-
-   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(address);
-            sb.append(" had ");
-            sb.append(members.size());
-            sb.append(" members; expecting ");
-            sb.append(memberCount);
-            sb.append(". Members were (");
-            for (int j = 0; j < members.size(); j++) {
-               if (j > 0) {
-                  sb.append(", ");
-               }
-               sb.append(members.get(j));
-            }
-            sb.append(')');
-
-            throw new IllegalStateException(sb.toString());
-         } else return false;
-      }
-
-      return true;
-   }
-
-
-   /**
-    * Puts the current thread to sleep for the desired number of ms, suppressing any exceptions.
-    *
-    * @param sleeptime number of ms to sleep
-    */
-   public static void sleepThread(long sleeptime) {
-      try {
-         Thread.sleep(sleeptime);
-      }
-      catch (InterruptedException ie) {
-      }
-   }
-
-   public static void sleepRandom(int maxTime) {
-      sleepThread(random.nextInt(maxTime));
-   }
-
-   public static void recursiveFileRemove(String directoryName) {
-      File file = new File(directoryName);
-      recursiveFileRemove(file);
-   }
-
-   public static void recursiveFileRemove(File file) {
-      if (file.exists()) {
-         System.out.println("Deleting file " + file);
-         recursivedelete(file);
-      }
-   }
-
-   private static void recursivedelete(File f) {
-      if (f.isDirectory()) {
-         File[] files = f.listFiles();
-         for (File file : files) {
-            recursivedelete(file);
-         }
-      }
-      //System.out.println("File " + f.toURI() + " deleted = " + f.delete());
-      f.delete();
-   }
-
-   public static void killTreeCaches(Collection treeCaches) {
-      if (treeCaches != null) killTreeCaches((TreeCache[]) treeCaches.toArray(new TreeCache[]{}));
-   }
-
-   public static void killCaches(Collection caches) {
-      if (caches != null) killCaches((Cache[]) caches.toArray(new Cache[]{}));
-   }
-
-   public static void killTreeCaches(TreeCache... treeCaches) {
-      for (TreeCache tc : treeCaches) {
-         if (tc != null) killCaches(tc.getCache());
-      }
-   }
-
-   public static void killCacheManagers(CacheManager... cacheManagers) {
-      if (cacheManagers != null) {
-         for (CacheManager cm : cacheManagers) {
-            if (cm != null) cm.stop();
-         }
-      }
-   }
-
-   /**
-    * Kills a cache - stops it, clears any data in any cache loaders, and rolls back any associated txs
-    */
-   public static void killCaches(Cache... caches) {
-      for (Cache c : caches) {
-         try {
-            if (c != null && c.getStatus() == ComponentStatus.RUNNING) {
-               TransactionManager tm = getTransactionManager(c);
-               if (tm != null) {
-                  try {
-                     tm.rollback();
-                  }
-                  catch (Exception e) {
-                     // don't care
-                  }
-               }
-               c.stop();
-            }
-         }
-         catch (Throwable t) {
-
-         }
-      }
-   }
-
-   /**
-    * Clears transaction with the current thread in the given transaction manager.
-    *
-    * @param txManager a TransactionManager to be cleared
-    */
-   public static void killTransaction(TransactionManager txManager) {
-      if (txManager != null) {
-         try {
-            txManager.rollback();
-         }
-         catch (Exception e) {
-            // don't care
-         }
-      }
-   }
-
-
-   /**
-    * Clears any associated transactions with the current thread in the caches' transaction managers.
-    */
-   public static void killTransactions(Cache... caches) {
-      for (Cache c : caches) {
-         if (c != null && c.getStatus() == ComponentStatus.RUNNING) {
-            TransactionManager tm = getTransactionManager(c);
-            if (tm != null) {
-               try {
-                  tm.rollback();
-               }
-               catch (Exception e) {
-                  // don't care
-               }
-            }
-         }
-      }
-   }
-
-   /**
-    * For testing only - introspects a cache and extracts the ComponentRegistry
-    *
-    * @param cache cache to introspect
-    * @return component registry
-    */
-   public static ComponentRegistry extractComponentRegistry(Cache cache) {
-      return (ComponentRegistry) extractField(cache, "componentRegistry");
-   }
-
-   public static GlobalComponentRegistry extractGlobalComponentRegistry(CacheManager cacheManager) {
-      return (GlobalComponentRegistry) extractField(cacheManager, "globalComponentRegistry");
-   }
-
-   public static LockManager extractLockManager(Cache cache) {
-      return extractComponentRegistry(cache).getComponent(LockManager.class);
-   }
-
-   /**
-    * For testing only - introspects a cache and extracts the ComponentRegistry
-    *
-    * @param ci interceptor chain to introspect
-    * @return component registry
-    */
-   public static ComponentRegistry extractComponentRegistry(InterceptorChain ci) {
-      return (ComponentRegistry) extractField(ci, "componentRegistry");
-   }
-
-
-   /**
-    * Replaces the existing interceptor chain in the cache wih one represented by the interceptor passed in.  This
-    * utility updates dependencies on all components that rely on the interceptor chain as well.
-    *
-    * @param cache       cache that needs to be altered
-    * @param interceptor the first interceptor in the new chain.
-    */
-   public static void replaceInterceptorChain(Cache<?, ?> cache, CommandInterceptor interceptor) {
-      ComponentRegistry cr = extractComponentRegistry(cache);
-      // make sure all interceptors here are wired.
-      CommandInterceptor i = interceptor;
-      do {
-         cr.wireDependencies(i);
-      }
-      while ((i = i.getNext()) != null);
-
-      InterceptorChain inch = cr.getComponent(InterceptorChain.class);
-      inch.setFirstInChain(interceptor);
-   }
-
-   /**
-    * Retrieves the remote delegate for a given cache.  It is on this remote delegate that the JGroups RPCDispatcher
-    * invokes remote methods.
-    *
-    * @param cache cache instance for which a remote delegate is to be retrieved
-    * @return remote delegate, or null if the cacge is not configured for replication.
-    */
-   public static CacheDelegate getInvocationDelegate(Cache cache) {
-      return (CacheDelegate) cache;
-   }
-
-   /**
-    * Blocks until the cache has reached a specified state.
-    *
-    * @param cache       cache to watch
-    * @param cacheStatus status to wait for
-    * @param timeout     timeout to wait for
-    */
-   public static void blockUntilCacheStatusAchieved(Cache cache, ComponentStatus cacheStatus, long timeout) {
-      AdvancedCache spi = cache.getAdvancedCache();
-      long killTime = System.currentTimeMillis() + timeout;
-      while (System.currentTimeMillis() < killTime) {
-         if (spi.getStatus() == cacheStatus) return;
-         sleepThread(50);
-      }
-      throw new RuntimeException("Timed out waiting for condition");
-   }
-
-   public static void replicateCommand(Cache cache, VisitableCommand command) throws Throwable {
-      ComponentRegistry cr = extractComponentRegistry(cache);
-      InterceptorChain ic = cr.getComponent(InterceptorChain.class);
-      ic.invoke(command);
-   }
-
-   public static void blockUntilViewsReceived(int timeout, List caches) {
-      blockUntilViewsReceived((Cache[]) caches.toArray(new Cache[]{}), timeout);
-   }
-
-
-   public static CommandsFactory extractCommandsFactory(Cache<Object, Object> cache) {
-      return (CommandsFactory) extractField(cache, "commandsFactory");
-   }
-
-   public static void dumpCacheContents(List caches) {
-      System.out.println("**** START: Cache Contents ****");
-      int count = 1;
-      for (Object o : caches) {
-         Cache c = (Cache) o;
-         if (c == null) {
-            System.out.println("  ** Cache " + count + " is null!");
-         } else {
-            System.out.println("  ** Cache " + count + " is " + c.getCacheManager().getAddress());
-         }
-         count++;
-      }
-      System.out.println("**** END: Cache Contents ****");
-   }
-
-   public static void dumpCacheContents(Cache... caches) {
-      dumpCacheContents(Arrays.asList(caches));
-   }
-
-   /**
-    * Extracts a component of a given type from the cache's internal component registry
-    *
-    * @param cache
-    * @param componentType
-    * @param <T>
-    * @return
-    */
-   public static <T> T extractComponent(Cache cache, Class<T> componentType) {
-      ComponentRegistry cr = extractComponentRegistry(cache);
-      return cr.getComponent(componentType);
-   }
-
-   public static TransactionManager getTransactionManager(Cache cache) {
-      return cache == null ? null : extractComponent(cache, TransactionManager.class);
-   }
-
-   /**
-    * Replaces a component in a running cache
-    *
-    * @param cache                cache in which to replace component
-    * @param componentType        component type of which to replace
-    * @param replacementComponent new instance
-    * @param rewire               if true, ComponentRegistry.rewire() is called after replacing.
-    * @return the original component that was replaced
-    */
-   public static <T> T replaceComponent(Cache<?, ?> cache, Class<T> componentType, T replacementComponent, boolean rewire) {
-      ComponentRegistry cr = extractComponentRegistry(cache);
-      T old = cr.getComponent(componentType);
-      cr.registerComponent(replacementComponent, componentType);
-      if (rewire) cr.rewire();
-      return old;
-   }
-
-   /**
-    * Replaces a component in a running cache manager (global component registry)
-    *
-    * @param cacheManager         cache in which to replace component
-    * @param componentType        component type of which to replace
-    * @param replacementComponent new instance
-    * @param rewire               if true, ComponentRegistry.rewire() is called after replacing.
-    * @return the original component that was replaced
-    */
-   public static <T> T replaceComponent(CacheManager cacheManager, Class<T> componentType, T replacementComponent, boolean rewire) {
-      GlobalComponentRegistry cr = extractGlobalComponentRegistry(cacheManager);
-      T old = cr.getComponent(componentType);
-      cr.registerComponent(replacementComponent, componentType);
-      if (rewire) {
-         cr.rewire();
-         cr.rewireNamedRegistries();
-      }
-      return old;
-   }
-}

Modified: core/branches/flat/src/main/resources/config-samples/all.xml
===================================================================
--- core/branches/flat/src/main/resources/config-samples/all.xml	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/main/resources/config-samples/all.xml	2009-02-17 14:38:40 UTC (rev 7699)
@@ -102,7 +102,7 @@
          <!--
             Uncomment this for async replication.
          -->
-         <!--<async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20" serializationExecutorQueueSize="5000000"/>-->
+         <!--<async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500"/>-->
       </clustering>
    </default>
 
@@ -163,7 +163,6 @@
 
    </namedCache>
 
-
    <namedCache name="cacheWithCustomInterceptors">
       <!--
       Define custom interceptors.  All custom interceptors need to extend org.jboss.cache.interceptors.base.CommandInterceptor

Deleted: core/branches/flat/src/test/java/org/horizon/BaseClusteredTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/BaseClusteredTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/BaseClusteredTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,217 +0,0 @@
-package org.horizon;
-
-import org.horizon.commands.DataCommand;
-import org.horizon.commands.VisitableCommand;
-import org.horizon.commands.tx.CommitCommand;
-import org.horizon.commands.tx.PrepareCommand;
-import org.horizon.config.Configuration;
-import org.horizon.config.GlobalConfiguration;
-import org.horizon.context.InvocationContext;
-import org.horizon.interceptors.base.CommandInterceptor;
-import org.horizon.manager.CacheManager;
-import org.horizon.manager.DefaultCacheManager;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.AfterMethod;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A base class that <i>all</i> tests that use clustering needs to extend.  <tt>CacheManager</tt>s should <i>only</b> be
- * created using the methods here, since this class takes care of proper cleanup of the clustering stack.
- * <p/>
- * This class also offers some cluster-specific helper methods, like {@link #assertClusterSize(String, int)} and {@link
- * #attachReplicationListener(Cache)}, the latter which allows you to attach listeners to caches and block until RPC
- * calls are received.  While this is most useful on asynchronous tests, it does not break synchronous tests either so
- * test code could be reused.
- * <p/>
- * See {@link org.horizon.BaseClusteredTest.ReplListener} for details.
- */
-public abstract class BaseClusteredTest {
-   ThreadLocal<List<CacheManager>> cacheManagerThreadLocal = new ThreadLocal<List<CacheManager>>() {
-      @Override
-      protected List<CacheManager> initialValue() {
-         return new LinkedList<CacheManager>();
-      }
-   };
-
-   /**
-    * @return a list of registered cache managers on the current thread.
-    */
-   protected List<CacheManager> getCacheManagers() {
-      return cacheManagerThreadLocal.get();
-   }
-
-   /**
-    * Creates a new cache manager, starts it, and adds it to the list of known cache managers on the current thread.
-    * Uses a default clustered cache manager global config.
-    *
-    * @return the new CacheManager
-    */
-   protected CacheManager addClusterEnabledCacheManager() {
-      return addCacheManager(GlobalConfiguration.getClusteredDefault());
-   }
-
-   /**
-    * Creates a new cache manager, starts it, and adds it to the list of known cache managers on the current thread.
-    *
-    * @param globalConfig config to use
-    * @return the new CacheManager
-    */
-   protected CacheManager addCacheManager(GlobalConfiguration globalConfig) {
-      CacheManager cm = new DefaultCacheManager(globalConfig);
-      cacheManagerThreadLocal.get().add(cm);
-      return cm;
-   }
-
-   protected void defineCacheOnAllManagers(String cacheName, Configuration c) {
-      for (CacheManager cm : cacheManagerThreadLocal.get()) {
-         cm.defineCache(cacheName, c);
-      }
-   }
-
-   protected List<Cache> createClusteredCaches(int numMembersInCluster, String cacheName, Configuration c) {
-      List<Cache> caches = new ArrayList<Cache>(numMembersInCluster);
-      for (int i = 0; i < numMembersInCluster; i++) {
-         CacheManager cm = addClusterEnabledCacheManager();
-         cm.defineCache(cacheName, c);
-         caches.add(cm.getCache(cacheName));
-      }
-      return caches;
-   }
-
-   protected void assertClusterSize(String message, int size) {
-      for (CacheManager cm : cacheManagerThreadLocal.get()) {
-         assert cm.getMembers() != null && cm.getMembers().size() == size : message;
-      }
-   }
-
-   protected ReplListener attachReplicationListener(Cache c) {
-      return new ReplListener(c);
-   }
-
-   @AfterMethod(alwaysRun = true)
-   public void cleanupThreadLocals() {
-      TestingUtil.killCacheManagers(cacheManagerThreadLocal.get().toArray(new CacheManager[cacheManagerThreadLocal.get().size()]));
-      cacheManagerThreadLocal.get().clear();
-   }
-
-   /**
-    * A listener that listens for replication events on a cache it is watching.  Typical usage: <code> ReplListener r =
-    * attachReplicationListener(cache); r.expect(RemoveCommand.class); // ... r.waitForRPC(); </code>
-    */
-   protected static class ReplListener {
-      Cache c;
-      Set<Class<? extends VisitableCommand>> expectedCommands;
-      CountDownLatch latch = new CountDownLatch(1);
-
-      public ReplListener(Cache c) {
-         this.c = c;
-         this.c.getAdvancedCache().addInterceptor(new ReplListenerInterceptor(), 0);
-      }
-
-      /**
-       * Expects any commands.  The moment a single command is detected, the {@link #waitForRPC()} command will be
-       * unblocked.
-       */
-      public void expectAny() {
-         expect();
-      }
-
-      /**
-       * Expects a specific set of commands, within transactional scope (i.e., as a payload to a PrepareCommand).  If
-       * the cache mode is synchronous, a CommitCommand is expected as well.
-       *
-       * @param commands commands to expect (not counting transaction boundary commands like PrepareCommand and
-       *                 CommitCommand)
-       */
-      public void expectWithTx(Class<? extends VisitableCommand>... commands) {
-         expect(PrepareCommand.class);
-         expect(commands);
-         //this is because for async replication we have an 1pc transaction
-         if (c.getConfiguration().getCacheMode().isSynchronous()) expect(CommitCommand.class);
-      }
-
-      /**
-       * Expects any commands, within transactional scope (i.e., as a payload to a PrepareCommand).  If the cache mode
-       * is synchronous, a CommitCommand is expected as well.
-       */
-      public void expectAnyWithTx() {
-         expect(PrepareCommand.class);
-         //this is because for async replication we have an 1pc transaction
-         if (c.getConfiguration().getCacheMode().isSynchronous()) expect(CommitCommand.class);
-      }
-
-      /**
-       * Expects a specific set of commands.  {@link #waitForRPC()} will block until all of these commands are
-       * detected.
-       *
-       * @param expectedCommands commands to expect
-       */
-      public void expect(Class<? extends VisitableCommand>... expectedCommands) {
-         if (this.expectedCommands == null) {
-            this.expectedCommands = new HashSet<Class<? extends VisitableCommand>>();
-         }
-         this.expectedCommands.addAll(Arrays.asList(expectedCommands));
-      }
-
-      /**
-       * Blocks for a predefined amount of time (120 Seconds) until commands defined in any of the expect*() methods
-       * have been detected.  If the commands have not been detected by this time, an exception is thrown.
-       */
-      public void waitForRPC() {
-         waitForRPC(120, TimeUnit.SECONDS);
-      }
-
-      /**
-       * The same as {@link #waitForRPC()} except that you are allowed to specify the max wait time.
-       */
-      public void waitForRPC(long time, TimeUnit unit) {
-         assert expectedCommands != null : "there are no replication expectations; please use ReplListener.expect() before calling this method";
-         try {
-            if (!latch.await(time, unit)) {
-               assert false : "Waiting for more than " + time + " " + unit + " and following commands did not replicate: " + expectedCommands;
-            }
-         }
-         catch (InterruptedException e) {
-            throw new IllegalStateException("unexpected", e);
-         }
-         finally {
-            expectedCommands = null;
-            latch = new CountDownLatch(1);
-         }
-      }
-
-      protected class ReplListenerInterceptor extends CommandInterceptor {
-         @Override
-         protected Object handleDefault(InvocationContext ctx, VisitableCommand cmd) throws Throwable {
-            // first pass up chain
-            Object o = invokeNextInterceptor(ctx, cmd);
-            markAsVisited(cmd);
-            return o;
-         }
-
-         @Override
-         public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand cmd) throws Throwable {
-            // first pass up chain
-            Object o = invokeNextInterceptor(ctx, cmd);
-            markAsVisited(cmd);
-            for (DataCommand mod : cmd.getModifications()) markAsVisited(mod);
-            return o;
-         }
-
-         private void markAsVisited(VisitableCommand cmd) {
-            if (expectedCommands != null) {
-               expectedCommands.remove(cmd.getClass());
-               if (expectedCommands.isEmpty()) latch.countDown();
-            }
-         }
-      }
-   }
-}

Deleted: core/branches/flat/src/test/java/org/horizon/UnitTestCacheFactory.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/UnitTestCacheFactory.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/UnitTestCacheFactory.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,332 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.horizon;
-
-import org.horizon.config.Configuration;
-import org.horizon.config.ConfigurationException;
-import org.horizon.config.parsing.XmlConfigurationParser;
-import org.horizon.config.parsing.XmlConfigurationParserImpl;
-import org.horizon.logging.Log;
-import org.horizon.logging.LogFactory;
-import org.horizon.manager.DefaultCacheManager;
-import org.horizon.util.TestingUtil;
-import org.jgroups.conf.XmlConfigurator;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:dpospisi at redhat.com">Dominik Pospisil (dpospisi at redhat.com)</a>
- */
-public class UnitTestCacheFactory<K, V>// implements CacheFactory<K, V>
-{
-
-   private final Log log = LogFactory.getLog(UnitTestCacheFactory.class);
-
-
-   /**
-    * Holds unique mcast_addr for each thread used for JGroups channel construction.
-    */
-   private static final ThreadLocal<String> threadMcastIP = new ThreadLocal<String>() {
-      private final AtomicInteger uniqueAddr = new AtomicInteger(11);
-
-      @Override
-      protected String initialValue() {
-         return "228.10.10." + uniqueAddr.getAndIncrement();
-      }
-   };
-
-   /**
-    * Holds unique mcast_port for each thread used for JGroups channel construction.
-    */
-   private static final ThreadLocal<Integer> threadMcastPort = new ThreadLocal<Integer>() {
-      private final AtomicInteger uniquePort = new AtomicInteger(45589);
-
-      @Override
-      protected Integer initialValue() {
-         return uniquePort.getAndIncrement();
-      }
-   };
-
-   /**
-    * For each thread holds list of caches created using this factory.
-    */
-   private static final ThreadLocal<List<Cache>> threadCaches =
-         new ThreadLocal<List<Cache>>() {
-            @Override
-            protected List<Cache> initialValue() {
-               return new ArrayList<Cache>();
-            }
-         };
-
-   private final static List<Cache> allCaches = new ArrayList<Cache>();
-
-   /**
-    * For each thread holds the name of the test class which executed createCache factory method.
-    */
-   private static final ThreadLocal<String> threadTestName = new ThreadLocal<String>();
-
-   // factory methods
-
-   public Cache<K, V> createCache() throws ConfigurationException {
-      return createCache(true);
-   }
-
-   public Cache<K, V> createCache(boolean start) throws ConfigurationException {
-      return createCache(new Configuration(), start);
-   }
-
-   public Cache<K, V> createCache(String configFileName) throws ConfigurationException, IOException {
-      return createCache(configFileName, true);
-   }
-
-   public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException, IOException {
-      XmlConfigurationParser parser = new XmlConfigurationParserImpl(configFileName);
-      Configuration c;
-
-      // TODO: gotta build a proper cache manager here
-      return null;
-
-      //return createCache(c, start);
-   }
-
-   public Cache<K, V> createCache(Configuration configuration) throws ConfigurationException {
-      return createCache(configuration, true);
-   }
-
-   public Cache<K, V> createCache(InputStream is) throws ConfigurationException, IOException {
-      return createCache(is, true);
-   }
-
-   public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException, IOException {
-      XmlConfigurationParser parser = new XmlConfigurationParserImpl(is);
-      //Configuration c = parser.parseStream(is);
-      //return createCache(c, start);
-      // TODO: gotta build a proper cache manager here
-      return null;
-   }
-
-   public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException {
-      // - Do not print out this exception - since tests are ALSO run from IDEs on the main thread. - MANIK
-//      if (!Thread.currentThread().getName().contains("pool"))
-//      {
-//         System.out.println("CreateCache called from wrong thread: " + Thread.currentThread().getName());
-//      }
-
-      checkCaches();
-
-      switch (configuration.getCacheMode()) {
-         case LOCAL:
-            // local cache, no channel used
-            break;
-         case REPL_SYNC:
-         case REPL_ASYNC:
-         case INVALIDATION_ASYNC:
-         case INVALIDATION_SYNC:
-            // replicated cache, update channel setup
-            mangleConfiguration(configuration);
-            break;
-         default:
-            log.info("Unknown cache mode!");
-      }
-
-//      Cache<K, V> cache = new DefaultCacheFactory<K, V>().createCache(configuration, start);
-      DefaultCacheManager cm = new DefaultCacheManager(configuration);
-      Cache<K, V> cache = cm.getCache();
-
-      List<Cache> caches = threadCaches.get();
-      caches.add(cache);
-
-      synchronized (allCaches) {
-         allCaches.add(cache);
-      }
-      return cache;
-
-   }
-
-   /**
-    * Destroys all caches created by this factory in the current thread.
-    *
-    * @return true if some cleanup was actually performed
-    */
-   public boolean cleanUp() {
-      List<Cache> caches = new ArrayList<Cache>(threadCaches.get());
-      boolean ret = false;
-
-      for (Cache cache : caches) {
-         TestingUtil.killCaches(cache);
-         ret = true;
-      }
-      return ret;
-   }
-
-   public void removeCache(Cache c) {
-
-      // - Do not print out this exception - since tests are ALSO run from IDEs on the main thread. - MANIK
-//      if (!Thread.currentThread().getName().contains("pool"))
-//      {
-//         System.out.println("RemoveCache called from wrong thread.");
-//      }
-
-      List<Cache> caches = threadCaches.get();
-      synchronized (allCaches) {
-         if (caches.contains(c)) {
-            caches.remove(c);
-            allCaches.remove(c);
-         } else if (allCaches.contains(c)) {
-            System.out.println("[" + Thread.currentThread().getName() + "] WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Remove cache called from different thread.");
-            Thread.dumpStack();
-         }
-      }
-   }
-
-   /**
-    * Updates cluster configuration to ensure mutual thread isolation.
-    *
-    * @param configuration Configuration to update.
-    */
-   public void mangleConfiguration(Configuration configuration) {
-      // TODO fix this to use the cache manager
-
-//      configuration.setClusterConfig(mangleClusterConfiguration(configuration.getClusterConfig()));
-      // Check if the cluster name contains thread id. If not, append. 
-      // We can not just append the threadId, since some of the tests are crating instances
-      // using configurations derived from configurations returned by this factory.
-
-//      String clusterName = configuration.getClusterName();
-
-      // append thread id
-//      if (clusterName.indexOf(Thread.currentThread().getName()) == -1) {
-//         clusterName = clusterName + "-" + Thread.currentThread().getName();
-////       System.out.println(getThreadId() + " Setting cluster name " + newClusterName);
-//      }
-
-//      String testName = extractTestName();
-
-      // prepend test name
-      /*
-      if (clusterName.indexOf(testName) == -1) {
-         clusterName = testName + "-" + clusterName;
-      }
-      */
-
-//      configuration.setClusterName(clusterName);
-
-   }
-
-   /**
-    * Updates cluster configuration to ensure mutual thread isolation.
-    */
-   public String mangleClusterConfiguration(String clusterConfig) {
-      if (clusterConfig == null) {
-         // No explicit cluster configuration found. we need to resolve the default config
-         // now in orded to be able to update it before the cache (and the channel) starts.         
-
-         clusterConfig = getDefaultClusterConfiguration();
-      }
-
-      // replace mcast_addr
-      Pattern pattern = Pattern.compile("mcast_addr=[^;]*");
-      Matcher m = pattern.matcher(clusterConfig);
-      if (m.find()) {
-         String origAddr = m.group().substring(m.group().indexOf("=") + 1);
-         String newAddr = threadMcastIP.get();
-//         System.out.println(getThreadId() + " Replacing mcast_addr " + origAddr + " with " + newAddr);
-         clusterConfig = m.replaceFirst("mcast_addr=" + newAddr);
-      } else {
-         Thread.dumpStack();
-         System.exit(1);
-      }
-
-      // replace mcast_port
-      pattern = Pattern.compile("mcast_port=[^;]*");
-      m = pattern.matcher(clusterConfig);
-      if (m.find()) {
-//         String origPort = m.group().substring(m.group().indexOf("=") + 1);
-         String newPort = threadMcastPort.get().toString();
-         //       System.out.println(getThreadId() + " Replacing mcast_port " + origPort + " with " + newPort);
-         clusterConfig = m.replaceFirst("mcast_port=" + newPort);
-      }
-
-      return clusterConfig;
-   }
-
-//   private String getThreadId()
-//   {
-//      return "[" + Thread.currentThread().getName() + "]";
-//   }
-
-   private void checkCaches() {
-      String lastTestName = threadTestName.get();
-      String currentTestName = extractTestName();
-
-      if ((lastTestName != null) && (!lastTestName.equals(currentTestName))) {
-
-         String threadId = "[" + Thread.currentThread().getName() + "] ";
-
-         // we are running new test class
-         // check if there is a cache(s) instance left & kill it if possitive
-
-         if (cleanUp()) {
-            System.out.print(threadId + "WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ");
-            System.out.print(threadId + " A test method in " + lastTestName + " did not clean all cache instances properly. ");
-            System.out.println(threadId + " Use UnitTestCacheFactory.cleanUp() or TestngUtil.killCaches(...) ");
-         }
-
-      }
-      threadTestName.set(currentTestName);
-   }
-
-   private String extractTestName() {
-      StackTraceElement[] stack = Thread.currentThread().getStackTrace();
-      if (stack.length == 0) return null;
-      for (int i = stack.length - 1; i > 0; i--) {
-         StackTraceElement e = stack[i];
-         String className = e.getClassName();
-         if (className.indexOf("org.horizon") != -1) return className; //+ "." + e.getMethodName();
-      }
-      return null;
-   }
-
-   private String getDefaultClusterConfiguration() {
-      // TODO: fix this to use the cache manager
-//      return getClusterConfigFromFile(new Configuration().getDefaultClusterConfig());
-      return null;
-   }
-
-   /**
-    * Helper method that takes a <b>JGroups</b> configuration file and creates an old-style JGroups config {@link
-    * String} that can be used in {@link Configuration#setClusterConfig(String)}.  Note that expressions in the file -
-    * such as <tt>${jgroups.udp.mcast_port:45588}</tt> are expanded out accordingly.
-    *
-    * @param url url to the cfg file
-    * @return a String
-    */
-   public static String getClusterConfigFromFile(URL url) {
-      try {
-         XmlConfigurator conf = XmlConfigurator.getInstance(url);
-         String tmp = conf.getProtocolStackString();
-         // parse this string for ${} substitutions
-         // Highly crappy approach!!
-         tmp = tmp.replace("${jgroups.udp.mcast_addr:228.10.10.10}", "228.10.10.10");
-         tmp = tmp.replace("${jgroups.udp.mcast_port:45588}", "45588");
-         tmp = tmp.replace("${jgroups.udp.ip_ttl:2}", "2");
-//         System.out.println("config string: " + tmp);
-         return tmp;
-      }
-      catch (Exception e) {
-         throw new RuntimeException("Problems with url " + url, e);
-      }
-   }
-
-}

Deleted: core/branches/flat/src/test/java/org/horizon/UnitTestCacheManager.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/UnitTestCacheManager.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/UnitTestCacheManager.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,30 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.horizon;
-
-import org.horizon.config.Configuration;
-
-/**
- * Always use this cache manager when writing unit tests.  This allows for parallel tests to run.
- *
- * @author dpospisi
- */
-public class UnitTestCacheManager {
-   Configuration c;
-
-   public UnitTestCacheManager(Configuration c) {
-      this.c = c.clone();
-   }
-
-   protected Cache createNewCache() {
-      UnitTestCacheFactory dcf = new UnitTestCacheFactory();
-      return dcf.createCache(c);
-   }
-
-   public Cache createCache(String name) {
-      return createNewCache();
-   }
-}

Modified: core/branches/flat/src/test/java/org/horizon/api/CacheAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/CacheAPITest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/CacheAPITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,17 +1,16 @@
 package org.horizon.api;
 
 import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.config.Configuration;
 import org.horizon.config.ConfigurationException;
 import org.horizon.lock.IsolationLevel;
+import org.horizon.manager.CacheManager;
+import org.horizon.test.SingleCacheManagerTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManager;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertNull;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.HashMap;
@@ -22,36 +21,27 @@
  *
  * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
  */
+ at Test(groups = "functional")
+public abstract class CacheAPITest extends SingleCacheManagerTest {
+   Cache cache;
 
- at Test(groups = "functional", sequential = true)
-public abstract class CacheAPITest {
-   private ThreadLocal<Cache<String, String>> cacheTL = new ThreadLocal<Cache<String, String>>();
-
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() throws Exception {
+   protected CacheManager createCacheManager() throws Exception {
       // start a single cache instance
       Configuration c = new Configuration();
       c.setIsolationLevel(getIsolationLevel());
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
-      Cache<String, String> cache = cf.createCache(c.clone());
-      cacheTL.set(cache);
+      CacheManager cm = TestingUtil.createLocalCacheManager();
+      cm.defineCache("test", c);
+      cache = cm.getCache("test");
+      return cm;
    }
 
    protected abstract IsolationLevel getIsolationLevel();
 
-   @AfterMethod(alwaysRun = true)
-   public void tearDown() {
-      Cache<String, String> cache = cacheTL.get();
-      TestingUtil.killCaches(cache);
-      cacheTL.set(null);
-   }
-
    /**
     * Tests that the configuration contains the values expected, as well as immutability of certain elements
     */
    public void testConfiguration() {
-      Cache<String, String> cache = cacheTL.get();
       Configuration c = cache.getConfiguration();
       assertEquals(Configuration.CacheMode.LOCAL, c.getCacheMode());
       assertEquals(DummyTransactionManagerLookup.class.getName(), c.getTransactionManagerLookupClass());
@@ -70,12 +60,10 @@
    }
 
    public void testGetMembersInLocalMode() {
-      Cache<String, String> cache = cacheTL.get();
       assert cache.getCacheManager().getAddress() == null : "Cache members should be null if running in LOCAL mode";
    }
 
    public void testConvenienceMethods() {
-      Cache<String, String> cache = cacheTL.get();
       String key = "key", value = "value";
       Map<String, String> data = new HashMap<String, String>();
       data.put(key, value);
@@ -99,7 +87,6 @@
     * Tests basic eviction
     */
    public void testEvict() {
-      Cache<String, String> cache = cacheTL.get();
       String key1 = "keyOne", key2 = "keyTwo", value = "value";
 
       cache.put(key1, value);
@@ -124,7 +111,6 @@
    }
 
    public void testStopClearsData() throws Exception {
-      Cache<String, String> cache = cacheTL.get();
       String key = "key", value = "value";
       cache.put(key, value);
       assert cache.get(key).equals(value);
@@ -138,7 +124,6 @@
    }
 
    public void testRollbackAfterPut() throws Exception {
-      Cache<String, String> cache = cacheTL.get();
       String key = "key", value = "value";
       cache.put(key, value);
       assert cache.get(key).equals(value);
@@ -154,7 +139,6 @@
    }
 
    public void testRollbackAfterOverwrite() throws Exception {
-      Cache<String, String> cache = cacheTL.get();
       String key = "key", value = "value";
       cache.put(key, value);
       assert cache.get(key).equals(value);
@@ -171,7 +155,6 @@
    }
 
    public void testRollbackAfterRemove() throws Exception {
-      Cache<String, String> cache = cacheTL.get();
       String key = "key", value = "value";
       cache.put(key, value);
       assert cache.get(key).equals(value);
@@ -187,7 +170,6 @@
    }
 
    public void testRollbackAfterClear() throws Exception {
-      Cache<String, String> cache = cacheTL.get();
       String key = "key", value = "value";
       cache.put(key, value);
       assert cache.get(key).equals(value);
@@ -203,31 +185,29 @@
    }
 
    public void testConcurrentMapMethods() {
-      Cache<String, String> c = cacheTL.get();
 
-      assert c.putIfAbsent("A", "B") == null;
-      assert c.putIfAbsent("A", "C").equals("B");
-      assert c.get("A").equals("B");
+      assert ((Cache<String, String>) cache).putIfAbsent("A", "B") == null;
+      assert ((Cache<String, String>) cache).putIfAbsent("A", "C").equals("B");
+      assert ((Cache<String, String>) cache).get("A").equals("B");
 
-      assert !c.remove("A", "C");
-      assert c.containsKey("A");
-      assert c.remove("A", "B");
-      assert !c.containsKey("A");
+      assert !((Cache<String, String>) cache).remove("A", "C");
+      assert ((Cache<String, String>) cache).containsKey("A");
+      assert ((Cache<String, String>) cache).remove("A", "B");
+      assert !((Cache<String, String>) cache).containsKey("A");
 
-      c.put("A", "B");
+      ((Cache<String, String>) cache).put("A", "B");
 
-      assert !c.replace("A", "D", "C");
-      assert c.get("A").equals("B");
-      assert c.replace("A", "B", "C");
-      assert c.get("A").equals("C");
+      assert !((Cache<String, String>) cache).replace("A", "D", "C");
+      assert ((Cache<String, String>) cache).get("A").equals("B");
+      assert ((Cache<String, String>) cache).replace("A", "B", "C");
+      assert ((Cache<String, String>) cache).get("A").equals("C");
 
-      assert c.replace("A", "X").equals("C");
-      assert c.replace("X", "A") == null;
-      assert !c.containsKey("X");
+      assert ((Cache<String, String>) cache).replace("A", "X").equals("C");
+      assert ((Cache<String, String>) cache).replace("X", "A") == null;
+      assert !((Cache<String, String>) cache).containsKey("X");
    }
 
    public void testSizeAndContents() throws Exception {
-      Cache cache = cacheTL.get();
       String key = "key", value = "value";
 
       assert cache.isEmpty();

Modified: core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,30 +1,36 @@
 package org.horizon.api;
 
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
 import org.horizon.config.Configuration.CacheMode;
 import org.horizon.manager.CacheManager;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.List;
 
- at Test(groups = "functional", sequential = true)
-public class CacheClusterJoinTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "api.CacheClusterJoinTest")
+public class CacheClusterJoinTest {
    Cache cache1, cache2;
    CacheManager cm1, cm2;
    Configuration cfg;
 
    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception {
-      cm1 = addClusterEnabledCacheManager();
+      cm1 = TestingUtil.createClusteredCacheManager();
       cfg = new Configuration();
       cfg.setCacheMode(CacheMode.REPL_SYNC);
       cm1.defineCache("cache", cfg);
    }
 
+   @AfterMethod
+   public void tearDown()
+   {
+      TestingUtil.killCacheManagers(cm1, cm2);
+   }
+
    public void testGetMembers() throws Exception {
       cm1.getCache("cache"); // this will make sure any lazy components are started.
       List memb1 = cm1.getMembers();
@@ -32,7 +38,7 @@
 
       Object coord = memb1.get(0);
 
-      cm2 = addClusterEnabledCacheManager();
+      cm2 = TestingUtil.createClusteredCacheManager();
       cm2.defineCache("cache", cfg);
       cm2.getCache("cache"); // this will make sure any lazy components are started.
       TestingUtil.blockUntilViewsReceived(50000, true, cm1, cm2);
@@ -52,7 +58,7 @@
       cm1.getCache("cache"); // this will make sure any lazy components are started.
       assert cm1.isCoordinator();
 
-      cm2 = addClusterEnabledCacheManager();
+      cm2 = TestingUtil.createClusteredCacheManager();
       cm2.defineCache("cache", cfg);
       cm2.getCache("cache"); // this will make sure any lazy components are started.
       assert cm1.isCoordinator();

Modified: core/branches/flat/src/test/java/org/horizon/api/MixedModeTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/MixedModeTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/MixedModeTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,27 +1,20 @@
 package org.horizon.api;
 
 import org.horizon.AdvancedCache;
-import org.horizon.BaseClusteredTest;
 import org.horizon.config.Configuration;
 import org.horizon.invocation.Options;
-import org.horizon.manager.CacheManager;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.BeforeMethod;
+import org.horizon.test.MultipleCacheManagersTest;
 import org.testng.annotations.Test;
 
- at Test(groups = "functional", sequential = true)
-public class MixedModeTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "api.MixedModeTest")
+public class MixedModeTest extends MultipleCacheManagersTest {
    AdvancedCache replSyncCache1, replSyncCache2;
    AdvancedCache replAsyncCache1, replAsyncCache2;
    AdvancedCache invalAsyncCache1, invalAsyncCache2;
    AdvancedCache invalSyncCache1, invalSyncCache2;
    AdvancedCache localCache1, localCache2;
 
-   @BeforeMethod
-   public void setUp() {
-      CacheManager cm1 = addClusterEnabledCacheManager();
-      CacheManager cm2 = addClusterEnabledCacheManager();
-
+   protected void createCaches() throws Throwable {
       Configuration replSync = new Configuration();
       replSync.setCacheMode(Configuration.CacheMode.REPL_SYNC);
 
@@ -37,29 +30,26 @@
       Configuration local = new Configuration();
       local.setCacheMode(Configuration.CacheMode.LOCAL);
 
-      defineCacheOnAllManagers("replSync", replSync);
+      createClusteredCaches(2, "replSync", replSync);
       defineCacheOnAllManagers("replAsync", replAsync);
       defineCacheOnAllManagers("invalSync", invalSync);
       defineCacheOnAllManagers("invalAsync", invalAsync);
       defineCacheOnAllManagers("local", local);
 
-      replSyncCache1 = cm1.getCache("replSync").getAdvancedCache();
-      replSyncCache2 = cm2.getCache("replSync").getAdvancedCache();
-      replAsyncCache1 = cm1.getCache("replAsync").getAdvancedCache();
-      replAsyncCache2 = cm2.getCache("replAsync").getAdvancedCache();
-      invalSyncCache1 = cm1.getCache("invalSync").getAdvancedCache();
-      invalSyncCache2 = cm2.getCache("invalSync").getAdvancedCache();
-      invalAsyncCache1 = cm1.getCache("invalAsync").getAdvancedCache();
-      invalAsyncCache2 = cm2.getCache("invalAsync").getAdvancedCache();
-      localCache1 = cm1.getCache("local").getAdvancedCache();
-      localCache2 = cm2.getCache("local").getAdvancedCache();
-
-      TestingUtil.blockUntilViewsReceived(60000, cm1, cm2);
+      replSyncCache1 = cache(0, "replSync").getAdvancedCache();
+      replSyncCache2 = cache(1, "replSync").getAdvancedCache();
+      replAsyncCache1 = cache(0, "replAsync").getAdvancedCache();
+      replAsyncCache2 = cache(1, "replAsync").getAdvancedCache();
+      invalSyncCache1 = cache(0, "invalSync").getAdvancedCache();
+      invalSyncCache2 = cache(1, "invalSync").getAdvancedCache();
+      invalAsyncCache1 = cache(0, "invalAsync").getAdvancedCache();
+      invalAsyncCache2 = cache(1, "invalAsync").getAdvancedCache();
+      localCache1 = cache(0, "local").getAdvancedCache();
+      localCache2 = cache(1, "local").getAdvancedCache();
    }
 
+
    public void testMixedMode() {
-      ReplListener r1 = attachReplicationListener(replAsyncCache2);
-      ReplListener r2 = attachReplicationListener(invalAsyncCache2);
 
       invalSyncCache2.put("k", "v", Options.CACHE_MODE_LOCAL);
       assert invalSyncCache2.get("k").equals("v");
@@ -68,8 +58,8 @@
       assert invalAsyncCache2.get("k").equals("v");
       assert invalAsyncCache1.get("k") == null;
 
-      r1.expectAny();
-      r2.expectAny();
+      replListener(replAsyncCache2).expectAny();
+      replListener(invalAsyncCache2).expectAny();
 
       replSyncCache1.put("k", "replSync");
       replAsyncCache1.put("k", "replAsync");
@@ -77,8 +67,8 @@
       invalAsyncCache1.put("k", "invalAsync");
       localCache1.put("k", "local");
 
-      r1.waitForRPC();
-      r2.waitForRPC();
+      replListener(replAsyncCache2).waitForRPC();
+      replListener(invalAsyncCache2).waitForRPC();
 
       assert replSyncCache1.get("k").equals("replSync");
       assert replSyncCache2.get("k").equals("replSync");

Modified: core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithTMTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,103 +1,101 @@
 package org.horizon.api.batch;
 
 import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.config.Configuration;
+import org.horizon.manager.CacheManager;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import javax.transaction.TransactionManager;
 
 
- at Test(groups = {"functional", "transaction"})
+ at Test(groups = {"functional", "transaction"}, testName = "api.batch.BatchWithTMTest")
 public class BatchWithTMTest extends AbstractBatchTest {
+
+   CacheManager cm;
+
+   @BeforeClass
+   public void createCacheManager() {
+      cm = TestingUtil.createLocalCacheManager();
+   }
+
+   @AfterClass
+   public void destroyCacheManager() {
+      TestingUtil.killCacheManagers(cm);
+   }
+
    public void testBatchWithOngoingTM() throws Exception {
       Cache<String, String> cache = null;
-      try {
-         cache = createCache();
-         TransactionManager tm = TestingUtil.getTransactionManager(cache);
-         tm.begin();
-         cache.put("k", "v");
-         cache.startBatch();
-         cache.put("k2", "v2");
-         tm.commit();
+      cache = createCache("testBatchWithOngoingTM");
+      TransactionManager tm = TestingUtil.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"));
+      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);
-      }
+      cache.endBatch(false); // should be a no op
+      assert "v".equals(cache.get("k"));
+      assert "v2".equals(cache.get("k2"));
    }
 
    public void testBatchWithoutOngoingTMSuspension() throws Exception {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache();
-         TransactionManager tm = TestingUtil.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");
+      Cache cache = createCache("testBatchWithoutOngoingTMSuspension");
+      TransactionManager tm = TestingUtil.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;
+      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.
-         }
+      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 tm.getTransaction() == null : "Should have no ongoing txs";
 
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
+      assert getOnDifferentThread(cache, "k") == null;
+      assert getOnDifferentThread(cache, "k2") == null;
 
-         cache.endBatch(true); // should be a no op
+      cache.endBatch(true); // should be a no op
 
-         assert "v".equals(getOnDifferentThread(cache, "k"));
-         assert "v2".equals(getOnDifferentThread(cache, "k2"));
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
+      assert "v".equals(getOnDifferentThread(cache, "k"));
+      assert "v2".equals(getOnDifferentThread(cache, "k2"));
    }
 
    public void testBatchRollback() throws Exception {
-      Cache<String, String> cache = null;
-      try {
-         cache = createCache();
-         cache.startBatch();
-         cache.put("k", "v");
-         cache.put("k2", "v2");
+      Cache cache = createCache("testBatchRollback");
+      cache.startBatch();
+      cache.put("k", "v");
+      cache.put("k2", "v2");
 
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
+      assert getOnDifferentThread(cache, "k") == null;
+      assert getOnDifferentThread(cache, "k2") == null;
 
-         cache.endBatch(false);
+      cache.endBatch(false);
 
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
+      assert getOnDifferentThread(cache, "k") == null;
+      assert getOnDifferentThread(cache, "k2") == null;
    }
 
-   private Cache<String, String> createCache() {
-      UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
+   private Cache<String, String> createCache(String name) {
       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);
+      cm.defineCache(name, c);
+      return cm.getCache(name);
    }
 }

Modified: core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/batch/BatchWithoutTMTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,120 +1,110 @@
 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.horizon.manager.CacheManager;
+import org.horizon.test.TestingUtil;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
- at Test(groups = "functional")
+ at Test(groups = "functional", testName = "api.batch.BatchWithoutTMTest")
 public class BatchWithoutTMTest extends AbstractBatchTest {
+
+   CacheManager cm;
+
+   @BeforeClass
+   public void createCacheManager() {
+      cm = TestingUtil.createLocalCacheManager();
+   }
+
+   @AfterClass
+   public void destroyCacheManager() {
+      TestingUtil.killCacheManagers(cm);
+   }
+
    public void testBatchWithoutCfg() {
       Cache<String, String> cache = null;
+      cache = createCache(false, "testBatchWithoutCfg");
       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
-         }
+         cache.startBatch();
+         assert false : "Should have failed";
       }
-      finally {
-         TestingUtil.killCaches(cache);
+      catch (ConfigurationException good) {
+         // do nothing
       }
-   }
 
-   public void testEndBatchWithoutStartBatch() {
-      Cache<String, String> cache = null;
       try {
-         cache = createCache(true);
          cache.endBatch(true);
+         assert false : "Should have failed";
+      }
+      catch (ConfigurationException good) {
+         // do nothing
+      }
+
+      try {
          cache.endBatch(false);
-         // should not fail.
+         assert false : "Should have failed";
       }
-      finally {
-         TestingUtil.killCaches(cache);
+      catch (ConfigurationException good) {
+         // do nothing
       }
    }
 
+   public void testEndBatchWithoutStartBatch() {
+      Cache<String, String> cache = null;
+      cache = createCache(true, "testEndBatchWithoutStartBatch");
+      cache.endBatch(true);
+      cache.endBatch(false);
+      // should not fail.
+   }
+
    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);
+      cache = createCache(true, "testStartBatchIdempotency");
+      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);
-      }
+      assert "v".equals(cache.get("k"));
+      assert "v2".equals(cache.get("k2"));
    }
 
    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 = createCache(true, "testBatchVisibility");
+      cache.startBatch();
+      cache.put("k", "v");
+      assert getOnDifferentThread(cache, "k") == null : "Other thread should not see batch update till batch completes!";
 
-         cache.endBatch(true);
+      cache.endBatch(true);
 
-         assert "v".equals(getOnDifferentThread(cache, "k"));
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
+      assert "v".equals(getOnDifferentThread(cache, "k"));
    }
 
    public void testBatchRollback() throws Exception {
       Cache<String, String> cache = null;
-      try {
-         cache = createCache(true);
-         cache.startBatch();
-         cache.put("k", "v");
-         cache.put("k2", "v2");
+      cache = createCache(true, "testBatchRollback");
+      cache.startBatch();
+      cache.put("k", "v");
+      cache.put("k2", "v2");
 
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
+      assert getOnDifferentThread(cache, "k") == null;
+      assert getOnDifferentThread(cache, "k2") == null;
 
-         cache.endBatch(false);
+      cache.endBatch(false);
 
-         assert getOnDifferentThread(cache, "k") == null;
-         assert getOnDifferentThread(cache, "k2") == null;
-      }
-      finally {
-         TestingUtil.killCaches(cache);
-      }
+      assert getOnDifferentThread(cache, "k") == null;
+      assert getOnDifferentThread(cache, "k2") == null;
    }
 
-   private Cache<String, String> createCache(boolean enableBatch) {
-      UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
+   private Cache<String, String> createCache(boolean enableBatch, String name) {
       Configuration c = new Configuration();
       c.setInvocationBatchingEnabled(enableBatch);
-      return cf.createCache(c);
+      cm.defineCache(name, c);
+      return cm.getCache(name);
    }
 }

Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/LockAssert.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/LockAssert.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/LockAssert.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,7 @@
 
 import org.horizon.invocation.InvocationContextContainer;
 import org.horizon.lock.LockManager;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import org.horizon.util.concurrent.locks.LockContainer;
 
 /**

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-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/LockTestBase.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,6 +1,7 @@
 package org.horizon.api.mvcc;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.config.Configuration;
 import org.horizon.invocation.InvocationContextContainer;
 import org.horizon.lock.IsolationLevel;
@@ -11,7 +12,6 @@
 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.Test;
@@ -23,7 +23,7 @@
 /**
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  */
- at Test(groups = {"functional", "mvcc"}, sequential = true)
+ at Test(groups = {"functional", "mvcc"})
 public abstract class LockTestBase {
    protected boolean repeatableRead = true;
    protected boolean lockParentForChildInsertRemove = false;

Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,25 +2,24 @@
 
 import org.easymock.EasyMock;
 import static org.easymock.EasyMock.*;
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.commands.RPCCommand;
 import org.horizon.commands.write.PutKeyValueCommand;
 import org.horizon.commands.write.RemoveCommand;
 import org.horizon.config.Configuration;
 import org.horizon.invocation.Options;
-import org.horizon.manager.CacheManager;
 import org.horizon.remoting.RPCManager;
 import org.horizon.remoting.RPCManagerImpl;
 import org.horizon.remoting.ResponseFilter;
 import org.horizon.remoting.ResponseMode;
 import org.horizon.remoting.transport.Address;
 import org.horizon.remoting.transport.Transport;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.ReplListener;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
 import org.horizon.transaction.TransactionTable;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.*;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import javax.transaction.Transaction;
@@ -28,31 +27,27 @@
 import java.util.ArrayList;
 import java.util.List;
 
- at Test(groups = "functional", sequential = true)
-public class PutForExternalReadTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "api.mvcc.PutForExternalReadTest")
+public class PutForExternalReadTest extends MultipleCacheManagersTest {
    final String key = "k", value = "v", value2 = "v2";
    Cache cache1, cache2;
    TransactionManager tm1, tm2;
    ReplListener replListener1, replListener2;
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() {
+   protected void createCaches() throws Throwable {
       Configuration c = new Configuration();
       c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      CacheManager cm1 = addClusterEnabledCacheManager();
-      CacheManager cm2 = addClusterEnabledCacheManager();
-      defineCacheOnAllManagers("replSync", c);
+      createClusteredCaches(2, "replSync", c);
 
-      cache1 = cm1.getCache("replSync");
-      cache2 = cm2.getCache("replSync");
+      cache1 = cache(0, "replSync");
+      cache2 = cache(1, "replSync");
 
       tm1 = TestingUtil.getTransactionManager(cache1);
       tm2 = TestingUtil.getTransactionManager(cache2);
-      TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
 
-      replListener1 = attachReplicationListener(cache1);
-      replListener2 = attachReplicationListener(cache2);
+      replListener1 = replListener(cache1);
+      replListener2 = replListener(cache2);
    }
 
    public void testNoOpWhenKeyPresent() {

Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/read_committed/CacheAPIMVCCTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/read_committed/CacheAPIMVCCTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/read_committed/CacheAPIMVCCTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -4,10 +4,10 @@
 import org.horizon.lock.IsolationLevel;
 import org.testng.annotations.Test;
 
- at Test(groups = "functional")
+ at Test(groups = "functional", testName = "api.mvcc.read_committed.CacheAPIMVCCTest")
 public class CacheAPIMVCCTest extends CacheAPITest {
    @Override
    protected IsolationLevel getIsolationLevel() {
       return IsolationLevel.READ_COMMITTED;
    }
-}
\ No newline at end of file
+}

Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/read_committed/ReadCommittedLockTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/read_committed/ReadCommittedLockTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/read_committed/ReadCommittedLockTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -6,7 +6,7 @@
 
 import javax.transaction.Transaction;
 
- at Test(groups = {"functional", "mvcc"})
+ at Test(groups = {"functional", "mvcc"}, testName = "api.mvcc.read_committed.ReadCommittedLockTest")
 public class ReadCommittedLockTest extends LockTestBase {
    public ReadCommittedLockTest() {
       repeatableRead = false;

Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/CacheAPIMVCCTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/CacheAPIMVCCTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/CacheAPIMVCCTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -4,7 +4,7 @@
 import org.horizon.lock.IsolationLevel;
 import org.testng.annotations.Test;
 
- at Test(groups = "functional")
+ at Test(groups = "functional", testName = "api.mvcc.repeatable_read.CacheAPIMVCCTest")
 public class CacheAPIMVCCTest extends CacheAPITest {
    @Override
    protected IsolationLevel getIsolationLevel() {

Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/RepeatableReadLockTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/RepeatableReadLockTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/RepeatableReadLockTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -7,7 +7,7 @@
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 
- at Test(groups = {"functional", "mvcc"})
+ at Test(groups = {"functional", "mvcc"}, testName = "api.mvcc.repeatable_read.RepeatableReadLockTest")
 public class RepeatableReadLockTest extends LockTestBase {
    public RepeatableReadLockTest() {
       repeatableRead = true;

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-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/repeatable_read/WriteSkewTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -9,7 +9,7 @@
 import org.horizon.manager.CacheManager;
 import org.horizon.manager.DefaultCacheManager;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -21,7 +21,7 @@
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 
- at Test(groups = {"functional", "mvcc"}, sequential = true)
+ at Test(groups = {"functional", "mvcc"}, testName = "api.mvcc.repeatable_read.WriteSkewTest")
 public class WriteSkewTest {
    protected TransactionManager tm;
    protected LockManager lockManager;

Modified: core/branches/flat/src/test/java/org/horizon/api/tree/NodeAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/NodeAPITest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/NodeAPITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -8,7 +8,7 @@
 import org.horizon.tree.Node;
 import org.horizon.tree.TreeCache;
 import org.horizon.tree.TreeCacheImpl;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -25,7 +25,7 @@
  *
  * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani</a>
  */
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "api.tree.NodeAPITest")
 public class NodeAPITest {
    static final Fqn A = Fqn.fromString("/a"), B = Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn.fromString("/d");
    Fqn A_B = Fqn.fromRelativeFqn(A, B);

Modified: core/branches/flat/src/test/java/org/horizon/api/tree/NodeLockSupport.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/NodeLockSupport.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/NodeLockSupport.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -24,11 +24,11 @@
 package org.horizon.api.tree;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.lock.LockManager;
 import org.horizon.tree.Fqn;
 import org.horizon.tree.TreeCache;
 import org.horizon.tree.TreeStructureSupport;
-import org.horizon.util.TestingUtil;
 
 import javax.transaction.TransactionManager;
 

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-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,29 +1,23 @@
 package org.horizon.api.tree;
 
-import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.api.mvcc.LockAssert;
-import org.horizon.config.CacheLoaderManagerConfig;
 import org.horizon.config.Configuration;
-import org.horizon.config.parsing.XmlConfigHelper;
-import org.horizon.config.parsing.element.LoadersElementParser;
 import org.horizon.factories.ComponentRegistry;
 import org.horizon.invocation.InvocationContextContainer;
 import org.horizon.lock.LockManager;
 import org.horizon.logging.Log;
 import org.horizon.logging.LogFactory;
+import org.horizon.manager.CacheManager;
+import org.horizon.test.SingleCacheManagerTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.tree.Fqn;
 import org.horizon.tree.Node;
 import org.horizon.tree.NodeNotExistsException;
 import org.horizon.tree.TreeCache;
 import org.horizon.tree.TreeCacheImpl;
 import org.horizon.tree.TreeStructureSupport;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
-import org.w3c.dom.Element;
 
 import javax.transaction.TransactionManager;
 import java.util.Random;
@@ -34,8 +28,8 @@
  *
  * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani</a>
  */
- at Test(groups = {"functional", "pessimistic"}, testName = "api.NodeMoveAPITest")
-public class NodeMoveAPITest {
+ at Test(groups = {"functional", "pessimistic"}, testName = "api.tree.NodeMoveAPITest")
+public class NodeMoveAPITest extends SingleCacheManagerTest {
    protected final Log log = LogFactory.getLog(getClass());
 
    protected static final Fqn A = Fqn.fromString("/a"), B = Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn.fromString("/d"), E = Fqn.fromString("/e");
@@ -48,31 +42,23 @@
    static final Fqn D_B_C = Fqn.fromRelativeFqn(D_B, C);
    protected static final Object k = "key", vA = "valueA", vB = "valueB", vC = "valueC", vD = "valueD", vE = "valueE";
 
-   protected ThreadLocal<TreeCache<Object, Object>> cacheTL = new ThreadLocal<TreeCache<Object, Object>>();
-   protected ThreadLocal<TransactionManager> tmTL = new ThreadLocal<TransactionManager>();
+   TreeCache<Object, Object> treeCache;
+   TransactionManager tm;
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() throws Exception {
-      // start a single cache instance
+   protected CacheManager createCacheManager() throws Exception {
+      CacheManager cm = TestingUtil.createLocalCacheManager();
       Configuration c = new Configuration();
       c.setFetchInMemoryState(false);
       c.setInvocationBatchingEnabled(true);
-      Cache<Object, Object> cache = new UnitTestCacheFactory<Object, Object>().createCache(c);
-
-      cacheTL.set(new TreeCacheImpl<Object, Object>(cache));
-      tmTL.set(TestingUtil.getTransactionManager(cache));
+      cm.defineCache("test", c);
+      cache = cm.getCache("test");
+      tm = TestingUtil.extractComponent(cache, TransactionManager.class);
+      treeCache = new TreeCacheImpl(cache);
+      return cm;
    }
 
-   @AfterMethod(alwaysRun = true)
-   public void tearDown() {
-      TestingUtil.killTreeCaches(cacheTL.get());
-      cacheTL.set(null);
-   }
-
    public void testBasicMove() {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      TransactionManager tm = tmTL.get();
-      Node<Object, Object> rootNode = cache.getRoot();
+      Node<Object, Object> rootNode = treeCache.getRoot();
 
       Node<Object, Object> nodeA = rootNode.addChild(A);
       nodeA.put(k, vA);
@@ -98,16 +84,16 @@
       // parentage
       assertEquals(nodeA, nodeC.getParent());
 
-      log.info("BEFORE MOVE " + cache);
+      log.info("BEFORE MOVE " + treeCache);
       // move
-      cache.move(nodeC.getFqn(), nodeB.getFqn());
+      treeCache.move(nodeC.getFqn(), nodeB.getFqn());
 
       // re-fetch nodeC
-      nodeC = cache.getNode(Fqn.fromRelativeFqn(nodeB.getFqn(), C));
+      nodeC = treeCache.getNode(Fqn.fromRelativeFqn(nodeB.getFqn(), C));
 
-      log.info("POST MOVE " + cache);
+      log.info("POST MOVE " + treeCache);
       log.info("HC " + nodeC + " " + System.identityHashCode(nodeC));
-      Node x = cache.getRoot().getChild(Fqn.fromString("b/c"));
+      Node x = treeCache.getRoot().getChild(Fqn.fromString("b/c"));
       log.info("HC " + x + " " + System.identityHashCode(x));
       /*
          /a
@@ -136,9 +122,7 @@
    }
 
    public void testMoveWithChildren() {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      TransactionManager tm = tmTL.get();
-      Node<Object, Object> rootNode = cache.getRoot();
+      Node<Object, Object> rootNode = treeCache.getRoot();
 
       Node<Object, Object> nodeA = rootNode.addChild(A);
       nodeA.put(k, vA);
@@ -174,7 +158,7 @@
 
       // move
       log.info("move " + nodeC + " to " + nodeB);
-      cache.move(nodeC.getFqn(), nodeB.getFqn());
+      treeCache.move(nodeC.getFqn(), nodeB.getFqn());
       //System.out.println("nodeB " + nodeB);
       //System.out.println("nodeC " + nodeC);
 
@@ -207,9 +191,7 @@
    }
 
    public void testTxCommit() throws Exception {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      TransactionManager tm = tmTL.get();
-      Node<Object, Object> rootNode = cache.getRoot();
+      Node<Object, Object> rootNode = treeCache.getRoot();
 
       Node<Object, Object> nodeA = rootNode.addChild(A);
       Node<Object, Object> nodeB = nodeA.addChild(B);
@@ -221,7 +203,7 @@
 
       tm.begin();
       // move node B up to hang off the root
-      cache.move(nodeB.getFqn(), Fqn.ROOT);
+      treeCache.move(nodeB.getFqn(), Fqn.ROOT);
 
       tm.commit();
 
@@ -237,9 +219,7 @@
    }
 
    public void testTxRollback() throws Exception {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      TransactionManager tm = tmTL.get();
-      Node<Object, Object> rootNode = cache.getRoot();
+      Node<Object, Object> rootNode = treeCache.getRoot();
 
       Node<Object, Object> nodeA = rootNode.addChild(A);
       Node<Object, Object> nodeB = nodeA.addChild(B);
@@ -252,11 +232,11 @@
 
       tm.begin();
       // move node B up to hang off the root
-      System.out.println("Before: " + TreeStructureSupport.printTree(cache, true));
-      cache.move(nodeB.getFqn(), Fqn.ROOT);
-      System.out.println("After: " + TreeStructureSupport.printTree(cache, true));
+      System.out.println("Before: " + TreeStructureSupport.printTree(treeCache, true));
+      treeCache.move(nodeB.getFqn(), Fqn.ROOT);
+      System.out.println("After: " + TreeStructureSupport.printTree(treeCache, true));
       tm.rollback();
-      System.out.println("Rolled back: " + TreeStructureSupport.printTree(cache, true));
+      System.out.println("Rolled back: " + TreeStructureSupport.printTree(treeCache, true));
 
       nodeA = rootNode.getChild(A);
       nodeB = nodeA.getChild(B);
@@ -268,115 +248,8 @@
       assertEquals(nodeB, nodeA.getChildren().iterator().next());
    }
 
-   /*
-   public void testWithCacheloaders() throws Exception
-   {
-      doCacheLoaderTest(false, false);
-   }
-
-   public void testWithPassivation() throws Exception
-   {
-      doCacheLoaderTest(true, false);
-   }
-
-   public void testWithCacheloadersTx() throws Exception
-   {
-      doCacheLoaderTest(false, true);
-   }
-
-   public void testWithPassivationTx() throws Exception
-   {
-      doCacheLoaderTest(true, true);
-   }
-   */
-
-   /*
-protected void doCacheLoaderTest(boolean pasv, boolean useTx) throws Exception
-{
-TreeCache<Object, Object> cache = cacheTL.get();
-TransactionManager tm = tmTL.get();
-Node<Object, Object> rootNode = cache.getRoot();
-
-cache.destroy();
-cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig(pasv, "/", DummyInMemoryCacheLoader.class.getName(), "debug=true", false, false, false, false));
-cache.start();
-
-DummyInMemoryCacheLoader loaderold = (DummyInMemoryCacheLoader) cache.getCacheLoaderManager().getCacheLoader();
-
-rootNode.put("key", "value");
-
-if (!pasv)
-{
-Map m = loaderold.get(Fqn.ROOT);
-assertNotNull("Should not be null", m);
-assertEquals("value", m.get("key"));
-}
-
-Node<Object, Object> nodeA = rootNode.addChild(A);
-nodeA.put(k, vA);
-Node<Object, Object> nodeB = rootNode.addChild(B);
-nodeB.put(k, vB);
-Node<Object, Object> nodeC = nodeA.addChild(C);
-nodeC.put(k, vC);
-Node<Object, Object> nodeD = nodeC.addChild(D);
-nodeD.put(k, vD);
-Node<Object, Object> nodeE = nodeD.addChild(E);
-nodeE.put(k, vE);
-cache.evict(Fqn.ROOT, true);
-
-// move
-if (useTx) tm.begin();
-cache.move(nodeC.getFqn(), nodeB.getFqn());
-if (useTx) tm.commit();
-
-// after eviction, the node objects we hold are probably stale.
-nodeA = rootNode.getChild(A);
-nodeB = rootNode.getChild(B);
-nodeC = nodeB.getChild(C);
-log.info("nodeC get child B ");
-nodeD = nodeC.getChild(D);
-log.info("nodeD get child E ");
-nodeE = nodeD.getChild(E);
-
-Fqn old_C = C;
-Fqn old_D = Fqn.fromRelativeFqn(old_C, D);
-Fqn old_E = Fqn.fromRelativeFqn(old_D, E);
-
-// test data
-assertEquals(vA, nodeA.get(k));
-assertEquals(vB, nodeB.get(k));
-assertEquals(vC, nodeC.get(k));
-assertEquals(vD, nodeD.get(k));
-assertEquals(vE, nodeE.get(k));
-
-// parentage
-assertEquals(rootNode, nodeA.getParent());
-assertEquals(rootNode, nodeB.getParent());
-assertEquals(nodeB, nodeC.getParent());
-assertEquals(nodeC, nodeD.getParent());
-assertEquals(nodeD, nodeE.getParent());
-
-
-if (pasv) cache.evict(Fqn.ROOT, true);
-
-//now inspect the loaderold.
-assertEquals(vA, loaderold.get(nodeA.getFqn()).get(k));
-assertEquals(vB, loaderold.get(nodeB.getFqn()).get(k));
-assertEquals(vC, loaderold.get(nodeC.getFqn()).get(k));
-assertEquals(vD, loaderold.get(nodeD.getFqn()).get(k));
-assertEquals(vE, loaderold.get(nodeE.getFqn()).get(k));
-
-assertNull(loaderold.get(old_C));
-assertNull(loaderold.get(old_D));
-assertNull(loaderold.get(old_E));
-
-}
-   */
-
    public void testLocksDeepMove() throws Exception {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      TransactionManager tm = tmTL.get();
-      Node<Object, Object> rootNode = cache.getRoot();
+      Node<Object, Object> rootNode = treeCache.getRoot();
 
       Node<Object, Object> nodeA = rootNode.addChild(A);
       Node<Object, Object> nodeB = nodeA.addChild(B);
@@ -386,7 +259,7 @@
       assertNoLocks();
       tm.begin();
 
-      cache.move(nodeC.getFqn(), nodeB.getFqn());
+      treeCache.move(nodeC.getFqn(), nodeB.getFqn());
 
       checkLocksDeep();
 
@@ -397,9 +270,7 @@
    }
 
    public void testLocks() throws Exception {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      TransactionManager tm = tmTL.get();
-      Node<Object, Object> rootNode = cache.getRoot();
+      Node<Object, Object> rootNode = treeCache.getRoot();
 
       Node<Object, Object> nodeA = rootNode.addChild(A);
       Node<Object, Object> nodeB = nodeA.addChild(B);
@@ -407,7 +278,7 @@
       assertNoLocks();
       tm.begin();
 
-      cache.move(nodeC.getFqn(), nodeB.getFqn());
+      treeCache.move(nodeC.getFqn(), nodeB.getFqn());
 
       checkLocks();
 
@@ -416,8 +287,7 @@
    }
 
    public void testConcurrency() throws InterruptedException {
-      final TreeCache<Object, Object> cache = cacheTL.get();
-      Node<Object, Object> rootNode = cache.getRoot();
+      Node<Object, Object> rootNode = treeCache.getRoot();
 
       final int N = 3;// number of threads
       final int loops = 1 << 6;// number of loops
@@ -460,14 +330,14 @@
 
                   System.out.println(getName() + ": Attempt " + counter);
                   try {
-                     cache.move(NODE_X.getFqn(), NODES[r.nextInt(NODES.length)].getFqn());
+                     treeCache.move(NODE_X.getFqn(), NODES[r.nextInt(NODES.length)].getFqn());
                   }
                   catch (NodeNotExistsException e) {
                      // this may happen ...
                   }
                   TestingUtil.sleepRandom(250);
                   try {
-                     cache.move(NODE_Y.getFqn(), NODES[r.nextInt(NODES.length)].getFqn());
+                     treeCache.move(NODE_Y.getFqn(), NODES[r.nextInt(NODES.length)].getFqn());
                   }
                   catch (NodeNotExistsException e) {
                      // this may happen ...
@@ -512,55 +382,31 @@
    }
 
    public void testMoveInSamePlace() {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      Node<Object, Object> rootNode = cache.getRoot();
-
+      Node<Object, Object> rootNode = treeCache.getRoot();
       final Fqn FQN_X = Fqn.fromString("/x");
       // set up the initial structure.
       Node aNode = rootNode.addChild(A);
       Node xNode = aNode.addChild(FQN_X);
       assertEquals(aNode.getChildren().size(), 1);
 
-      System.out.println("Before: " + TreeStructureSupport.printTree(cache, true));
+      System.out.println("Before: " + TreeStructureSupport.printTree(treeCache, true));
 
-      cache.move(xNode.getFqn(), aNode.getFqn());
+      treeCache.move(xNode.getFqn(), aNode.getFqn());
 
-      System.out.println("After: " + TreeStructureSupport.printTree(cache, true));
+      System.out.println("After: " + TreeStructureSupport.printTree(treeCache, true));
 
       assertEquals(aNode.getChildren().size(), 1);
 
       assertNoLocks();
    }
 
-   protected CacheLoaderManagerConfig getSingleCacheLoaderConfig(boolean passivation, String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception {
-      String xml =
-            "      <loaders passivation=\"" + passivation + "\" shared=\"" + shared + "\">\n" +
-                  "         <preload>\n" +
-                  "            <node fqn=\"" + preload + "\"/>\n" +
-                  "         </preload>\n" +
-                  "         <loader class=\"" + cacheloaderClass + "\" async=\"" + async + "\" fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
-                  "                     purgeOnStartup=\"" + purgeOnStartup + "\">\n" +
-                  "            <properties>\n" +
-                  properties +
-                  "            </properties>\n" +
-                  "         </loader>\n" +
-                  "      </loaders>";
-      Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
-      LoadersElementParser elementParser = new LoadersElementParser();
-      return elementParser.parseLoadersElement(element);
-   }
-
    protected void checkLocks() {
-      TreeCache<Object, Object> tree = cacheTL.get();
-      Cache<Object, Object> cache = tree.getCache();
       LockManager lm = TestingUtil.extractLockManager(cache);
       assert TreeStructureSupport.isLocked(cache, lm, C);
       assert TreeStructureSupport.isLocked(cache, lm, A_B_C);
    }
 
    protected void checkLocksDeep() {
-      TreeCache<Object, Object> tree = cacheTL.get();
-      Cache<Object, Object> cache = tree.getCache();
       LockManager lm = TestingUtil.extractLockManager(cache);
 
       // /a/b, /c, /c/e, /a/b/c and /a/b/c/e should all be locked.
@@ -571,48 +417,45 @@
    }
 
    protected void assertNoLocks() {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache.getCache());
+      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
       LockManager lm = cr.getComponent(LockManager.class);
       InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);
       LockAssert.assertNoLocks(lm, icc);
    }
 
    public void testNonexistentSource() {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      cache.put(A_B_C, "k", "v");
-      assert "v".equals(cache.get(A_B_C, "k"));
-      assert 1 == cache.getNode(A_B).getChildren().size();
-      assert cache.getNode(A_B).getChildrenNames().contains(C.getLastElement());
-      assert !cache.getNode(A_B).getChildrenNames().contains(D.getLastElement());
+      treeCache.put(A_B_C, "k", "v");
+      assert "v".equals(treeCache.get(A_B_C, "k"));
+      assert 1 == treeCache.getNode(A_B).getChildren().size();
+      assert treeCache.getNode(A_B).getChildrenNames().contains(C.getLastElement());
+      assert !treeCache.getNode(A_B).getChildrenNames().contains(D.getLastElement());
 
-      cache.move(D, A_B);
+      treeCache.move(D, A_B);
 
-      assert "v".equals(cache.get(A_B_C, "k"));
-      assert 1 == cache.getNode(A_B).getChildren().size();
-      assert cache.getNode(A_B).getChildrenNames().contains(C.getLastElement());
-      assert !cache.getNode(A_B).getChildrenNames().contains(D.getLastElement());
+      assert "v".equals(treeCache.get(A_B_C, "k"));
+      assert 1 == treeCache.getNode(A_B).getChildren().size();
+      assert treeCache.getNode(A_B).getChildrenNames().contains(C.getLastElement());
+      assert !treeCache.getNode(A_B).getChildrenNames().contains(D.getLastElement());
    }
 
    public void testNonexistentTarget() {
-      TreeCache<Object, Object> cache = cacheTL.get();
-      cache.put(A_B_C, "k", "v");
-      assert "v".equals(cache.get(A_B_C, "k"));
-      assert 1 == cache.getNode(A_B).getChildren().size();
-      assert cache.getNode(A_B).getChildrenNames().contains(C.getLastElement());
-      assert null == cache.getNode(D);
+      treeCache.put(A_B_C, "k", "v");
+      assert "v".equals(treeCache.get(A_B_C, "k"));
+      assert 1 == treeCache.getNode(A_B).getChildren().size();
+      assert treeCache.getNode(A_B).getChildrenNames().contains(C.getLastElement());
+      assert null == treeCache.getNode(D);
 
-      System.out.println(TreeStructureSupport.printTree(cache, true));
+      System.out.println(TreeStructureSupport.printTree(treeCache, true));
 
-      cache.move(A_B, D);
+      treeCache.move(A_B, D);
 
-      System.out.println(TreeStructureSupport.printTree(cache, true));
+      System.out.println(TreeStructureSupport.printTree(treeCache, true));
 
-      assert null == cache.getNode(A_B_C);
-      assert null == cache.getNode(A_B);
-      assert null != cache.getNode(D);
-      assert null != cache.getNode(D_B);
-      assert null != cache.getNode(D_B_C);
-      assert "v".equals(cache.get(D_B_C, "k"));
+      assert null == treeCache.getNode(A_B_C);
+      assert null == treeCache.getNode(A_B);
+      assert null != treeCache.getNode(D);
+      assert null != treeCache.getNode(D_B);
+      assert null != treeCache.getNode(D_B_C);
+      assert "v".equals(treeCache.get(D_B_C, "k"));
    }
 }

Modified: core/branches/flat/src/test/java/org/horizon/api/tree/NodeReplicatedMoveTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/NodeReplicatedMoveTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/NodeReplicatedMoveTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -6,25 +6,23 @@
  */
 package org.horizon.api.tree;
 
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
-import org.horizon.manager.CacheManager;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
 import org.horizon.tree.Fqn;
 import org.horizon.tree.Node;
 import org.horizon.tree.TreeCache;
 import org.horizon.tree.TreeCacheImpl;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertNull;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import javax.transaction.TransactionManager;
 
- at Test(groups = "functional", sequential = true, testName = "api.NodeReplicatedMoveTest")
-public class NodeReplicatedMoveTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "api.tree.NodeReplicatedMoveTest")
+public class NodeReplicatedMoveTest extends MultipleCacheManagersTest {
 
    static final Fqn A = Fqn.fromString("/a"), B = Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn.fromString("/d"), E = Fqn.fromString("/e");
    static final Object k = "key", vA = "valueA", vB = "valueB", vC = "valueC", vD = "valueD", vE = "valueE";
@@ -32,8 +30,7 @@
    TreeCache<Object, Object> cache1, cache2;
    TransactionManager tm1;
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() throws Exception {
+   protected void createCaches() throws Throwable {
       Configuration c = new Configuration();
       c.setInvocationBatchingEnabled(true);
       c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
@@ -41,16 +38,12 @@
       c.setSyncCommitPhase(true);
       c.setSyncRollbackPhase(true);
 
-      CacheManager cm1 = addClusterEnabledCacheManager();
-      CacheManager cm2 = addClusterEnabledCacheManager();
+      createClusteredCaches(2, "replSync", c);
 
-      defineCacheOnAllManagers("replSync", c);
+      Cache c1 = cache(0, "replSync");
+      Cache c2 = cache(1, "replSync");
 
-      Cache c1 = cm1.getCache("replSync");
-      Cache c2 = cm2.getCache("replSync");
-
       tm1 = TestingUtil.getTransactionManager(c1);
-      TestingUtil.blockUntilViewsReceived(10000, cm1, cm2);
 
       cache1 = new TreeCacheImpl<Object, Object>(c1);
       cache2 = new TreeCacheImpl<Object, Object>(c2);

Modified: core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -7,18 +7,15 @@
 
 package org.horizon.api.tree;
 
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
 import org.horizon.invocation.Options;
-import org.horizon.manager.CacheManager;
+import org.horizon.test.MultipleCacheManagersTest;
 import org.horizon.tree.Fqn;
 import org.horizon.tree.Node;
 import org.horizon.tree.TreeCache;
 import org.horizon.tree.TreeCacheImpl;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.*;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.HashMap;
@@ -27,27 +24,21 @@
 /**
  * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
  */
- at Test(groups = "functional", sequential = true, testName = "api.SyncReplTest")
-public class SyncReplTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "api.tree.SyncReplTest")
+public class SyncReplTest extends MultipleCacheManagersTest {
    private TreeCache<Object, Object> cache1, cache2;
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() {
+   protected void createCaches() throws Throwable {
       Configuration c = new Configuration();
       c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
       c.setInvocationBatchingEnabled(true);
       c.setFetchInMemoryState(false);
 
-      CacheManager cm1 = addClusterEnabledCacheManager();
-      CacheManager cm2 = addClusterEnabledCacheManager();
+      createClusteredCaches(2, "replSync", c);
 
-      defineCacheOnAllManagers("replSync", c);
+      Cache c1 = cache(0, "replSync");
+      Cache c2 = cache(1, "replSync");
 
-      Cache c1 = cm1.getCache("replSync");
-      Cache c2 = cm2.getCache("replSync");
-
-      TestingUtil.blockUntilViewsReceived(new Cache[]{c1, c2}, 5000);
-
       cache1 = new TreeCacheImpl<Object, Object>(c1);
       cache2 = new TreeCacheImpl<Object, Object>(c2);
    }

Modified: core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTxTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTxTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTxTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -7,18 +7,16 @@
 
 package org.horizon.api.tree;
 
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
-import org.horizon.manager.CacheManager;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
 import org.horizon.tree.Fqn;
 import org.horizon.tree.Node;
 import org.horizon.tree.TreeCache;
 import org.horizon.tree.TreeCacheImpl;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.*;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import javax.transaction.HeuristicMixedException;
@@ -31,12 +29,11 @@
 /**
  * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
  */
- at Test(groups = "functional", sequential = true, testName = "api.SyncReplTxTest")
-public class SyncReplTxTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "api.tree.SyncReplTxTest")
+public class SyncReplTxTest extends MultipleCacheManagersTest {
    TreeCache<Object, Object> cache1, cache2;
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() throws CloneNotSupportedException {
+   protected void createCaches() throws Throwable {
       Configuration c = new Configuration();
       c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
       c.setFetchInMemoryState(false);
@@ -45,16 +42,11 @@
       c.setSyncRollbackPhase(true);
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
 
-      CacheManager cm1 = addClusterEnabledCacheManager();
-      CacheManager cm2 = addClusterEnabledCacheManager();
+      createClusteredCaches(2, "replSync", c);
 
-      defineCacheOnAllManagers("replSync", c);
+      Cache c1 = cache(0, "replSync");
+      Cache c2 = cache(1, "replSync");
 
-      Cache c1 = cm1.getCache("replSync");
-      Cache c2 = cm2.getCache("replSync");
-
-      TestingUtil.blockUntilViewsReceived(10000, cm1, cm2);
-
       cache1 = new TreeCacheImpl<Object, Object>(c1);
       cache2 = new TreeCacheImpl<Object, Object>(c2);
    }

Modified: core/branches/flat/src/test/java/org/horizon/api/tree/TreeCacheAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/TreeCacheAPITest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/TreeCacheAPITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -8,7 +8,7 @@
 import org.horizon.tree.Node;
 import org.horizon.tree.TreeCache;
 import org.horizon.tree.TreeCacheImpl;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -24,7 +24,7 @@
  * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani</a>
  */
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "api.tree.TreeCacheAPITest")
 public class TreeCacheAPITest {
    private TreeCache<String, String> cache;
    private TransactionManager tm;

Modified: core/branches/flat/src/test/java/org/horizon/api/tree/TreeStructureHashCodeTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/TreeStructureHashCodeTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/TreeStructureHashCodeTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -15,8 +15,9 @@
 /**
  * Tests the degree to which hash codes get spread
  */
- at Test
+ at Test (groups =  "unit" , testName = "api.tree.TreeStructureHashCodeTest")
 public class TreeStructureHashCodeTest {
+
    public void testHashCodesAppendedCount() {
       List<Fqn> fqns = new ArrayList<Fqn>();
       fqns.add(Fqn.ROOT);

Modified: core/branches/flat/src/test/java/org/horizon/atomic/APITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/atomic/APITest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/atomic/APITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -25,8 +25,8 @@
 import static org.horizon.atomic.AtomicHashMapTestAssertions.assertIsEmptyMap;
 import org.horizon.config.Configuration;
 import org.horizon.manager.DefaultCacheManager;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
@@ -36,7 +36,7 @@
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "atomic.APITest")
 public class APITest {
 
    AtomicMapCache cache;

Modified: core/branches/flat/src/test/java/org/horizon/atomic/AtomicHashMapTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/atomic/AtomicHashMapTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/atomic/AtomicHashMapTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -29,7 +29,7 @@
 import java.io.IOException;
 import java.io.ObjectOutput;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "atomic.AtomicHashMapTest")
 public class AtomicHashMapTest {
    public void testDeltasWithEmptyMap() throws IOException {
       AtomicHashMap m = new AtomicHashMap();

Modified: core/branches/flat/src/test/java/org/horizon/atomic/ClusteredAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/atomic/ClusteredAPITest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/atomic/ClusteredAPITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,25 +1,24 @@
 package org.horizon.atomic;
 
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import static org.horizon.atomic.AtomicHashMapTestAssertions.assertIsEmpty;
 import static org.horizon.atomic.AtomicHashMapTestAssertions.assertIsEmptyMap;
 import org.horizon.config.Configuration;
+import org.horizon.container.DataContainer;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManager;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.List;
 
 
- at Test(groups = "functional", sequential = true)
-public class ClusteredAPITest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "atomic.ClusteredAPITest")
+public class ClusteredAPITest extends MultipleCacheManagersTest {
    AtomicMapCache cache1, cache2;
 
-   @BeforeMethod
-   public void setUp() {
+   protected void createCaches() throws Throwable {
       Configuration c = new Configuration();
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
@@ -28,7 +27,6 @@
       List<Cache> caches = createClusteredCaches(2, "atomic", c);
       cache1 = (AtomicMapCache) caches.get(0);
       cache2 = (AtomicMapCache) caches.get(1);
-      TestingUtil.blockUntilViewsReceived(20000, cache1, cache2);
    }
 
    public void testReplicationCommit() throws Exception {
@@ -51,6 +49,10 @@
    }
 
    public void testReplicationRollback() throws Exception {
+      System.out.println("ClusteredAPITest.testReplicationRollback");
+      DataContainer dataContainer = TestingUtil.extractComponent(cache2, DataContainer.class);
+      System.out.println("dataContainer = " + dataContainer);
+      assertIsEmptyMap(cache2, "map");
       AtomicMap map = cache1.getAtomicMap("map");
 
       DummyTransactionManager.getInstance().begin();

Modified: core/branches/flat/src/test/java/org/horizon/config/parsing/ConfigurationParserTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/config/parsing/ConfigurationParserTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/config/parsing/ConfigurationParserTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -14,7 +14,7 @@
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "config.parsing.ConfigurationParserTest")
 public class ConfigurationParserTest {
 
    public void testLocking() throws Exception {

Modified: core/branches/flat/src/test/java/org/horizon/config/parsing/GlobalConfigurationParserTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/config/parsing/GlobalConfigurationParserTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/config/parsing/GlobalConfigurationParserTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -10,7 +10,7 @@
 import org.w3c.dom.Element;
 
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "config.parsing.GlobalConfigurationParserTest")
 public class GlobalConfigurationParserTest {
 
    public void testTransport() throws Exception {

Modified: core/branches/flat/src/test/java/org/horizon/config/parsing/XmlFileParsingTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/config/parsing/XmlFileParsingTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/config/parsing/XmlFileParsingTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -8,7 +8,7 @@
 import java.io.IOException;
 import java.util.Map;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "config.parsing.XmlFileParsingTest")
 public class XmlFileParsingTest {
    public void testNamedCacheFile() throws IOException {
       XmlConfigurationParser parser = new XmlConfigurationParserImpl("configs/named-cache-test.xml");

Modified: core/branches/flat/src/test/java/org/horizon/container/DataContainerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/container/DataContainerTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/container/DataContainerTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -5,12 +5,12 @@
 import java.util.HashSet;
 import java.util.Set;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "container.DataContainerTest")
 public class DataContainerTest {
    public void testExpiredData() throws InterruptedException {
       DataContainer dc = new UnsortedDataContainer();
       dc.put("k", "v", -1);
-      Thread.sleep(1);
+      Thread.sleep(100);
 
       assert dc.getModifiedTimestamp("k") <= System.currentTimeMillis();
 
@@ -18,7 +18,7 @@
       assert dc.purgeExpiredEntries().isEmpty();
 
       dc.put("k", "v", 0);
-      Thread.sleep(1);
+      Thread.sleep(100);
       assert dc.size() == 1;
       assert dc.getModifiedTimestamp("k") <= System.currentTimeMillis();
 
@@ -26,7 +26,7 @@
       assert dc.size() == 0;
 
       dc.put("k", "v", 0);
-      Thread.sleep(1);
+      Thread.sleep(100);
       assert dc.size() == 1;
       assert dc.getModifiedTimestamp("k") <= System.currentTimeMillis();
 

Modified: core/branches/flat/src/test/java/org/horizon/eviction/EvictionFunctionalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/EvictionFunctionalTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/EvictionFunctionalTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,6 +1,7 @@
 package org.horizon.eviction;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.config.Configuration;
 import org.horizon.config.EvictionConfig;
 import org.horizon.container.DataContainer;
@@ -9,7 +10,6 @@
 import org.horizon.manager.CacheManager;
 import org.horizon.manager.DefaultCacheManager;
 import org.horizon.util.ReflectionUtil;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -18,7 +18,7 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "eviction.EvictionFunctionalTest")
 public class EvictionFunctionalTest {
    Cache cache;
 

Modified: core/branches/flat/src/test/java/org/horizon/eviction/EvictionManagerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/EvictionManagerTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/EvictionManagerTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -14,7 +14,7 @@
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.EvictionManagerTest")
 public class EvictionManagerTest {
 
    private Configuration getCfg() {

Modified: core/branches/flat/src/test/java/org/horizon/eviction/algorithms/fifo/FifoAlgorithmTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/algorithms/fifo/FifoAlgorithmTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/algorithms/fifo/FifoAlgorithmTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -3,7 +3,7 @@
 import org.horizon.eviction.algorithms.BaseAlgorithmTest;
 import org.testng.annotations.Test;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.algorithms.fifo.FifoAlgorithmTest")
 public class FifoAlgorithmTest extends BaseAlgorithmTest {
    protected FIFOAlgorithmConfig getNewEvictionAlgorithmConfig() {
       return new FIFOAlgorithmConfig();

Modified: core/branches/flat/src/test/java/org/horizon/eviction/algorithms/fifo/FifoQueueTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/algorithms/fifo/FifoQueueTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/algorithms/fifo/FifoQueueTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -6,7 +6,7 @@
 
 import java.util.Iterator;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.algorithms.fifo.FifoQueueTest")
 public class FifoQueueTest extends BaseQueueTest {
 
    public void testOrder() throws Exception {

Modified: core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lfu/LfuAlgorithmTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lfu/LfuAlgorithmTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lfu/LfuAlgorithmTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -3,7 +3,7 @@
 import org.horizon.eviction.algorithms.BaseAlgorithmTest;
 import org.testng.annotations.Test;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.algorithms.lfu.LfuAlgorithmTest")
 public class LfuAlgorithmTest extends BaseAlgorithmTest {
    @Override
    protected boolean timeOrderedQueue() {

Modified: core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lfu/LfuQueueTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lfu/LfuQueueTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lfu/LfuQueueTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -8,7 +8,7 @@
 import java.util.Iterator;
 import java.util.Set;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.algorithms.lfu.LfuQueueTest")
 public class LfuQueueTest extends BaseQueueTest {
 
    @Override

Modified: core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lru/LruAlgorithmTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lru/LruAlgorithmTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lru/LruAlgorithmTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -3,7 +3,7 @@
 import org.horizon.eviction.algorithms.BaseAlgorithmTest;
 import org.testng.annotations.Test;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.algorithms.lru.LruAlgorithmTest")
 public class LruAlgorithmTest extends BaseAlgorithmTest {
    protected LRUAlgorithmConfig getNewEvictionAlgorithmConfig() {
       return new LRUAlgorithmConfig();

Modified: core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lru/LruQueueTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lru/LruQueueTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/algorithms/lru/LruQueueTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -6,7 +6,7 @@
 
 import java.util.Iterator;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.algorithms.lru.LruQueueTest")
 public class LruQueueTest extends BaseQueueTest {
    protected EvictionQueue getNewEvictionQueue() {
       return new LRUQueue();

Modified: core/branches/flat/src/test/java/org/horizon/eviction/algorithms/mru/MruAlgorithmTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/algorithms/mru/MruAlgorithmTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/algorithms/mru/MruAlgorithmTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -3,7 +3,7 @@
 import org.horizon.eviction.algorithms.BaseAlgorithmTest;
 import org.testng.annotations.Test;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.algorithms.mru.MruAlgorithmTest")
 public class MruAlgorithmTest extends BaseAlgorithmTest {
    protected MRUAlgorithmConfig getNewEvictionAlgorithmConfig() {
       return new MRUAlgorithmConfig();

Modified: core/branches/flat/src/test/java/org/horizon/eviction/algorithms/mru/MruQueueTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/eviction/algorithms/mru/MruQueueTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/eviction/algorithms/mru/MruQueueTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -5,7 +5,7 @@
 
 import java.util.Iterator;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "eviction.algorithms.mru.MruQueueTest")
 public class MruQueueTest extends BaseQueueTest {
    protected MRUQueue getNewEvictionQueue() {
       return new MRUQueue();

Modified: core/branches/flat/src/test/java/org/horizon/expiry/ExpiryTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/expiry/ExpiryTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/expiry/ExpiryTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -5,7 +5,7 @@
 import org.horizon.loader.StoredEntry;
 import org.horizon.manager.CacheManager;
 import org.horizon.manager.DefaultCacheManager;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -14,7 +14,7 @@
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "expiry.ExpiryTest")
 public class ExpiryTest {
 
    CacheManager cm;

Modified: core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,21 +1,19 @@
 package org.horizon.expiry;
 
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
-import org.testng.annotations.BeforeMethod;
+import org.horizon.test.MultipleCacheManagersTest;
 import org.testng.annotations.Test;
 
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
- at Test(groups = "functional", sequential = true)
-public class ReplicatedExpiryTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "expiry.ReplicatedExpiryTest")
+public class ReplicatedExpiryTest extends MultipleCacheManagersTest {
 
    Cache c1, c2;
 
-   @BeforeMethod
-   public void setUp() {
+   protected void createCaches() throws Throwable {
       Configuration cfg = new Configuration();
       cfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
       List<Cache> caches = createClusteredCaches(2, "cache", cfg);
@@ -25,18 +23,16 @@
 
    public void testExpiryReplicates() throws InterruptedException {
       long start = System.currentTimeMillis();
-      long lifespan = 10000;
+      long lifespan = 3000;
       c1.put("k", "v", lifespan, TimeUnit.MILLISECONDS);
 
-      while (System.currentTimeMillis() < start + lifespan + 1000) {
-         if (System.currentTimeMillis() < start + lifespan) {
-            assert c1.get("k").equals("v");
-            assert c2.get("k").equals("v");
-         } else {
-            assert c1.get("k") == null;
-            assert c2.get("k") == null;
-         }
+      while (System.currentTimeMillis() < start + lifespan) {
+         assert c1.get("k").equals("v");
+         assert c2.get("k").equals("v");
          Thread.sleep(250);
       }
+      Thread.sleep(1000);
+      assert c1.get("k") == null;
+      assert c2.get("k") == null;
    }
 }

Modified: core/branches/flat/src/test/java/org/horizon/factories/scopes/ScopeDetectorTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/factories/scopes/ScopeDetectorTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/factories/scopes/ScopeDetectorTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -6,7 +6,7 @@
  * @author Manik Surtani
  * @since 1.0
  */
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "factories.scopes.ScopeDetectorTest")
 public class ScopeDetectorTest {
    public void testScopeOnClass() {
       testScopes(Test1.class, Scopes.GLOBAL);

Modified: core/branches/flat/src/test/java/org/horizon/interceptors/MarshalledValueInterceptorTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/interceptors/MarshalledValueInterceptorTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/interceptors/MarshalledValueInterceptorTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,12 +1,12 @@
 package org.horizon.interceptors;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.config.Configuration;
 import org.horizon.config.GlobalConfiguration;
 import org.horizon.manager.CacheManager;
 import org.horizon.manager.DefaultCacheManager;
 import org.horizon.marshall.MarshalledValue;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -21,7 +21,7 @@
  * @author Mircea.Markus at jboss.com
  * @since 1.0
  */
- at Test(groups = "functional", sequential = true, testName = "interceptors.MarshalledValueInterceptorTest")
+ at Test(groups = "functional", testName = "interceptors.MarshalledValueInterceptorTest")
 public class MarshalledValueInterceptorTest {
    CacheManager cm;
 

Modified: core/branches/flat/src/test/java/org/horizon/invalidation/AsyncInvalidationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/invalidation/AsyncInvalidationTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/invalidation/AsyncInvalidationTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,7 @@
 
 import org.testng.annotations.Test;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "invalidation.AsyncInvalidationTest")
 public class AsyncInvalidationTest extends BaseInvalidationTest {
    public AsyncInvalidationTest() {
       isSync = false;

Modified: core/branches/flat/src/test/java/org/horizon/invalidation/BaseInvalidationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/invalidation/BaseInvalidationTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/invalidation/BaseInvalidationTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,6 @@
 
 import static org.easymock.EasyMock.*;
 import org.horizon.AdvancedCache;
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.commands.RPCCommand;
 import org.horizon.commands.write.ClearCommand;
@@ -15,10 +14,10 @@
 import org.horizon.remoting.ResponseMode;
 import org.horizon.remoting.transport.Address;
 import org.horizon.remoting.transport.Transport;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.*;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import javax.transaction.RollbackException;
@@ -27,13 +26,12 @@
 import java.util.ArrayList;
 import java.util.List;
 
- at Test(groups = "functional", sequential = true)
-public abstract class BaseInvalidationTest extends BaseClusteredTest {
+ at Test(groups = "functional")
+public abstract class BaseInvalidationTest extends MultipleCacheManagersTest {
    protected AdvancedCache cache1, cache2;
    protected boolean isSync;
 
-   @BeforeMethod
-   public void setUp() {
+   protected void createCaches() throws Throwable {
       Configuration c = new Configuration();
       c.setStateRetrievalTimeout(1000);
       c.setFetchInMemoryState(false);
@@ -42,7 +40,6 @@
       List<Cache> caches = createClusteredCaches(2, "invalidation", c);
       cache1 = caches.get(0).getAdvancedCache();
       cache2 = caches.get(1).getAdvancedCache();
-      TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
    }
 
    public void testRemove() throws Exception {
@@ -51,48 +48,45 @@
       cache2.put("key", "value", Options.CACHE_MODE_LOCAL);
       assertEquals("value", cache2.get("key"));
 
-      ReplListener rl = attachReplicationListener(cache2);
-      rl.expectAny();
+      replListener(cache2).expectAny();
       assertEquals("value", cache1.remove("key"));
-      rl.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assertEquals(false, cache2.containsKey("key"));
    }
 
    public void testResurrectEntry() throws Exception {
-      ReplListener r2 = attachReplicationListener(cache2);
-      r2.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       cache1.put("key", "value");
-      r2.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assertEquals("value", cache1.get("key"));
       assertEquals(null, cache2.get("key"));
-      r2.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       cache1.put("key", "newValue");
-      r2.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assertEquals("newValue", cache1.get("key"));
       assertEquals(null, cache2.get("key"));
 
-      r2.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       assertEquals("newValue", cache1.remove("key"));
-      r2.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assertEquals(null, cache1.get("key"));
       assertEquals(null, cache2.get("key"));
 
       // Restore locally
-      r2.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       cache1.put("key", "value");
-      r2.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assertEquals("value", cache1.get("key"));
       assertEquals(null, cache2.get("key"));
 
-      ReplListener r1 = attachReplicationListener(cache1);
-      r1.expect(InvalidateCommand.class);
+      replListener(cache1).expect(InvalidateCommand.class);
       cache2.put("key", "value2");
-      r1.waitForRPC();
+      replListener(cache1).waitForRPC();
 
       assertEquals("value2", cache2.get("key"));
       assertEquals(null, cache1.get("key"));
@@ -102,23 +96,21 @@
       assertNull("Should be null", cache1.get("key"));
       assertNull("Should be null", cache2.get("key"));
 
-      ReplListener rl2 = attachReplicationListener(cache2);
-      rl2.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       cache1.put("key", "value");
-      rl2.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assertEquals("value", cache1.get("key"));
       assertNull("Should be null", cache2.get("key"));
 
       // OK, here's the real test
       TransactionManager tm = TestingUtil.getTransactionManager(cache2);
-      ReplListener rl1 = attachReplicationListener(cache1);
-      rl1.expect(InvalidateCommand.class); // invalidates always happen outside of a tx
+      replListener(cache1).expect(InvalidateCommand.class); // invalidates always happen outside of a tx
       tm.begin();
       // Remove an entry that doesn't exist in cache2
       cache2.remove("key");
       tm.commit();
-      rl1.waitForRPC();
+      replListener(cache1).waitForRPC();
 
       assert cache1.get("key") == null;
       assert cache2.get("key") == null;
@@ -197,10 +189,9 @@
       assert cache2.get("key").equals("value");
       assert cache1.get("key") == null;
 
-      ReplListener r = attachReplicationListener(cache2);
-      r.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       cache1.putIfAbsent("key", "value");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key").equals("value");
       assert cache2.get("key") == null;
@@ -227,10 +218,9 @@
       assert cache1.get("key").equals("value1") : "Should not remove";
       assert cache2.get("key").equals("value2") : "Should not evict";
 
-      ReplListener r = attachReplicationListener(cache2);
-      r.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       cache1.remove("key", "value1");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key") == null;
       assert cache2.get("key") == null;
@@ -242,10 +232,9 @@
       assert cache1.get("key").equals("value1");
       assert cache2.get("key").equals("value2");
 
-      ReplListener r = attachReplicationListener(cache2);
-      r.expect(ClearCommand.class);
+      replListener(cache2).expect(ClearCommand.class);
       cache1.clear();
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key") == null;
       assert cache2.get("key") == null;
@@ -263,10 +252,9 @@
 
       cache1.put("key", "valueN", Options.CACHE_MODE_LOCAL);
 
-      ReplListener r = attachReplicationListener(cache2);
-      r.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       cache1.replace("key", "value1");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key").equals("value1");
       assert cache2.get("key") == null;
@@ -289,10 +277,9 @@
       assert cache1.get("key").equals("valueN");
       assert cache2.get("key").equals("value2");
 
-      ReplListener r = attachReplicationListener(cache2);
-      r.expect(InvalidateCommand.class);
+      replListener(cache2).expect(InvalidateCommand.class);
       cache1.replace("key", "valueN", "value1");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key").equals("value1");
       assert cache2.get("key") == null;

Modified: core/branches/flat/src/test/java/org/horizon/invalidation/SyncInvalidationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/invalidation/SyncInvalidationTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/invalidation/SyncInvalidationTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,7 @@
 
 import org.testng.annotations.Test;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "invalidation.SyncInvalidationTest")
 public class SyncInvalidationTest extends BaseInvalidationTest {
    public SyncInvalidationTest() {
       isSync = true;

Modified: core/branches/flat/src/test/java/org/horizon/loader/BaseCacheLoaderTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/BaseCacheLoaderTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/loader/BaseCacheLoaderTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -19,7 +19,7 @@
 import java.util.List;
 import java.util.Set;
 
- at Test(groups = "unit", sequential = true)
+ at Test(groups = "unit")
 @SuppressWarnings("unchecked")
 public abstract class BaseCacheLoaderTest {
 
@@ -67,7 +67,7 @@
       lifespan = 1;
       se = new StoredEntry("k", "v", now, now + lifespan);
       cs.store(se);
-      Thread.sleep(2);
+      Thread.sleep(100);
       assert se.isExpired();
       assert cs.load("k") == null;
       assert !cs.containsKey("k");

Modified: core/branches/flat/src/test/java/org/horizon/loader/CacheLoaderFunctionalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/CacheLoaderFunctionalTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/loader/CacheLoaderFunctionalTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -8,8 +8,8 @@
 import org.horizon.loader.dummy.DummyInMemoryCacheLoader;
 import org.horizon.manager.CacheManager;
 import org.horizon.manager.DefaultCacheManager;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
@@ -25,7 +25,7 @@
  *
  * @author Manik Surtani
  */
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "loader.CacheLoaderFunctionalTest")
 public class CacheLoaderFunctionalTest {
    Cache cache;
    CacheStore store;

Modified: core/branches/flat/src/test/java/org/horizon/loader/decorators/AsyncTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/decorators/AsyncTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/loader/decorators/AsyncTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -3,7 +3,7 @@
 import org.horizon.CacheException;
 import org.horizon.loader.StoredEntry;
 import org.horizon.loader.dummy.DummyInMemoryCacheLoader;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
@@ -11,7 +11,7 @@
 
 import java.util.concurrent.ExecutorService;
 
- at Test(groups = "unit", sequential = true)
+ at Test(groups = "unit", testName = "loader.decorators.AsyncTest")
 public class AsyncTest {
 
    AsyncStore store;

Modified: core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/loader/decorators/ReadOnlyCacheStoreTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -7,7 +7,7 @@
 
 import java.io.InputStream;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "loader.decorators.ReadOnlyCacheStoreTest")
 public class ReadOnlyCacheStoreTest {
    public void testWriteMethods() {
       CacheStore mock = createMock(CacheStore.class);

Modified: core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.config.CacheLoaderManagerConfig;
 import org.horizon.config.Configuration;
@@ -11,10 +10,11 @@
 import org.horizon.loader.StoredEntry;
 import org.horizon.loader.dummy.DummyInMemoryCacheLoader;
 import org.horizon.manager.CacheManager;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import org.horizon.util.internals.ViewChangeListener;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.fail;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -30,17 +30,17 @@
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 
- at Test(groups = "functional", sequential = true)
-public class SingletonStoreTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "loader.decorators.SingletonStoreTest")
+public class SingletonStoreTest {
    private static final Log log = LogFactory.getLog(SingletonStoreTest.class);
    private static final AtomicInteger storeCounter = new AtomicInteger(0);
    private CacheManager cm0, cm1, cm2;
 
    @BeforeMethod
-   public void setUp() {
-      cm0 = addClusterEnabledCacheManager();
-      cm1 = addClusterEnabledCacheManager();
-      cm2 = addClusterEnabledCacheManager();
+   protected void setUp() throws Throwable {
+      cm0 = TestingUtil.createClusteredCacheManager();
+      cm1 = TestingUtil.createClusteredCacheManager();
+      cm2 = TestingUtil.createClusteredCacheManager();
 
       Configuration conf = new Configuration();
       conf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
@@ -81,9 +81,18 @@
       cm2.defineCache("nonPushing", conf);
    }
 
+   @AfterMethod
+   public void tearDown() {
+      TestingUtil.killCacheManagers(cm0, cm1, cm2);
+   }
+
    private Cache[] getCaches(String name) {
+      Cache cache = cm0.getCache(name);
+      Cache cache1 = cm1.getCache(name);
+      Cache cache2 = cm2.getCache(name);
+      TestingUtil.blockUntilViewsReceived(10000, cm0, cm1, cm2);
       return new Cache[]{
-            cm0.getCache(name), cm1.getCache(name), cm2.getCache(name)
+            cache, cache1, cache2
       };
    }
 
@@ -127,7 +136,7 @@
       }
 
       cm0.stop();
-      TestingUtil.blockUntilViewsReceived(60000, cm1, cm2);
+      TestingUtil.blockForMemberToFail(60000, cm1, cm2);
 
       caches[1].put("key4", "value4");
       caches[2].put("key5", "value5");
@@ -139,7 +148,7 @@
       assert load(stores[2], "key5") == null;
 
       cm1.stop();
-      TestingUtil.blockUntilViewsReceived(60000, cm2);
+      TestingUtil.blockForMemberToFail(10000, cm2);
 
       caches[2].put("key6", "value6");
       assert load(stores[2], "key6").equals("value6");

Modified: core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheLoaderTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheLoaderTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/loader/dummy/DummyInMemoryCacheLoaderTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -4,7 +4,7 @@
 import org.horizon.loader.CacheStore;
 import org.testng.annotations.Test;
 
- at Test(groups = "unit", sequential = true)
+ at Test(groups = "unit", testName = "loader.dummy.DummyInMemoryCacheLoaderTest")
 public class DummyInMemoryCacheLoaderTest extends BaseCacheLoaderTest {
 
    protected CacheStore createCacheStore() {

Modified: core/branches/flat/src/test/java/org/horizon/lock/LockContainerHashingTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/lock/LockContainerHashingTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/lock/LockContainerHashingTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -33,7 +33,7 @@
 import java.util.Random;
 import java.util.concurrent.locks.Lock;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "lock.LockContainerHashingTest")
 public class LockContainerHashingTest {
    private LockContainer<String> stripedLock;
 

Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,6 +1,7 @@
 package org.horizon.manager;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.config.Configuration;
 import org.horizon.config.EvictionConfig;
 import org.horizon.config.GlobalConfiguration;
@@ -11,7 +12,6 @@
 import org.horizon.remoting.RPCManager;
 import org.horizon.transaction.DummyTransactionManager;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 
@@ -21,7 +21,7 @@
  * @author Manik Surtani
  * @since 1.0
  */
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "manager.CacheManagerComponentRegistryTest")
 public class CacheManagerComponentRegistryTest {
    DefaultCacheManager cm;
 

Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,17 +1,17 @@
 package org.horizon.manager;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.config.Configuration;
 import org.horizon.config.DuplicateCacheNameException;
 import org.horizon.lifecycle.ComponentStatus;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.Test;
 
 /**
  * @author Manik Surtani
  * @since 1.0
  */
- at Test(groups = "functional")
+ at Test(groups = "functional", testName = "manager.CacheManagerTest")
 public class CacheManagerTest {
    public void testDefaultCache() {
       CacheManager cm = new DefaultCacheManager();

Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,10 +1,10 @@
 package org.horizon.manager;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 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;
 
@@ -16,7 +16,7 @@
  * @author Manik Surtani
  * @since 1.0
  */
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "manager.CacheManagerXmlConfigurationTest")
 public class CacheManagerXmlConfigurationTest {
    DefaultCacheManager cm;
 

Modified: core/branches/flat/src/test/java/org/horizon/marshall/MarshalledValueTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/marshall/MarshalledValueTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/marshall/MarshalledValueTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,9 +1,8 @@
 package org.horizon.marshall;
 
-import org.horizon.AdvancedCache;
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.CacheException;
+import org.horizon.AdvancedCache;
 import org.horizon.commands.write.PutKeyValueCommand;
 import org.horizon.config.CacheLoaderManagerConfig;
 import org.horizon.config.Configuration;
@@ -14,11 +13,11 @@
 import org.horizon.interceptors.base.CommandInterceptor;
 import org.horizon.loader.CacheLoaderConfig;
 import org.horizon.loader.dummy.DummyInMemoryCacheLoader;
-import org.horizon.manager.CacheManager;
 import org.horizon.notifications.Listener;
 import org.horizon.notifications.cachelistener.annotation.CacheEntryModified;
 import org.horizon.notifications.cachelistener.event.CacheEntryModifiedEvent;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -41,32 +40,23 @@
  * @since 1.0
  */
 @Test(groups = "functional", testName = "marshall.MarshalledValueTest")
-public class MarshalledValueTest extends BaseClusteredTest {
+public class MarshalledValueTest extends MultipleCacheManagersTest {
    private Cache cache1, cache2;
    private MarshalledValueListenerInterceptor mvli;
    String k = "key", v = "value";
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() {
-      CacheManager cm1 = addClusterEnabledCacheManager();
-      CacheManager cm2 = addClusterEnabledCacheManager();
-
+   protected void createCaches() throws Throwable {
       Configuration replSync = new Configuration();
       replSync.setCacheMode(Configuration.CacheMode.REPL_SYNC);
       replSync.setUseLazyDeserialization(true);
 
-      defineCacheOnAllManagers("replSync", replSync);
+      createClusteredCaches(2, "replSync", replSync);
 
-      cache1 = cm1.getCache("replSync");
-      cache2 = cm2.getCache("replSync");
+      cache1 = cache(0, "replSync");
+      cache2 = cache(1, "replSync");
 
       assertMarshalledValueInterceptorPresent(cache1);
       assertMarshalledValueInterceptorPresent(cache2);
-
-      mvli = new MarshalledValueListenerInterceptor();
-      ((AdvancedCache)cache1).addInterceptorAfter(mvli, MarshalledValueInterceptor.class);
-
-      TestingUtil.blockUntilViewsReceived(60000, true, cm1, cm2);
    }
 
    private void assertMarshalledValueInterceptorPresent(Cache c) {
@@ -74,9 +64,14 @@
       assert ic1.containsInterceptorType(MarshalledValueInterceptor.class);
    }
 
+   @BeforeMethod
+   public void addMarshalledValueInterceptor() {
+      mvli = new MarshalledValueListenerInterceptor();
+      ((AdvancedCache)cache1).addInterceptorAfter(mvli, MarshalledValueInterceptor.class);
+   }
+
    @AfterMethod
    public void tearDown() {
-      TestingUtil.killCaches(cache1, cache2);
       Pojo.serializationCount = 0;
       Pojo.deserializationCount = 0;
    }
@@ -266,11 +261,9 @@
       cacheCofig.setCacheLoaderConfig(clmc);
 
       defineCacheOnAllManagers("replSync2", cacheCofig);
-      cache1 = getCacheManagers().get(0).getCache("replSync2");
-      cache2 = getCacheManagers().get(1).getCache("replSync2");
+      cache1 = cache(0, "replSync2");
+      cache2 = cache(1, "replSync2");
 
-      TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
-
       Pojo pojo = new Pojo();
       cache1.put("key", pojo);
 

Modified: core/branches/flat/src/test/java/org/horizon/notifications/AsyncNotificationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/AsyncNotificationTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/AsyncNotificationTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -5,14 +5,14 @@
 import org.horizon.manager.DefaultCacheManager;
 import org.horizon.notifications.cachelistener.annotation.CacheEntryCreated;
 import org.horizon.notifications.cachelistener.event.CacheEntryCreatedEvent;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.concurrent.CountDownLatch;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "notifications.AsyncNotificationTest")
 public class AsyncNotificationTest {
    Cache<String, String> c;
    CacheManager cm;

Modified: core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,7 @@
 
 import org.testng.annotations.Test;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "notifications.CacheListenerCacheLoaderTest")
 public class CacheListenerCacheLoaderTest {
    // TODO implement me!
 //   private Cache<Object, Object> cache;
@@ -24,7 +24,7 @@
 //      clc.setPassivation(true);
 //
 //      c.setCacheLoaderConfig(clc);
-//      cache = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
+//      cache = new UnitTestCacheFactory<Object, Object>().createCacheManager(c, getClass());
 //      eventLog.events.clear();
 //      cache.addCacheListener(eventLog);
 //      tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -181,4 +181,4 @@
 //      assert cache.get(fqn, "key").equals("value");
 //      assert cache.get(fqn, "key2").equals("value2");
 //   }
-}
\ No newline at end of file
+}

Modified: core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerPassivationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerPassivationTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerPassivationTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,7 @@
 
 import org.testng.annotations.Test;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "notifications.CacheListenerPassivationTest")
 public class CacheListenerPassivationTest {
    // TODO implement me!
 //   private Cache<Object, Object> cache;
@@ -24,7 +24,7 @@
 //      clc.setPassivation(true);
 //
 //      c.setCacheLoaderConfig(clc);
-//      cache = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
+//      cache = new UnitTestCacheFactory<Object, Object>().createCacheManager(c, getClass());
 //      eventLog.events.clear();
 //      cache.addCacheListener(eventLog);
 //      tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();

Modified: core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerRemovalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerRemovalTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerRemovalTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -5,7 +5,7 @@
 import org.horizon.manager.DefaultCacheManager;
 import org.horizon.notifications.cachelistener.annotation.CacheEntryVisited;
 import org.horizon.notifications.cachelistener.event.Event;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -15,7 +15,7 @@
 /**
  * @author Manik Surtani
  */
- at Test(groups = "functional")
+ at Test(groups = "functional", testName = "notifications.CacheListenerRemovalTest")
 public class CacheListenerRemovalTest {
    Cache<String, String> cache;
    CacheManager cm;
@@ -43,7 +43,7 @@
       cache.get("x");
       assert 1 == i.get();
 
-      // remove the listener
+      // remove the replListener
       cache.removeListener(l);
       assert 0 == cache.getListeners().size();
       i.set(0);

Modified: core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,6 +1,7 @@
 package org.horizon.notifications;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.logging.Log;
 import org.horizon.logging.LogFactory;
 import org.horizon.manager.CacheManager;
@@ -10,7 +11,6 @@
 import org.horizon.notifications.cachelistener.annotation.CacheEntryRemoved;
 import org.horizon.notifications.cachelistener.annotation.CacheEntryVisited;
 import org.horizon.notifications.cachelistener.event.Event;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -20,7 +20,7 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 
- at Test(groups = "functional", sequential = true, testName = "notifications.ConcurrentNotificationTest")
+ at Test(groups = "functional", testName = "notifications.ConcurrentNotificationTest")
 public class ConcurrentNotificationTest {
    Cache<String, String> cache;
    CacheManager cm;
@@ -91,7 +91,7 @@
       for (Exception e : exceptions)
          throw e;
 
-      // we cannot ascertain the exact number of invocations on the listener since some removes would mean that other
+      // we cannot ascertain the exact number of invocations on the replListener since some removes would mean that other
       // gets would miss.  And this would cause no notification to fire for that get.  And we cannot be sure of the
       // timing between removes and gets, so we just make sure *some* of these have got through, and no exceptions
       // were thrown due to concurrent access.

Modified: core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierImplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierImplTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierImplTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -18,7 +18,7 @@
 
 import javax.transaction.Transaction;
 
- at Test(groups = "unit", sequential = true)
+ at Test(groups = "unit", testName = "notifications.cachelistener.CacheNotifierImplTest")
 public class CacheNotifierImplTest {
    CacheNotifierImpl n;
    Cache mockCache;

Modified: core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,13 +2,13 @@
 
 import static org.easymock.EasyMock.*;
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.config.Configuration;
 import org.horizon.context.InvocationContext;
 import org.horizon.lock.IsolationLevel;
 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.Test;
@@ -19,7 +19,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "notifications.cachelistener.CacheNotifierTest")
 public class CacheNotifierTest {
    private Cache<Object, Object> cache;
    private TransactionManager tm;

Modified: core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/ListenerRegistrationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/ListenerRegistrationTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/ListenerRegistrationTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -11,7 +11,7 @@
 
 import java.util.List;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "notifications.cachelistener.ListenerRegistrationTest")
 public class ListenerRegistrationTest {
    public void testControl() {
       Object l = new TestControlListener();

Modified: core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -12,7 +12,7 @@
 import java.util.Collections;
 import java.util.List;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "notifications.cachemanagerlistener.CacheManagerNotifierImplTest")
 public class CacheManagerNotifierImplTest {
    CacheManagerNotifierImpl n;
    CacheManagerListener cl;

Modified: core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,27 +1,38 @@
 package org.horizon.notifications.cachemanagerlistener;
 
 import static org.easymock.EasyMock.*;
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
 import org.horizon.config.GlobalConfiguration;
 import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
 import org.horizon.remoting.transport.Address;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 
 import java.util.List;
 
- at Test(groups = "unit", sequential = true, testName = "notifications.CacheManagerNotifierTest")
-public class CacheManagerNotifierTest extends BaseClusteredTest {
+ at Test(groups = "unit", testName = "notifications.cachemanagerlistener.CacheManagerNotifierTest")
+public class CacheManagerNotifierTest {
+   CacheManager cm1;
+   CacheManager cm2;
+
+   @AfterMethod 
+   public void tearDown()
+   {
+      TestingUtil.killCacheManagers(cm1, cm2);
+   }
+
    public void testViewChange() {
-      CacheManager cm1 = addClusterEnabledCacheManager();
-      CacheManager cm2 = addClusterEnabledCacheManager();
+      cm1 = TestingUtil.createClusteredCacheManager();
+      cm2 = TestingUtil.createClusteredCacheManager();
       Configuration c = new Configuration();
       c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
-      defineCacheOnAllManagers("cache", c);
+      cm1.defineCache("cache", c);
+      cm2.defineCache("cache", c);
 
-      Cache c1 = cm1.getCache("cache");
+      cm1.getCache("cache");
 
       // this will mean only 1 cache in the cluster so far
       assert cm1.getMembers().size() == 1;
@@ -45,8 +56,8 @@
    }
 
    public void testCacheStartedAndStopped() {
-      CacheManager cm1 = addCacheManager(GlobalConfiguration.getNonClusteredDefault());
-      Cache defCache = cm1.getCache();
+      cm1 = new DefaultCacheManager(GlobalConfiguration.getNonClusteredDefault());
+      cm1.getCache();
       CacheManagerNotifier mockNotifier = createMock(CacheManagerNotifier.class);
       CacheManagerNotifier origNotifier = TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, mockNotifier, true);
       try {

Modified: core/branches/flat/src/test/java/org/horizon/profiling/AbstractProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/profiling/AbstractProfileTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/profiling/AbstractProfileTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,28 +1,18 @@
 package org.horizon.profiling;
 
-import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.config.Configuration;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+import org.horizon.test.SingleCacheManagerTest;
 import org.testng.annotations.Test;
 
-import java.util.Map;
+ at Test(groups = "profiling", enabled = false, testName = "profiling.SingleCacheManagerTest")
+public abstract class AbstractProfileTest extends SingleCacheManagerTest {
 
- at Test(groups = "profiling")
-public abstract class AbstractProfileTest {
-   protected Map cache;
-
-   @BeforeTest
-   public void setUp() {
+   protected CacheManager createCacheManager() throws Exception {
       Configuration cfg = new Configuration();
-      cache = new UnitTestCacheFactory().createCache(cfg, false);
+      cacheManager = new DefaultCacheManager(cfg);
+      cache = cacheManager.getCache();
+      return cacheManager;
    }
-
-   @AfterTest
-   public void tearDown() {
-      TestingUtil.killCaches((Cache) cache);
-      cache = null;
-   }
 }

Modified: core/branches/flat/src/test/java/org/horizon/profiling/MemConsumptionTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/profiling/MemConsumptionTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/profiling/MemConsumptionTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -24,7 +24,7 @@
 import org.horizon.Cache;
 import org.horizon.CacheException;
 import org.horizon.manager.DefaultCacheManager;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.TestingUtil;
 import org.testng.annotations.Test;
 
 import java.io.IOException;
@@ -32,7 +32,7 @@
 import java.util.Arrays;
 import java.util.Random;
 
- at Test(groups = "profiling", enabled = false)
+ at Test(groups = "profiling", enabled = false, testName = "profiling.MemConsumptionTest")
 public class MemConsumptionTest {
    // adjust the next 4 values
    int numEntries = 1000000;

Modified: core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,13 +1,13 @@
 package org.horizon.profiling;
 
 import org.horizon.Cache;
+import org.horizon.test.TestingUtil;
 import org.horizon.config.Configuration;
 import org.horizon.lock.IsolationLevel;
 import org.horizon.logging.Log;
 import org.horizon.logging.LogFactory;
 import org.horizon.profiling.testinternals.Generator;
 import org.horizon.profiling.testinternals.TaskRunner;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.Test;
 
 import java.util.ArrayList;
@@ -26,7 +26,7 @@
  *
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  */
- at Test(groups = "profiling", sequential = true, enabled = false)
+ at Test(groups = "profiling", enabled = false, testName = "profiling.ProfileTest")
 public class ProfileTest extends AbstractProfileTest {
    /*
       Test configuration options
@@ -42,7 +42,7 @@
 
    Log log = LogFactory.getLog(ProfileTest.class);
 
-   @Test(enabled = true)
+   @Test(enabled = false)
    public void testLocalMode() throws Exception {
       Cache c = (Cache) cache;
       c.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);

Modified: core/branches/flat/src/test/java/org/horizon/profiling/TreeProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/profiling/TreeProfileTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/profiling/TreeProfileTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,20 +1,21 @@
 package org.horizon.profiling;
 
 import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.config.Configuration;
 import org.horizon.lock.IsolationLevel;
 import org.horizon.logging.Log;
 import org.horizon.logging.LogFactory;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
 import org.horizon.profiling.testinternals.Generator;
 import org.horizon.profiling.testinternals.TaskRunner;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManager;
 import org.horizon.tree.Fqn;
 import org.horizon.tree.TreeCache;
 import org.horizon.tree.TreeCacheImpl;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.ArrayList;
@@ -33,9 +34,11 @@
  *
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  */
- at Test(groups = "profiling", sequential = true, enabled = false)
+ at Test(groups = "profiling", testName = "profiling.TreeProfileTest", enabled = false)
 public class TreeProfileTest {
-   /*
+   Log log = LogFactory.getLog(TreeProfileTest.class);
+
+   /**
       Test configuration options
     */
    protected static final long NUM_OPERATIONS = 1000000; // DURATION is replaced with a fixed number of operations instead.
@@ -44,11 +47,14 @@
    protected static final int MAX_DEPTH = 3;
    protected static final int MAX_OVERALL_NODES = 2000;
    protected static final int WARMUP_LOOPS = 20000;
+
    protected static final boolean USE_SLEEP = false; // throttle generation a bit
+   private CacheManager cacheManager;
 
+
    protected TreeCache cache;
 
-   @BeforeTest
+   @BeforeMethod
    public void setUp() {
       Configuration cfg = new Configuration();
       cfg.setInvocationBatchingEnabled(true);
@@ -56,20 +62,19 @@
       cfg.setConcurrencyLevel(2000);
       cfg.setLockAcquisitionTimeout(120000);
       cfg.setIsolationLevel(IsolationLevel.READ_COMMITTED);
-      Cache c = new UnitTestCacheFactory().createCache(cfg);
+      cacheManager = new DefaultCacheManager(cfg);
+      Cache c = cacheManager.getCache();
       cache = new TreeCacheImpl(c);
    }
 
-   @AfterTest
+   @AfterMethod
    public void tearDown() {
       TestingUtil.killTreeCaches(cache);
-      cache = null;
+      TestingUtil.killCacheManagers(cacheManager);
    }
 
    private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_NODES);
 
-   Log log = LogFactory.getLog(TreeProfileTest.class);
-
    public void testLocalMode() throws Exception {
       runCompleteTest();
    }

Modified: core/branches/flat/src/test/java/org/horizon/replication/AsyncReplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/AsyncReplTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/replication/AsyncReplTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -8,13 +8,12 @@
 
 package org.horizon.replication;
 
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.assertEquals;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import javax.transaction.TransactionManager;
@@ -24,70 +23,63 @@
 /**
  * Unit test for replicated async CacheSPI. Use locking and multiple threads to test concurrent access to the tree.
  */
- at Test(groups = "functional", sequential = true)
-public class AsyncReplTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "replication.AsyncReplTest")
+public class AsyncReplTest extends MultipleCacheManagersTest {
 
    Cache cache1, cache2;
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() throws Exception {
+   protected void createCaches() throws Throwable {
       Configuration asyncConfiguration = new Configuration();
       asyncConfiguration.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
       asyncConfiguration.setSyncCommitPhase(true);
       asyncConfiguration.setSyncRollbackPhase(true);
       asyncConfiguration.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-
       List<Cache> caches = createClusteredCaches(2, "asyncRepl", asyncConfiguration);
-
       cache1 = caches.get(0);
       cache2 = caches.get(1);
    }
 
    public void testWithNoTx() throws Exception {
-      ReplListener replListener2 = attachReplicationListener(cache2);
 
       String key = "key";
 
-      replListener2.expectAny();
+      replListener(cache2).expectAny();
       cache1.put(key, "value1");
       // allow for replication
-      replListener2.waitForRPC(60, TimeUnit.SECONDS);
+      replListener(cache2).waitForRPC(60, TimeUnit.SECONDS);
       assertEquals("value1", cache1.get(key));
       assertEquals("value1", cache2.get(key));
 
-      replListener2.expectAny();
+      replListener(cache2).expectAny();
       cache1.put(key, "value2");
       assertEquals("value2", cache1.get(key));
 
-      replListener2.waitForRPC(60, TimeUnit.SECONDS);
+      replListener(cache2).waitForRPC(60, TimeUnit.SECONDS);
 
       assertEquals("value2", cache1.get(key));
       assertEquals("value2", cache2.get(key));
    }
 
    public void testWithTx() throws Exception {
-      ReplListener replListener2 = attachReplicationListener(cache2);
-
       String key = "key";
-
-      replListener2.expectAny();
+      replListener(cache2).expectAny();
       cache1.put(key, "value1");
       // allow for replication
-      replListener2.waitForRPC(60, TimeUnit.SECONDS);
+      replListener(cache2).waitForRPC(60, TimeUnit.SECONDS);
       assertEquals("value1", cache1.get(key));
       assertEquals("value1", cache2.get(key));
 
       TransactionManager mgr = TestingUtil.getTransactionManager(cache1);
       mgr.begin();
 
-      replListener2.expectAnyWithTx();
+      replListener(cache2).expectAnyWithTx();
       cache1.put(key, "value2");
       assertEquals("value2", cache1.get(key));
       assertEquals("value1", cache2.get(key));
 
       mgr.commit();
 
-      replListener2.waitForRPC(60, TimeUnit.SECONDS);
+      replListener(cache2).waitForRPC(60, TimeUnit.SECONDS);
 
       assertEquals("value2", cache1.get(key));
       assertEquals("value2", cache2.get(key));

Modified: core/branches/flat/src/test/java/org/horizon/replication/AsyncReplicatedAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/AsyncReplicatedAPITest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/replication/AsyncReplicatedAPITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,7 @@
 
 import org.testng.annotations.Test;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "replication.AsyncReplicatedAPITest")
 public class AsyncReplicatedAPITest extends BaseReplicatedAPITest {
    public AsyncReplicatedAPITest() {
       isSync = false;

Modified: core/branches/flat/src/test/java/org/horizon/replication/BaseReplicatedAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/BaseReplicatedAPITest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/replication/BaseReplicatedAPITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,7 +1,6 @@
 package org.horizon.replication;
 
 import org.horizon.AdvancedCache;
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.commands.write.ClearCommand;
 import org.horizon.commands.write.PutKeyValueCommand;
@@ -10,23 +9,19 @@
 import org.horizon.commands.write.ReplaceCommand;
 import org.horizon.config.Configuration;
 import org.horizon.invocation.Options;
+import org.horizon.test.MultipleCacheManagersTest;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
 
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
- at Test(groups = "functional", sequential = true)
-public abstract class BaseReplicatedAPITest extends BaseClusteredTest {
+public class BaseReplicatedAPITest extends MultipleCacheManagersTest {
 
    AdvancedCache cache1, cache2;
    protected boolean isSync;
 
-   @BeforeMethod
-   public void setUp() {
+   protected void createCaches() throws Throwable {
       Configuration c = new Configuration();
       c.setStateRetrievalTimeout(1000);
       c.setFetchInMemoryState(false);
@@ -35,7 +30,6 @@
       List<Cache> caches = createClusteredCaches(2, "replication", c);
       cache1 = caches.get(0).getAdvancedCache();
       cache2 = caches.get(1).getAdvancedCache();
-      TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
    }
 
    public void put() {
@@ -43,10 +37,9 @@
       assert cache1.get("key") == null;
       assert cache2.get("key") == null;
 
-      ReplListener r = attachReplicationListener(cache2);
-      r.expect(PutKeyValueCommand.class);
+      replListener(cache2).expect(PutKeyValueCommand.class);
       cache1.put("key", "value");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key").equals("value");
       assert cache2.get("key").equals("value");
@@ -55,9 +48,9 @@
       map.put("key2", "value2");
       map.put("key3", "value3");
 
-      r.expect(PutMapCommand.class);
+      replListener(cache2).expect(PutMapCommand.class);
       cache1.putAll(map);
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key").equals("value");
       assert cache2.get("key").equals("value");
@@ -72,10 +65,9 @@
       assert cache2.get("key").equals("value");
       assert cache1.get("key") == null;
 
-      ReplListener r = attachReplicationListener(cache2);
-      r.expect(RemoveCommand.class);
+      replListener(cache2).expect(RemoveCommand.class);
       cache1.remove("key");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key") == null;
       assert cache2.get("key") == null;
@@ -85,9 +77,9 @@
       assert cache1.get("key").equals("value");
       assert cache2.get("key").equals("value");
 
-      r.expect(RemoveCommand.class);
+      replListener(cache2).expect(RemoveCommand.class);
       cache1.remove("key");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key") == null;
       assert cache2.get("key") == null;
@@ -98,10 +90,9 @@
       assert cache2.get("key").equals("valueOld");
       assert cache1.get("key") == null;
 
-      BaseClusteredTest.ReplListener r = attachReplicationListener(cache2);
-      r.expect(PutKeyValueCommand.class);
+      replListener(cache2).expect(PutKeyValueCommand.class);
       cache1.putIfAbsent("key", "value");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key").equals("value");
       assert cache2.get("key").equals("value");
@@ -128,10 +119,9 @@
       assert cache1.get("key").equals("value1") : "Should not remove";
       assert cache2.get("key").equals("value2") : "Should not remove";
 
-      BaseClusteredTest.ReplListener r = attachReplicationListener(cache2);
-      r.expect(RemoveCommand.class);
+      replListener(cache2).expect(RemoveCommand.class);
       cache1.remove("key", "value1");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key") == null;
       assert cache2.get("key") == null;
@@ -143,10 +133,9 @@
       assert cache1.get("key").equals("value1");
       assert cache2.get("key").equals("value2");
 
-      BaseClusteredTest.ReplListener r = attachReplicationListener(cache2);
-      r.expect(ClearCommand.class);
+      replListener(cache2).expect(ClearCommand.class);
       cache1.clear();
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key") == null;
       assert cache2.get("key") == null;
@@ -164,10 +153,9 @@
 
       cache1.put("key", "valueN", Options.CACHE_MODE_LOCAL);
 
-      BaseClusteredTest.ReplListener r = attachReplicationListener(cache2);
-      r.expect(ReplaceCommand.class);
+      replListener(cache2).expect(ReplaceCommand.class);
       cache1.replace("key", "value1");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key").equals("value1");
       assert cache2.get("key").equals("value1");
@@ -190,10 +178,9 @@
       assert cache1.get("key").equals("valueN");
       assert cache2.get("key").equals("value2");
 
-      BaseClusteredTest.ReplListener r = attachReplicationListener(cache2);
-      r.expect(ReplaceCommand.class);
+      replListener(cache2).expect(ReplaceCommand.class);
       cache1.replace("key", "valueN", "value1");
-      r.waitForRPC();
+      replListener(cache2).waitForRPC();
 
       assert cache1.get("key").equals("value1");
       assert cache2.get("key").equals("value1");

Modified: core/branches/flat/src/test/java/org/horizon/replication/ReplicationExceptionTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/ReplicationExceptionTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/replication/ReplicationExceptionTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -8,7 +8,6 @@
 package org.horizon.replication;
 
 import org.horizon.AdvancedCache;
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.commands.VisitableCommand;
 import org.horizon.config.Configuration;
@@ -16,11 +15,11 @@
 import org.horizon.interceptors.base.CommandInterceptor;
 import org.horizon.lock.IsolationLevel;
 import org.horizon.lock.TimeoutException;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.assertNotNull;
 import static org.testng.AssertJUnit.fail;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import javax.transaction.NotSupportedException;
@@ -31,12 +30,11 @@
 import java.io.Serializable;
 import java.util.List;
 
- at Test(groups = "functional", sequential = true)
-public class ReplicationExceptionTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "replication.ReplicationExceptionTest")
+public class ReplicationExceptionTest extends MultipleCacheManagersTest {
    private AdvancedCache cache1, cache2;
 
-   @BeforeMethod
-   public void setUp() {
+   protected void createCaches() throws Throwable {
       Configuration configuration = new Configuration();
 
       configuration.setCacheMode(Configuration.CacheMode.REPL_SYNC);

Modified: core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -7,7 +7,6 @@
  */
 package org.horizon.replication;
 
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.CacheException;
 import org.horizon.config.Configuration;
@@ -19,10 +18,10 @@
 import org.horizon.notifications.cachelistener.annotation.CacheEntryRemoved;
 import org.horizon.notifications.cachelistener.event.Event;
 import org.horizon.notifications.cachelistener.event.TransactionalEvent;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import static org.testng.AssertJUnit.*;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import javax.transaction.Transaction;
@@ -33,13 +32,12 @@
 /**
  * Test out the CacheListener
  */
- at Test(groups = "functional", sequential = true)
-public class SyncCacheListenerTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "replication.SyncCacheListenerTest")
+public class SyncCacheListenerTest extends MultipleCacheManagersTest {
    private Cache<Object, Object> cache1, cache2;
    private final static Log log = LogFactory.getLog(SyncCacheListenerTest.class);
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() throws Exception {
+   protected void createCaches() throws Throwable {
       Configuration conf = new Configuration();
       conf.setSyncCommitPhase(true);
       conf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
@@ -51,7 +49,6 @@
 
       cache1 = caches.get(0);
       cache2 = caches.get(1);
-      TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
    }
 
    public void testSyncTxRepl() throws Exception {

Modified: core/branches/flat/src/test/java/org/horizon/replication/SyncReplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/SyncReplTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/replication/SyncReplTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -7,21 +7,19 @@
 package org.horizon.replication;
 
 import static org.easymock.EasyMock.*;
-import org.horizon.BaseClusteredTest;
 import org.horizon.Cache;
 import org.horizon.commands.RPCCommand;
 import org.horizon.config.Configuration;
-import org.horizon.manager.CacheManager;
 import org.horizon.remoting.RPCManager;
 import org.horizon.remoting.RPCManagerImpl;
 import org.horizon.remoting.ResponseFilter;
 import org.horizon.remoting.ResponseMode;
 import org.horizon.remoting.transport.Address;
 import org.horizon.remoting.transport.Transport;
-import org.horizon.util.TestingUtil;
+import org.horizon.test.MultipleCacheManagersTest;
+import org.horizon.test.TestingUtil;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertNull;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.Collections;
@@ -31,25 +29,18 @@
 /**
  * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
  */
- at Test(groups = "functional", sequential = true)
-public class SyncReplTest extends BaseClusteredTest {
+ at Test(groups = "functional", testName = "replication.SyncReplTest")
+public class SyncReplTest extends MultipleCacheManagersTest {
    Cache cache1, cache2;
    String k = "key", v = "value";
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() {
-      CacheManager cm1 = addClusterEnabledCacheManager();
-      CacheManager cm2 = addClusterEnabledCacheManager();
-
+   protected void createCaches() throws Throwable {
       Configuration replSync = new Configuration();
       replSync.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+      createClusteredCaches(2, "replSync", replSync);
 
-      defineCacheOnAllManagers("replSync", replSync);
-
-      cache1 = cm1.getCache("replSync");
-      cache2 = cm2.getCache("replSync");
-
-      TestingUtil.blockUntilViewsReceived(60000, true, cm1, cm2);
+      cache1 = manager(0).getCache("replSync");
+      cache2 = manager(1).getCache("replSync");
    }
 
    public void testBasicOperation() {
@@ -73,27 +64,30 @@
       assert cache1.isEmpty();
       assert cache2.isEmpty();
 
-      List<CacheManager> managers = getCacheManagers();
       Configuration newConf = new Configuration();
       newConf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
       defineCacheOnAllManagers("newCache", newConf);
-      Cache altCache1 = managers.get(0).getCache("newCache");
-      Cache altCache2 = managers.get(1).getCache("newCache");
+      Cache altCache1 = manager(0).getCache("newCache");
+      Cache altCache2 = manager(1).getCache("newCache");
 
-      assert altCache1.isEmpty();
-      assert altCache2.isEmpty();
+      try {
+         assert altCache1.isEmpty();
+         assert altCache2.isEmpty();
 
-      cache1.put(k, v);
-      assert cache1.get(k).equals(v);
-      assert cache2.get(k).equals(v);
-      assert altCache1.isEmpty();
-      assert altCache2.isEmpty();
+         cache1.put(k, v);
+         assert cache1.get(k).equals(v);
+         assert cache2.get(k).equals(v);
+         assert altCache1.isEmpty();
+         assert altCache2.isEmpty();
 
-      altCache1.put(k, "value2");
-      assert altCache1.get(k).equals("value2");
-      assert altCache2.get(k).equals("value2");
-      assert cache1.get(k).equals(v);
-      assert cache2.get(k).equals(v);
+         altCache1.put(k, "value2");
+         assert altCache1.get(k).equals("value2");
+         assert altCache2.get(k).equals("value2");
+         assert cache1.get(k).equals(v);
+         assert cache2.get(k).equals(v);
+      } finally {
+         removeCacheFromCluster("newCache");
+      }
    }
 
    public void testReplicateToNonExistentCache() {
@@ -101,36 +95,38 @@
       assert cache1.isEmpty();
       assert cache2.isEmpty();
 
-      List<CacheManager> managers = getCacheManagers();
       Configuration newConf = new Configuration();
       newConf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
-      defineCacheOnAllManagers("newCache", newConf);
-      Cache altCache1 = managers.get(0).getCache("newCache");
+      defineCacheOnAllManagers("newCache2", newConf);
+      Cache altCache1 = manager(0).getCache("newCache2");
 
-      assert altCache1.isEmpty();
+      try {
+         assert altCache1.isEmpty();
 
-      cache1.put(k, v);
-      assert cache1.get(k).equals(v);
-      assert cache2.get(k).equals(v);
-      assert altCache1.isEmpty();
+         cache1.put(k, v);
+         assert cache1.get(k).equals(v);
+         assert cache2.get(k).equals(v);
+         assert altCache1.isEmpty();
 
-      altCache1.put(k, "value2");
-      assert altCache1.get(k).equals("value2");
-      assert cache1.get(k).equals(v);
-      assert cache2.get(k).equals(v);
+         altCache1.put(k, "value2");
+         assert altCache1.get(k).equals("value2");
+         assert cache1.get(k).equals(v);
+         assert cache2.get(k).equals(v);
 
-      managers.get(0).getCache("newCache").get(k).equals("value2");
+         assert manager(0).getCache("newCache2").get(k).equals("value2");
+      } finally {
+         removeCacheFromCluster("newCache2");
+      }
    }
 
    public void testMixingSyncAndAsyncOnSameTransport() throws Exception {
-      List<CacheManager> managers = getCacheManagers();
       Transport originalTransport = null;
       RPCManagerImpl rpcManager = null;
       try {
          Configuration asyncCache = new Configuration();
          asyncCache.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
          defineCacheOnAllManagers("asyncCache", asyncCache);
-         Cache asyncCache1 = managers.get(0).getCache("asyncCache");
+         Cache asyncCache1 = manager(0).getCache("asyncCache");
 
          // replace the transport with a mock object
          Transport mockTransport = createMock(Transport.class);

Modified: core/branches/flat/src/test/java/org/horizon/replication/SyncReplicatedAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/SyncReplicatedAPITest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/replication/SyncReplicatedAPITest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -2,7 +2,7 @@
 
 import org.testng.annotations.Test;
 
- at Test(groups = "functional", sequential = true)
+ at Test(groups = "functional", testName = "replication.SyncReplicatedAPITest")
 public class SyncReplicatedAPITest extends BaseReplicatedAPITest {
    public SyncReplicatedAPITest() {
       isSync = true;

Added: core/branches/flat/src/test/java/org/horizon/test/AbstractCacheTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/AbstractCacheTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/AbstractCacheTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,83 @@
+package org.horizon.test;
+
+import org.horizon.AdvancedCache;
+import org.horizon.Cache;
+import org.horizon.context.InvocationContext;
+import org.horizon.container.DataContainer;
+import org.horizon.lifecycle.ComponentStatus;
+import org.horizon.loader.CacheLoaderManager;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+
+import javax.transaction.TransactionManager;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Base class for {@link org.horizon.test.SingleCacheManagerTest} and {@link org.horizon.test.MultipleCacheManagersTest}.
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+public class AbstractCacheTest {
+   /**
+    * Importnat: do not reset RegionManager (rm.reset()) here, as this woulfd cause eviction region to be clered. If
+    * that is needed, do it in @BeforeMethods
+    */
+   public void clearContent(CacheManager cacheManager) {
+      Set<Cache> runningCaches = getRunningCaches(cacheManager);
+      for (Cache cache : runningCaches) {
+         clearRunningTx(cache);
+      }
+      if (!cacheManager.getStatus().allowInvocations()) return;
+      for (Cache cache : runningCaches) {
+         removeInMemoryData(cache);
+         clearCacheLoader(cache);
+         InvocationContext invocationContext = ((AdvancedCache) cache).getInvocationContextContainer().get();
+         if (invocationContext != null) invocationContext.reset();
+      }
+   }
+
+   @SuppressWarnings(value = "unchecked")
+   private Set<Cache> getRunningCaches(CacheManager cacheManager) {
+      ConcurrentMap<String, Cache> caches = (ConcurrentMap<String, Cache>) TestingUtil.extractField(DefaultCacheManager.class, cacheManager, "caches");
+      Set<Cache> result = new HashSet<Cache>();
+      for (Cache cache : caches.values()) {
+         if (cache.getStatus() == ComponentStatus.RUNNING)
+            result.add(cache);
+      }
+      return result;
+   }
+
+   private void clearCacheLoader(Cache cache) {
+      CacheLoaderManager cacheLoaderManager = TestingUtil.extractComponent(cache, CacheLoaderManager.class);
+      if (cacheLoaderManager != null && cacheLoaderManager.getCacheStore() != null) {
+         try {
+            cacheLoaderManager.getCacheStore().clear();
+         } catch (Exception e) {
+            throw new RuntimeException(e);
+         }
+      }
+   }
+
+   private void removeInMemoryData(Cache cache) {
+      System.out.println("Cleaning data for cache: " + cache.getName());
+      DataContainer dataContainer = TestingUtil.extractComponent(cache, DataContainer.class);
+      System.out.println("AbstractCacheTest.removeInMemoryData--> dataContainerBefore==" + dataContainer);
+      dataContainer.clear();
+      System.out.println("AbstractCacheTest.removeInMemoryData--> dataContainerAfter==" + dataContainer);
+   }
+
+   private void clearRunningTx(Cache cache) {
+      if (cache != null) {
+         TransactionManager txm = TestingUtil.getTransactionManager(cache);
+         if (txm == null) return;
+         try {
+            txm.rollback();
+         }
+         catch (Exception e) {
+            // don't care
+         }
+      }
+   }
+}


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

Added: core/branches/flat/src/test/java/org/horizon/test/JGroupsConfigBuilder.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/JGroupsConfigBuilder.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/JGroupsConfigBuilder.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,165 @@
+package org.horizon.test;
+
+import org.horizon.config.parsing.JGroupsStackParser;
+import org.horizon.config.parsing.XmlConfigHelper;
+import org.w3c.dom.Element;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * This class owns the logic of associating network resources(i.e. ports) with threads, in order to make sure that there
+ * won't be any clashes between multiple clusters running in parallel on same host. Used for parallel test suite.
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+public class JGroupsConfigBuilder {
+
+   public static final String JGROUPS_STACK;
+
+   private static String tcpConfig;
+   private static String udpConfig;
+
+   private static final ThreadLocal<String> threadTcpStartPort = new ThreadLocal<String>() {
+      private final AtomicInteger uniqueAddr = new AtomicInteger(7900);
+
+      @Override
+      protected String initialValue() {
+         return uniqueAddr.getAndAdd(50) + "";
+      }
+   };
+
+   /**
+    * Holds unique mcast_addr for each thread used for JGroups channel construction.
+    */
+   private static final ThreadLocal<String> threadMcastIP = new ThreadLocal<String>() {
+      private final AtomicInteger uniqueAddr = new AtomicInteger(11);
+
+      @Override
+      protected String initialValue() {
+         return "228.10.10." + uniqueAddr.getAndIncrement();
+      }
+   };
+
+   /**
+    * Holds unique mcast_port for each thread used for JGroups channel construction.
+    */
+   private static final ThreadLocal<Integer> threadMcastPort = new ThreadLocal<Integer>() {
+      private final AtomicInteger uniquePort = new AtomicInteger(45589);
+
+      @Override
+      protected Integer initialValue() {
+         return uniquePort.getAndIncrement();
+      }
+   };
+
+   private static final Pattern TCP_START_PORT = Pattern.compile("bind_port=[^;]*");
+   private static final Pattern TCP_INITIAL_HOST = Pattern.compile("initial_hosts=[^;]*");
+   private static final Pattern UDP_MCAST_ADDRESS = Pattern.compile("mcast_addr=[^;]*");
+   private static final Pattern UDP_MCAST_PORT = Pattern.compile("mcast_port=[^;]*");
+
+   static {
+      JGROUPS_STACK = System.getProperties().getProperty("jgroups.stack", "tcp");
+      System.out.println("IN USE JGROUPS STACK = " + JGROUPS_STACK);
+   }
+
+   public static String getJGroupsConfig() {
+      if (JGROUPS_STACK.equalsIgnoreCase("tcp")) return getTcpConfig();
+      if (JGROUPS_STACK.equalsIgnoreCase("udp")) return getUdpConfig();
+      throw new IllegalStateException("Unknown protocol stack : " + JGROUPS_STACK);
+   }
+
+   public static String getTcpConfig() {
+      loadTcp();
+      // replace mcast_addr
+      Matcher m = TCP_START_PORT.matcher(tcpConfig);
+      String result;
+      String newStartPort;
+      if (m.find()) {
+         newStartPort = threadTcpStartPort.get();
+         result = m.replaceFirst("start_port=" + newStartPort);
+      } else {
+         System.out.println("Config is:" + tcpConfig);
+         Thread.dumpStack();
+         throw new IllegalStateException();
+      }
+
+      if (result.indexOf("TCPGOSSIP") < 0) //onluy adjust for TCPPING
+      {
+         m = TCP_INITIAL_HOST.matcher(result);
+         if (m.find()) {
+            result = m.replaceFirst("initial_hosts=" + "127.0.0.1[" + newStartPort + "]");
+         }
+      }
+      return result;
+   }
+
+   public static String getUdpConfig() {
+      loadUdp();
+      // replace mcast_addr
+      Matcher m = UDP_MCAST_ADDRESS.matcher(udpConfig);
+      String result;
+      if (m.find()) {
+         String newAddr = threadMcastIP.get();
+         result = m.replaceFirst("mcast_addr=" + newAddr);
+      } else {
+         Thread.dumpStack();
+         throw new IllegalStateException();
+      }
+
+      // replace mcast_port
+      m = UDP_MCAST_PORT.matcher(result);
+      if (m.find()) {
+         String newPort = threadMcastPort.get().toString();
+         result = m.replaceFirst("mcast_port=" + newPort);
+      }
+      return result;
+   }
+
+   private static void loadTcp() {
+      if (tcpConfig != null) return;
+      String xmlString = readFile("stacks/tcp.xml");
+      tcpConfig = getJgroupsConfig(xmlString);
+   }
+
+   private static void loadUdp() {
+      if (udpConfig != null) return;
+      String xmlString = readFile("stacks/udp.xml");
+      udpConfig = getJgroupsConfig(xmlString);
+   }
+
+   private static String getJgroupsConfig(String xmlString) {
+      try {
+         Element e = XmlConfigHelper.stringToElement(xmlString);
+         JGroupsStackParser parser = new JGroupsStackParser();
+         return parser.parseClusterConfigXml(e);
+      } catch (Exception ex) {
+         throw new RuntimeException("Unexpected!", ex);
+      }
+   }
+
+   private static String readFile(String fileName) {
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      InputStream is = cl.getResourceAsStream(fileName);
+      BufferedReader bf = new BufferedReader(new InputStreamReader(is));
+      StringBuilder result = new StringBuilder();
+      String line;
+      try {
+         while ((line = bf.readLine()) != null) result.append(line);
+      } catch (IOException e) {
+         throw new RuntimeException("Unexpected!", e);
+      } finally {
+         try {
+            bf.close();
+         } catch (IOException e) {
+            e.printStackTrace();
+         }
+      }
+      return result.toString();
+   }
+}


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

Added: core/branches/flat/src/test/java/org/horizon/test/MultipleCacheManagersTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/MultipleCacheManagersTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/MultipleCacheManagersTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,117 @@
+package org.horizon.test;
+
+import org.horizon.Cache;
+import org.horizon.config.Configuration;
+import org.horizon.manager.CacheManager;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.IdentityHashMap;
+import java.util.List;
+
+/**
+ * Base class for tests that operates on clusters of caches. The way tests extending this class operates is:
+ * <pre>
+ *    1) created cache managers before tests start. The cache managers are only created once
+ *    2) after each test method runs, the cache managers are being cleared
+ *    3) next test method will run on same cacheManager instance. This way the test is much faster, as CacheManagers
+ *       are expensive to create.
+ * </pre>
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = {"functional", "unit"})
+public abstract class MultipleCacheManagersTest extends AbstractCacheTest {
+
+   private List<CacheManager> cacheManagers = new ArrayList<CacheManager>();
+
+   private IdentityHashMap<Cache, ReplListener> listeners = new IdentityHashMap<Cache, ReplListener>();
+
+   @BeforeClass
+   public void create() throws Throwable {
+      createCaches();
+   }
+
+   @AfterClass
+   protected void destroy() {
+      TestingUtil.killCacheManagers(cacheManagers);
+   }
+
+   @AfterMethod
+   protected void clearContent() throws Throwable {
+      System.out.println("MultipleCacheManagersTest.clearContent");
+      if (cacheManagers.isEmpty())
+         throw new IllegalStateException("No caches registered! Use registerCacheManager(Cache... caches) do that!");
+      for (CacheManager cacheManager : cacheManagers) {
+         super.clearContent(cacheManager);
+      }
+   }
+
+   final protected void registerCaches(CacheManager... cacheManagers) {
+      this.cacheManagers.addAll(Arrays.asList(cacheManagers));
+   }
+
+   /**
+    * Creates a new cache manager, starts it, and adds it to the list of known cache managers on the current thread.
+    * Uses a default clustered cache manager global config.
+    *
+    * @return the new CacheManager
+    */
+   protected CacheManager addClusterEnabledCacheManager() {
+      CacheManager cm = TestingUtil.createClusteredCacheManager();
+      cacheManagers.add(cm);
+      return cm;
+   }
+
+   protected void defineCacheOnAllManagers(String cacheName, Configuration c) {
+      for (CacheManager cm : cacheManagers) {
+         cm.defineCache(cacheName, c);
+      }
+   }
+
+   protected List<Cache> createClusteredCaches(int numMembersInCluster, String cacheName, Configuration c) {
+      List<Cache> caches = new ArrayList<Cache>(numMembersInCluster);
+      for (int i = 0; i < numMembersInCluster; i++) {
+         CacheManager cm = addClusterEnabledCacheManager();
+         cm.defineCache(cacheName, c);
+         caches.add(cm.getCache(cacheName));
+      }
+      TestingUtil.blockUntilViewsReceived(10000, caches);
+      return caches;
+   }
+
+   public ReplListener replListener(Cache cache) {
+      ReplListener listener = listeners.get(cache);
+      if (listener == null) {
+         listener = new ReplListener(cache);
+         listeners.put(cache, listener);
+      }
+      return listener;
+   }
+
+   public CacheManager manager(int i) {
+      return cacheManagers.get(i);
+   }
+
+   protected Cache cache(int managerIndex, String cacheName) {
+      return manager(managerIndex).getCache(cacheName);
+   }
+
+   protected void assertClusterSize(String message, int size) {
+      for (CacheManager cm : cacheManagers) {
+         assert cm.getMembers() != null && cm.getMembers().size() == size : message;
+      }
+   }
+
+   protected void removeCacheFromCluster(String cacheName) {
+      for (CacheManager cm : cacheManagers) {
+         TestingUtil.killCaches(cm.getCache(cacheName));
+      }
+   }
+
+   protected abstract void createCaches() throws Throwable;
+}


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

Added: core/branches/flat/src/test/java/org/horizon/test/ReplListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/ReplListener.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/ReplListener.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,127 @@
+package org.horizon.test;
+
+import org.horizon.Cache;
+import org.horizon.context.InvocationContext;
+import org.horizon.interceptors.base.CommandInterceptor;
+import org.horizon.commands.VisitableCommand;
+import org.horizon.commands.DataCommand;
+import org.horizon.commands.tx.PrepareCommand;
+import org.horizon.commands.tx.CommitCommand;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A listener that listens for replication events on a cache it is watching.  Typical usage: <code> ReplListener r =
+ * attachReplicationListener(cache); r.expect(RemoveCommand.class); // ... r.waitForRPC(); </code>
+ */
+public class ReplListener {
+   Cache c;
+   Set<Class<? extends VisitableCommand>> expectedCommands;
+   CountDownLatch latch = new CountDownLatch(1);
+
+   public ReplListener(Cache c) {
+      this.c = c;
+      this.c.getAdvancedCache().addInterceptor(new ReplListenerInterceptor(), 0);
+   }
+
+   /**
+    * Expects any commands.  The moment a single command is detected, the {@link #waitForRPC()} command will be
+    * unblocked.
+    */
+   public void expectAny() {
+      expect();
+   }
+
+   /**
+    * Expects a specific set of commands, within transactional scope (i.e., as a payload to a PrepareCommand).  If the
+    * cache mode is synchronous, a CommitCommand is expected as well.
+    *
+    * @param commands commands to expect (not counting transaction boundary commands like PrepareCommand and
+    *                 CommitCommand)
+    */
+   public void expectWithTx(Class<? extends VisitableCommand>... commands) {
+      expect(PrepareCommand.class);
+      expect(commands);
+      //this is because for async replication we have an 1pc transaction
+      if (c.getConfiguration().getCacheMode().isSynchronous()) expect(CommitCommand.class);
+   }
+
+   /**
+    * Expects any commands, within transactional scope (i.e., as a payload to a PrepareCommand).  If the cache mode is
+    * synchronous, a CommitCommand is expected as well.
+    */
+   public void expectAnyWithTx() {
+      expect(PrepareCommand.class);
+      //this is because for async replication we have an 1pc transaction
+      if (c.getConfiguration().getCacheMode().isSynchronous()) expect(CommitCommand.class);
+   }
+
+   /**
+    * Expects a specific set of commands.  {@link #waitForRPC()} will block until all of these commands are detected.
+    *
+    * @param expectedCommands commands to expect
+    */
+   public void expect(Class<? extends VisitableCommand>... expectedCommands) {
+      if (this.expectedCommands == null) {
+         this.expectedCommands = new HashSet<Class<? extends VisitableCommand>>();
+      }
+      this.expectedCommands.addAll(Arrays.asList(expectedCommands));
+   }
+
+   /**
+    * Blocks for a predefined amount of time (120 Seconds) until commands defined in any of the expect*() methods have
+    * been detected.  If the commands have not been detected by this time, an exception is thrown.
+    */
+   public void waitForRPC() {
+      waitForRPC(120, TimeUnit.SECONDS);
+   }
+
+   /**
+    * The same as {@link #waitForRPC()} except that you are allowed to specify the max wait time.
+    */
+   public void waitForRPC(long time, TimeUnit unit) {
+      assert expectedCommands != null : "there are no replication expectations; please use ReplListener.expect() before calling this method";
+      try {
+         if (!latch.await(time, unit)) {
+            assert false : "Waiting for more than " + time + " " + unit + " and following commands did not replicate: " + expectedCommands;
+         }
+      }
+      catch (InterruptedException e) {
+         throw new IllegalStateException("unexpected", e);
+      }
+      finally {
+         expectedCommands = null;
+         latch = new CountDownLatch(1);
+      }
+   }
+
+   protected class ReplListenerInterceptor extends CommandInterceptor {
+      @Override
+      protected Object handleDefault(InvocationContext ctx, VisitableCommand cmd) throws Throwable {
+         // first pass up chain
+         Object o = invokeNextInterceptor(ctx, cmd);
+         markAsVisited(cmd);
+         return o;
+      }
+
+      @Override
+      public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand cmd) throws Throwable {
+         // first pass up chain
+         Object o = invokeNextInterceptor(ctx, cmd);
+         markAsVisited(cmd);
+         for (DataCommand mod : cmd.getModifications()) markAsVisited(mod);
+         return o;
+      }
+
+      private void markAsVisited(VisitableCommand cmd) {
+         if (expectedCommands != null) {
+            expectedCommands.remove(cmd.getClass());
+            if (expectedCommands.isEmpty()) latch.countDown();
+         }
+      }
+   }
+}


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

Added: core/branches/flat/src/test/java/org/horizon/test/SingleCacheManagerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/SingleCacheManagerTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/SingleCacheManagerTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,51 @@
+package org.horizon.test;
+
+import org.horizon.Cache;
+import org.horizon.manager.CacheManager;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+
+/**
+ * Base class for tests that operate on a single (most likely local) cache instance.
+ * This operates similar to {@link org.horizon.test.MultipleCacheManagersTest}, but on only once CacheManager.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @see org.horizon.test.MultipleCacheManagersTest
+ */
+public abstract class SingleCacheManagerTest extends AbstractCacheTest {
+   protected CacheManager cacheManager;
+   protected Cache cache;
+
+   /**
+    * This method will always be called before {@link #create()}.  If you override this, make sure you annotate the
+    * overridden method with {@link org.testng.annotations.BeforeClass}.
+    *
+    * @throws Exception Just in case
+    */
+   @BeforeClass
+   public void preCreate() throws Exception {
+      // no op, made for overriding.
+   }
+
+   // Due to some weirdness with TestNG, it always appends the package and class name to the method names
+   // provided on dependsOnMethods unless it thinks there already is a package.  This does accept regular expressions
+   // though so .*. works.  Otherwise it won't detect overridden methods in subclasses.
+   @BeforeClass(dependsOnMethods = "org.horizon.*.preCreate")
+   protected void create() throws Exception {
+      cacheManager = createCacheManager();
+   }
+
+   @AfterClass
+   protected void destroy() {
+      TestingUtil.killCacheManagers(cacheManager);
+   }
+
+   @AfterMethod
+   protected void clearContent() {
+      super.clearContent(cacheManager);
+   }
+
+   protected abstract CacheManager createCacheManager() throws Exception;
+
+}


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

Added: core/branches/flat/src/test/java/org/horizon/test/TestNameVerifier.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/TestNameVerifier.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/TestNameVerifier.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,209 @@
+package org.horizon.test;
+
+import org.testng.annotations.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Class that tests that test names are correclty set for each test.
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "test.TestNameVerifier")
+public class TestNameVerifier {
+   String dir = "src/test/java/org/horizon";
+
+   Pattern packageLinePattern = Pattern.compile("package org.horizon[^;]*");
+   Pattern classLinePattern = Pattern.compile("(abstract\\s*)??(public\\s*)(abstract\\s*)??class [^\\s]*");
+   Pattern atAnnotationPattern = Pattern.compile("@Test[^)]*");
+   Pattern testNamePattern = Pattern.compile("testName\\s*=\\s*\"[^\"]*\"");
+
+   String fileCache;
+
+   FilenameFilter javaFilter = new FilenameFilter() {
+      public boolean accept(File dir, String name) {
+         if (dir.getAbsolutePath().contains("testng")) return false;
+         return name.endsWith(".java");
+      }
+   };
+
+   FileFilter onlyDirs = new FileFilter() {
+      public boolean accept(File pathname) {
+         return pathname.isDirectory();
+      }
+   };
+
+   @Test(enabled = false, description = "Do not enable this unless you want your files to be updated with test names!!!")
+   public void process() throws Exception {
+      File[] javaFiles = getJavaFiles();
+      for (File file : javaFiles) {
+         if (needsUpdate(file)) {
+            System.out.println("Updating file: " + file.getAbsolutePath());
+            updateFile(file);
+         }
+      }
+   }
+
+   private void updateFile(File file) throws Exception {
+      String javaString = fileCache;
+      String testName = getTestName(javaString, file.getName());
+      String testNameStr = ", testName = \"" + testName + "\"";
+      javaString = replaceAtTestAnnotation(javaString, testNameStr);
+      persistNewFile(file, javaString);
+   }
+
+   private void persistNewFile(File file, String javaString) throws Exception {
+      if (file.delete()) {
+         System.out.println("!!!!!!!!!! error porcessing file " + file.getName());
+         return;
+      }
+      file.createNewFile();
+      PrintWriter writter = new PrintWriter(file);
+      writter.append(javaString);
+      writter.close();
+   }
+
+   private String replaceAtTestAnnotation(String javaString, String testNameStr) {
+      Matcher matcher = atAnnotationPattern.matcher(javaString);
+      boolean found = matcher.find();
+      assert found;
+      String theMatch = matcher.group();
+      return matcher.replaceFirst(theMatch + testNameStr);
+   }
+
+   private String getTestName(String javaString, String filename) {
+      String classNamePart = getClassNamePart(javaString, filename);
+
+      //abstract classes do not require test names
+      if (classNamePart.indexOf("abstract") >= 0) return null;
+
+      classNamePart = classNamePart.substring("public class ".length());
+      String packagePart = getPackagePart(javaString, filename);
+      //if the test is in org.horizon package then make sure no . is prepanded
+      String packagePrepend = ((packagePart != null) && (packagePart.length() > 0)) ? packagePart + "." : "";
+      return packagePrepend + classNamePart;
+   }
+
+   private String getClassNamePart(String javaString, String filename) {
+      Matcher matcher = classLinePattern.matcher(javaString);
+      boolean found = matcher.find();
+      assert found : "could not determine class name for file: " + filename;
+      return matcher.group();
+   }
+
+   private String getPackagePart(String javaString, String filename) {
+      Matcher matcher = packageLinePattern.matcher(javaString);
+      boolean found = matcher.find();
+      assert found : "Could not determine package name for file: " + filename;
+      String theMatch = matcher.group();
+      String partial = theMatch.substring("package org.horizon".length());
+      if (partial.trim().length() == 0) return partial.trim();
+      return partial.substring(1);//drop the leading dot.
+   }
+
+
+   private boolean needsUpdate(File file) throws Exception {
+      String javaFileStr = getFileAsString(file);
+      if (javaFileStr.indexOf(" testName = \"") > 0) return false;
+      int atTestIndex = javaFileStr.indexOf("@Test");
+      int classDeclarationIndex = javaFileStr.indexOf("public class");
+      return atTestIndex > 0 && atTestIndex < classDeclarationIndex;
+   }
+
+   private String getFileAsString(File file) throws Exception {
+      StringBuilder builder = new StringBuilder();
+      BufferedReader fileReader = new BufferedReader(new FileReader(file));
+      String line;
+      while ((line = fileReader.readLine()) != null) {
+         builder.append(line + "\n");
+      }
+      this.fileCache = builder.toString();
+//      fileReader.close();
+      return fileCache;
+   }
+
+   private File[] getJavaFiles() {
+      File file = new File(dir);
+      assert file.isDirectory();
+      ArrayList<File> result = new ArrayList<File>();
+      addJavaFiles(file, result);
+      return result.toArray(new File[0]);
+   }
+
+   private void addJavaFiles(File file, ArrayList<File> result) {
+      assert file.isDirectory();
+      File[] javaFiles = file.listFiles(javaFilter);
+//      printFiles(javaFiles);
+      result.addAll(Arrays.asList(javaFiles));
+      for (File dir : file.listFiles(onlyDirs)) {
+         addJavaFiles(dir, result);
+      }
+   }
+
+   private void printFiles(File[] javaFiles) {
+      for (File f : javaFiles) {
+         System.out.println(f.getAbsolutePath());
+      }
+   }
+
+   public void verifyTestName() throws Exception {
+      File[] javaFiles = getJavaFiles();
+      StringBuilder errorMessage = new StringBuilder("Following test class(es) do not have an appropriate test name: \n");
+      boolean hasErrors = false;
+      for (File file : javaFiles) {
+         String expectedName = incorrectTestName(file);
+         if (expectedName != null) {
+            errorMessage.append(file.getAbsoluteFile()).append(" expected test name is: '").append(expectedName).append("' \n");
+            hasErrors = true;
+         }
+      }
+      assert !hasErrors : errorMessage.append("The rules for writting UTs are being descibed here: https://www.jboss.org/community/docs/DOC-13315");
+   }
+
+   private String incorrectTestName(File file) throws Exception {
+      String fileAsStr = getFileAsString(file);
+
+      boolean containsTestAnnotation = atAnnotationPattern.matcher(fileAsStr).find();
+      if (!containsTestAnnotation) return null;
+
+      String expectedTestName = getTestName(fileAsStr, file.getName());
+      if (expectedTestName == null) return null; //this happens when the class is abstract
+      Matcher matcher = this.testNamePattern.matcher(fileAsStr);
+      if (!matcher.find()) return expectedTestName;
+      String name = matcher.group().trim();
+      int firstIndexOfQuote = name.indexOf('"');
+      String existingTestName = name.substring(firstIndexOfQuote + 1, name.length() - 1); //to ignore last quote
+      if (!existingTestName.equals(expectedTestName)) return expectedTestName;
+      return null;
+   }
+
+
+//   @Test(enabled = false)
+//   public static void main(String[] args) throws Exception {
+//      File file = new File("C:\\jboss\\brainstoriming\\horizon\\src\\test\\java\\org\\horizon\\api\\tree\\NodeMoveAPITest.java");
+//      String incorrectName = new TestNameVerifier().incorrectTestName(file);
+//      System.out.println("incorrectName = " + incorrectName);
+
+
+//      new TestNameVerifier().process();
+//      Pattern classLinePattern = Pattern.compile("@Test[^)]*");
+//      String totest = "aaaa\n" + "@Test(groups = {\"functional\", \"pessimistic\"})\n" + "{ dsadsadsa";
+//      Matcher matcher = classLinePattern.matcher(totest);
+//      boolean found = matcher.find();
+//      System.out.println("found = " + found);
+//      String theMatch = matcher.group();
+//      String result = matcher.replaceFirst(theMatch + ", testName=\"alaBala\"");
+//      System.out.println("theMatch = " + theMatch);
+//      System.out.println("result = " + result);
+
+//   }
+}
\ No newline at end of file


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

Added: core/branches/flat/src/test/java/org/horizon/test/TestingUtil.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/TestingUtil.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/TestingUtil.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,639 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.horizon.test;
+
+import org.horizon.AdvancedCache;
+import org.horizon.Cache;
+import org.horizon.CacheDelegate;
+import org.horizon.config.GlobalConfiguration;
+import org.horizon.commands.CommandsFactory;
+import org.horizon.commands.VisitableCommand;
+import org.horizon.factories.ComponentRegistry;
+import org.horizon.factories.GlobalComponentRegistry;
+import org.horizon.interceptors.InterceptorChain;
+import org.horizon.interceptors.base.CommandInterceptor;
+import org.horizon.lifecycle.ComponentStatus;
+import org.horizon.lock.LockManager;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+import org.horizon.remoting.transport.Address;
+import org.horizon.remoting.transport.jgroups.JGroupsTransport;
+import org.horizon.tree.TreeCache;
+
+import javax.transaction.TransactionManager;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Random;
+import java.util.Properties;
+
+/**
+ * Utilities for unit testing JBossCache.
+ *
+ * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
+ * @since 1.0
+ */
+public class TestingUtil {
+   private static Random random = new Random();
+   public static final String TEST_FILES = "testFiles";
+
+   /**
+    * Extracts the value of a field in a given target instance using reflection, able to extract private fields as
+    * well.
+    *
+    * @param target    object to extract field from
+    * @param fieldName name of field to extract
+    * @return field value
+    */
+   public static Object extractField(Object target, String fieldName) {
+      return extractField(target.getClass(), target, fieldName);
+   }
+
+   public static void replaceField(Object newValue, String fieldName, Object owner, Class baseType) {
+      Field field;
+      try {
+         field = baseType.getDeclaredField(fieldName);
+         field.setAccessible(true);
+         field.set(owner, newValue);
+      }
+      catch (Exception e) {
+         throw new RuntimeException(e);//just to simplify exception handeling
+      }
+   }
+
+
+   public static Object extractField(Class type, Object target, String fieldName) {
+      Field field;
+      try {
+         field = type.getDeclaredField(fieldName);
+         field.setAccessible(true);
+         return field.get(target);
+      }
+      catch (Exception e) {
+         if (type.equals(Object.class)) {
+            e.printStackTrace();
+            return null;
+         } else {
+            // try with superclass!!
+            return extractField(type.getSuperclass(), target, fieldName);
+         }
+      }
+   }
+
+   public static <T extends CommandInterceptor> T findInterceptor(Cache<?, ?> cache, Class<T> interceptorToFind) {
+      for (CommandInterceptor i : cache.getAdvancedCache().getInterceptorChain()) {
+         if (interceptorToFind.isInstance(i)) return interceptorToFind.cast(i);
+      }
+      return null;
+   }
+
+   /**
+    * Loops, continually calling {@link #areCacheViewsComplete(Cache[])} until it either returns true or
+    * <code>timeout</code> ms have elapsed.
+    *
+    * @param caches  caches which must all have consistent views
+    * @param timeout max number of ms to loop
+    * @throws RuntimeException if <code>timeout</code> ms have elapse without all caches having the same number of
+    *                          members.
+    */
+   public static void blockUntilViewsReceived(Cache[] caches, long timeout) {
+      long failTime = System.currentTimeMillis() + timeout;
+
+      while (System.currentTimeMillis() < failTime) {
+         sleepThread(100);
+         if (areCacheViewsComplete(caches)) {
+            return;
+         }
+      }
+
+      throw new RuntimeException("timed out before caches had complete views");
+   }
+
+   /**
+    * Version of blockUntilViewsReceived that uses varargs
+    */
+   public static void blockUntilViewsReceived(long timeout, Cache... caches) {
+      blockUntilViewsReceived(caches, timeout);
+   }
+
+   /**
+    * Version of blockUntilViewsReceived that uses varargsa and cache managers
+    */
+   public static void blockUntilViewsReceived(long timeout, CacheManager... cacheManagers) {
+      blockUntilViewsReceived(timeout, true, cacheManagers);
+   }
+
+   /**
+    * Waits for the given memebrs to be removed from the cluster. The difference between this and
+    * {@link #blockUntilViewsReceived(long, org.horizon.manager.CacheManager[])} methods(s) is that it does not barf if
+    * more than expected memebers is in the cluster - this is because we expect to start with a grater number fo memebers
+    * than we eventually expect. It will barf though, if the number of members is not the one expected but only after the 
+    * timeout expieres.
+    */
+   public static void blockForMemberToFail(long timeout, CacheManager... cacheManagers) {
+      blockUntilViewsReceived(timeout, false, cacheManagers);
+      areCacheViewsComplete(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.
+    *
+    * @param caches  caches which must all have consistent views
+    * @param timeout max number of ms to loop
+    * @throws RuntimeException if <code>timeout</code> ms have elapse without all caches having the same number of
+    *                          members.
+    */
+//   public static void blockUntilViewsReceived(Cache[] caches, long timeout) {
+//      long failTime = System.currentTimeMillis() + timeout;
+//
+//      while (System.currentTimeMillis() < failTime) {
+//         sleepThread(100);
+//         if (areCacheViewsComplete(caches)) {
+//            return;
+//         }
+//      }
+//
+//      throw new RuntimeException("timed out before caches had complete views");
+//   }
+
+
+   /**
+    * An overloaded version of {@link #blockUntilViewsReceived(long,Cache[])} that allows for 'shrinking' clusters.
+    * I.e., the usual method barfs if there are more members than expected.  This one takes a param
+    * (barfIfTooManyMembers) which, if false, will NOT barf but will wait until the cluster 'shrinks' to the desired
+    * size.  Useful if in tests, you kill a member and want to wait until this fact is known across the cluster.
+    *
+    * @param timeout
+    * @param barfIfTooManyMembers
+    * @param caches
+    */
+   public static void blockUntilViewsReceived(long timeout, boolean barfIfTooManyMembers, Cache... caches) {
+      long failTime = System.currentTimeMillis() + timeout;
+
+      while (System.currentTimeMillis() < failTime) {
+         sleepThread(100);
+         if (areCacheViewsComplete(caches, barfIfTooManyMembers)) {
+            return;
+         }
+      }
+
+      throw new RuntimeException("timed out before caches had complete views");
+   }
+
+   /**
+    * Loops, continually calling {@link #areCacheViewsComplete(Cache[])} until it either returns true or
+    * <code>timeout</code> ms have elapsed.
+    *
+    * @param groupSize number of caches expected in the group
+    * @param timeout   max number of ms to loop
+    * @throws RuntimeException if <code>timeout</code> ms have elapse without all caches having the same number of
+    *                          members.
+    */
+   public static void blockUntilViewReceived(Cache cache, int groupSize, long timeout) {
+      blockUntilViewReceived(cache, groupSize, timeout, true);
+   }
+
+   public static void blockUntilViewReceived(Cache cache, int groupSize, long timeout, boolean barfIfTooManyMembersInView) {
+      long failTime = System.currentTimeMillis() + timeout;
+
+      while (System.currentTimeMillis() < failTime) {
+         sleepThread(100);
+         if (isCacheViewComplete(cache.getCacheManager().getMembers(), cache.getCacheManager().getAddress(), groupSize, barfIfTooManyMembersInView)) {
+            return;
+         }
+      }
+
+      throw new RuntimeException("timed out before caches had complete views");
+   }
+
+   /**
+    * Checks each cache to see if the number of elements in the array returned by {@link CacheManager#getMembers()}
+    * matches the size of the <code>caches</code> parameter.
+    *
+    * @param caches caches that should form a View
+    * @return <code>true</code> if all caches have <code>caches.length</code> members; false otherwise
+    * @throws IllegalStateException if any of the caches have MORE view members than caches.length
+    */
+   public static boolean areCacheViewsComplete(Cache[] caches) {
+      return areCacheViewsComplete(caches, true);
+   }
+
+   public static boolean areCacheViewsComplete(Cache[] caches, boolean barfIfTooManyMembers) {
+      int memberCount = caches.length;
+
+      for (int i = 0; i < memberCount; i++) {
+         if (!isCacheViewComplete(caches[i].getCacheManager().getMembers(), caches[i].getCacheManager().getAddress(), memberCount, barfIfTooManyMembers)) {
+            return false;
+         }
+      }
+
+      return true;
+   }
+
+   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
+//    */
+//   public static boolean isCacheViewComplete(Cache cache, int memberCount) {
+//      List members = cache.getCacheManager().getMembers();
+//      if (members == null || memberCount > members.size()) {
+//         return false;
+//      } else if (memberCount < members.size()) {
+//         // This is an exceptional condition
+//         StringBuilder sb = new StringBuilder("Cache at address ");
+//         sb.append(cache.getCacheManager().getAddress());
+//         sb.append(" had ");
+//         sb.append(members.size());
+//         sb.append(" members; expecting ");
+//         sb.append(memberCount);
+//         sb.append(". Members were (");
+//         for (int j = 0; j < members.size(); j++) {
+//            if (j > 0) {
+//               sb.append(", ");
+//            }
+//            sb.append(members.get(j));
+//         }
+//         sb.append(')');
+//
+//         throw new IllegalStateException(sb.toString());
+//      }
+//
+//      return true;
+//   }
+
+   /**
+    * @param c
+    * @param memberCount
+    */
+   public static boolean isCacheViewComplete(Cache c, int memberCount) {
+      return isCacheViewComplete(c.getCacheManager().getMembers(), c.getCacheManager().getAddress(), memberCount, true);
+   }
+
+   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(address);
+            sb.append(" had ");
+            sb.append(members.size());
+            sb.append(" members; expecting ");
+            sb.append(memberCount);
+            sb.append(". Members were (");
+            for (int j = 0; j < members.size(); j++) {
+               if (j > 0) {
+                  sb.append(", ");
+               }
+               sb.append(members.get(j));
+            }
+            sb.append(')');
+
+            throw new IllegalStateException(sb.toString());
+         } else return false;
+      }
+
+      return true;
+   }
+
+
+   /**
+    * Puts the current thread to sleep for the desired number of ms, suppressing any exceptions.
+    *
+    * @param sleeptime number of ms to sleep
+    */
+   public static void sleepThread(long sleeptime) {
+      try {
+         Thread.sleep(sleeptime);
+      }
+      catch (InterruptedException ie) {
+      }
+   }
+
+   public static void sleepRandom(int maxTime) {
+      sleepThread(random.nextInt(maxTime));
+   }
+
+   public static void recursiveFileRemove(String directoryName) {
+      File file = new File(directoryName);
+      recursiveFileRemove(file);
+   }
+
+   public static void recursiveFileRemove(File file) {
+      if (file.exists()) {
+         System.out.println("Deleting file " + file);
+         recursivedelete(file);
+      }
+   }
+
+   private static void recursivedelete(File f) {
+      if (f.isDirectory()) {
+         File[] files = f.listFiles();
+         for (File file : files) {
+            recursivedelete(file);
+         }
+      }
+      //System.out.println("File " + f.toURI() + " deleted = " + f.delete());
+      f.delete();
+   }
+
+   public static void killTreeCaches(Collection treeCaches) {
+      if (treeCaches != null) killTreeCaches((TreeCache[]) treeCaches.toArray(new TreeCache[]{}));
+   }
+
+   public static void killCaches(Collection caches) {
+      if (caches != null) killCaches((Cache[]) caches.toArray(new Cache[]{}));
+   }
+
+   public static void killTreeCaches(TreeCache... treeCaches) {
+      for (TreeCache tc : treeCaches) {
+         if (tc != null) killCaches(tc.getCache());
+      }
+   }
+
+   public static void killCacheManagers(CacheManager... cacheManagers) {
+      if (cacheManagers != null) {
+         for (CacheManager cm : cacheManagers) {
+            if (cm != null) cm.stop();
+         }
+      }
+   }
+
+   public static void killCacheManagers(Collection<CacheManager> cacheManagers) {
+      killCacheManagers(cacheManagers.toArray(new CacheManager[cacheManagers.size()]));
+   }
+
+   /**
+    * Kills a cache - stops it, clears any data in any cache loaders, and rolls back any associated txs
+    */
+   public static void killCaches(Cache... caches) {
+      for (Cache c : caches) {
+         try {
+            if (c != null && c.getStatus() == ComponentStatus.RUNNING) {
+               TransactionManager tm = getTransactionManager(c);
+               if (tm != null) {
+                  try {
+                     tm.rollback();
+                  }
+                  catch (Exception e) {
+                     // don't care
+                  }
+               }
+               c.stop();
+            }
+         }
+         catch (Throwable t) {
+
+         }
+      }
+   }
+
+   /**
+    * Clears transaction with the current thread in the given transaction manager.
+    *
+    * @param txManager a TransactionManager to be cleared
+    */
+   public static void killTransaction(TransactionManager txManager) {
+      if (txManager != null) {
+         try {
+            txManager.rollback();
+         }
+         catch (Exception e) {
+            // don't care
+         }
+      }
+   }
+
+
+   /**
+    * Clears any associated transactions with the current thread in the caches' transaction managers.
+    */
+   public static void killTransactions(Cache... caches) {
+      for (Cache c : caches) {
+         if (c != null && c.getStatus() == ComponentStatus.RUNNING) {
+            TransactionManager tm = getTransactionManager(c);
+            if (tm != null) {
+               try {
+                  tm.rollback();
+               }
+               catch (Exception e) {
+                  // don't care
+               }
+            }
+         }
+      }
+   }
+
+   /**
+    * For testing only - introspects a cache and extracts the ComponentRegistry
+    *
+    * @param cache cache to introspect
+    * @return component registry
+    */
+   public static ComponentRegistry extractComponentRegistry(Cache cache) {
+      return (ComponentRegistry) extractField(cache, "componentRegistry");
+   }
+
+   public static GlobalComponentRegistry extractGlobalComponentRegistry(CacheManager cacheManager) {
+      return (GlobalComponentRegistry) extractField(cacheManager, "globalComponentRegistry");
+   }
+
+   public static LockManager extractLockManager(Cache cache) {
+      return extractComponentRegistry(cache).getComponent(LockManager.class);
+   }
+
+   /**
+    * For testing only - introspects a cache and extracts the ComponentRegistry
+    *
+    * @param ci interceptor chain to introspect
+    * @return component registry
+    */
+   public static ComponentRegistry extractComponentRegistry(InterceptorChain ci) {
+      return (ComponentRegistry) extractField(ci, "componentRegistry");
+   }
+
+
+   /**
+    * Replaces the existing interceptor chain in the cache wih one represented by the interceptor passed in.  This
+    * utility updates dependencies on all components that rely on the interceptor chain as well.
+    *
+    * @param cache       cache that needs to be altered
+    * @param interceptor the first interceptor in the new chain.
+    */
+   public static void replaceInterceptorChain(Cache<?, ?> cache, CommandInterceptor interceptor) {
+      ComponentRegistry cr = extractComponentRegistry(cache);
+      // make sure all interceptors here are wired.
+      CommandInterceptor i = interceptor;
+      do {
+         cr.wireDependencies(i);
+      }
+      while ((i = i.getNext()) != null);
+
+      InterceptorChain inch = cr.getComponent(InterceptorChain.class);
+      inch.setFirstInChain(interceptor);
+   }
+
+   /**
+    * Retrieves the remote delegate for a given cache.  It is on this remote delegate that the JGroups RPCDispatcher
+    * invokes remote methods.
+    *
+    * @param cache cache instance for which a remote delegate is to be retrieved
+    * @return remote delegate, or null if the cacge is not configured for replication.
+    */
+   public static CacheDelegate getInvocationDelegate(Cache cache) {
+      return (CacheDelegate) cache;
+   }
+
+   /**
+    * Blocks until the cache has reached a specified state.
+    *
+    * @param cache       cache to watch
+    * @param cacheStatus status to wait for
+    * @param timeout     timeout to wait for
+    */
+   public static void blockUntilCacheStatusAchieved(Cache cache, ComponentStatus cacheStatus, long timeout) {
+      AdvancedCache spi = cache.getAdvancedCache();
+      long killTime = System.currentTimeMillis() + timeout;
+      while (System.currentTimeMillis() < killTime) {
+         if (spi.getStatus() == cacheStatus) return;
+         sleepThread(50);
+      }
+      throw new RuntimeException("Timed out waiting for condition");
+   }
+
+   public static void replicateCommand(Cache cache, VisitableCommand command) throws Throwable {
+      ComponentRegistry cr = extractComponentRegistry(cache);
+      InterceptorChain ic = cr.getComponent(InterceptorChain.class);
+      ic.invoke(command);
+   }
+
+   public static void blockUntilViewsReceived(int timeout, List caches) {
+      blockUntilViewsReceived((Cache[]) caches.toArray(new Cache[]{}), timeout);
+   }
+
+
+   public static CommandsFactory extractCommandsFactory(Cache<Object, Object> cache) {
+      return (CommandsFactory) extractField(cache, "commandsFactory");
+   }
+
+   public static void dumpCacheContents(List caches) {
+      System.out.println("**** START: Cache Contents ****");
+      int count = 1;
+      for (Object o : caches) {
+         Cache c = (Cache) o;
+         if (c == null) {
+            System.out.println("  ** Cache " + count + " is null!");
+         } else {
+            System.out.println("  ** Cache " + count + " is " + c.getCacheManager().getAddress());
+         }
+         count++;
+      }
+      System.out.println("**** END: Cache Contents ****");
+   }
+
+   public static void dumpCacheContents(Cache... caches) {
+      dumpCacheContents(Arrays.asList(caches));
+   }
+
+   /**
+    * Extracts a component of a given type from the cache's internal component registry
+    *
+    * @param cache
+    * @param componentType
+    * @param <T>
+    * @return
+    */
+   public static <T> T extractComponent(Cache cache, Class<T> componentType) {
+      ComponentRegistry cr = extractComponentRegistry(cache);
+      return cr.getComponent(componentType);
+   }
+
+   public static TransactionManager getTransactionManager(Cache cache) {
+      return cache == null ? null : extractComponent(cache, TransactionManager.class);
+   }
+
+   /**
+    * Replaces a component in a running cache
+    *
+    * @param cache                cache in which to replace component
+    * @param componentType        component type of which to replace
+    * @param replacementComponent new instance
+    * @param rewire               if true, ComponentRegistry.rewire() is called after replacing.
+    * @return the original component that was replaced
+    */
+   public static <T> T replaceComponent(Cache<?, ?> cache, Class<T> componentType, T replacementComponent, boolean rewire) {
+      ComponentRegistry cr = extractComponentRegistry(cache);
+      T old = cr.getComponent(componentType);
+      cr.registerComponent(replacementComponent, componentType);
+      if (rewire) cr.rewire();
+      return old;
+   }
+
+   /**
+    * Replaces a component in a running cache manager (global component registry)
+    *
+    * @param cacheManager         cache in which to replace component
+    * @param componentType        component type of which to replace
+    * @param replacementComponent new instance
+    * @param rewire               if true, ComponentRegistry.rewire() is called after replacing.
+    * @return the original component that was replaced
+    */
+   public static <T> T replaceComponent(CacheManager cacheManager, Class<T> componentType, T replacementComponent, boolean rewire) {
+      GlobalComponentRegistry cr = extractGlobalComponentRegistry(cacheManager);
+      T old = cr.getComponent(componentType);
+      cr.registerComponent(replacementComponent, componentType);
+      if (rewire) {
+         cr.rewire();
+         cr.rewireNamedRegistries();
+      }
+      return old;
+   }
+
+   public static CacheManager createClusteredCacheManager() {
+      GlobalConfiguration globalConfiguration = GlobalConfiguration.getClusteredDefault();
+      Properties newTransportProps = new Properties();
+      newTransportProps.put(JGroupsTransport.CONFIGURATION_STRING, JGroupsConfigBuilder.getJGroupsConfig());
+      globalConfiguration.setTransportProperties(newTransportProps);
+      return new DefaultCacheManager(globalConfiguration);      
+   }
+
+   public static CacheManager createLocalCacheManager() {
+      GlobalConfiguration globalConfiguration = GlobalConfiguration.getNonClusteredDefault();
+      return new DefaultCacheManager(globalConfiguration);
+   }
+}


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

Added: core/branches/flat/src/test/java/org/horizon/test/testng/SuiteResourcesAndLogTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/testng/SuiteResourcesAndLogTest.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/testng/SuiteResourcesAndLogTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,58 @@
+package org.horizon.test.testng;
+
+import org.horizon.test.TestingUtil;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+import java.io.File;
+
+/**
+ * This class makes sure that all files are being deleted after each test run. It also logs testsuite information. 
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test (groups = "functional", testName = "test.testng.SuiteResourcesAndLogTest")
+public class SuiteResourcesAndLogTest {
+
+   @BeforeSuite
+   public void removeTempDir()
+   {
+      TestingUtil.recursiveFileRemove(TestingUtil.TEST_FILES);
+      System.out.println("Removing all the files from " + TestingUtil.TEST_FILES);
+      File file = new File(TestingUtil.TEST_FILES);
+      if (file.exists())
+      {
+         System.err.println("!!!!!!!!!!!!! Directory '" + TestingUtil.TEST_FILES + "' should have been deleted!!!");
+      }
+      else
+      {
+         System.out.println("Successfully removed folder: '" + TestingUtil.TEST_FILES + "'");
+      }
+   }
+
+   @BeforeSuite
+   @AfterSuite
+   public void printEnvInformation()
+   {
+      System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~ ENVIRONMENT INFO ~~~~~~~~~~~~~~~~~~~~~~~~~~");
+      String bindAddress = System.getProperty("bind.address");
+      System.out.println("bind.address = " + bindAddress);
+//      //todo for some funny reasons MVN ignores bind.address passed in. This is a hack..
+//      if (bindAddress == null)
+//      {
+//         System.out.println("Setting bind.address to 127.0.0.1 as it is missing!!!");
+//         System.setProperty("bind.address","127.0.0.1");
+//      }
+      System.out.println("java.runtime.version = " + System.getProperty("java.runtime.version"));
+      System.out.println("java.runtime.name =" + System.getProperty("java.runtime.name"));
+      System.out.println("java.vm.version = " + System.getProperty("java.vm.version"));
+      System.out.println("java.vm.vendor = " + System.getProperty("java.vm.vendor"));
+      System.out.println("os.name = " + System.getProperty("os.name"));
+      System.out.println("os.version = " + System.getProperty("os.version"));
+      System.out.println("sun.arch.data.model = " + System.getProperty("sun.arch.data.model"));
+      System.out.println("sun.cpu.endian = " + System.getProperty("sun.cpu.endian"));
+      System.out.println("jgroups.stack = " + System.getProperty("jgroups.stack"));
+      System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~ ENVIRONMENT INFO ~~~~~~~~~~~~~~~~~~~~~~~~~~");
+   }
+}


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

Added: core/branches/flat/src/test/java/org/horizon/test/testng/UnitTestTestNGListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/testng/UnitTestTestNGListener.java	                        (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/testng/UnitTestTestNGListener.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,73 @@
+package org.horizon.test.testng;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.testng.IClass;
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+/**
+ * @author dpospisi at redhat.com
+ * @author Mircea.Markus at jboss.com
+ */
+public class UnitTestTestNGListener implements ITestListener {
+
+   /**
+    * Holds test classes actually running in all threads.
+    */
+   private ThreadLocal<IClass> threadTestClass = new ThreadLocal<IClass>();
+   Log log = LogFactory.getLog(UnitTestTestNGListener.class);
+
+   private int failed = 0;
+   private int succeded = 0;
+   private int skipped = 0;
+
+   public void onTestStart(ITestResult res) {
+      log.info("Starting test " + getTestDesc(res));
+      threadTestClass.set(res.getTestClass());
+   }
+
+   synchronized public void onTestSuccess(ITestResult arg0) {
+      System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " succeded.");
+      log.info("Test succeded " + getTestDesc(arg0) + ".");
+      succeded++;
+      printStatus();
+   }
+
+   synchronized public void onTestFailure(ITestResult arg0) {
+      System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " failed.");
+      if (arg0.getThrowable() != null) log.error("Test failed " + getTestDesc(arg0), arg0.getThrowable());
+      failed++;
+      printStatus();
+   }
+
+   synchronized public void onTestSkipped(ITestResult arg0) {
+      System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " skipped.");
+      log.info(" Test " + getTestDesc(arg0) + " skipped.");
+      if (arg0.getThrowable() != null) log.error("Test skipped : " + arg0.getThrowable(), arg0.getThrowable());
+      skipped++;
+      printStatus();
+   }
+
+   public void onTestFailedButWithinSuccessPercentage(ITestResult arg0) {
+   }
+
+   public void onStart(ITestContext arg0) {
+   }
+
+   public void onFinish(ITestContext arg0) {
+   }
+
+   private String getThreadId() {
+      return "[" + Thread.currentThread().getName() + "]";
+   }
+
+   private String getTestDesc(ITestResult res) {
+      return res.getMethod().getMethodName() + "(" + res.getTestClass().getName() + ")";
+   }
+
+   private void printStatus() {
+      System.out.println("Testsuite execution progress: tests succeded " + succeded + ", failed " + failed + ", skipped " + skipped + ".");
+   }
+}


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

Modified: core/branches/flat/src/test/java/org/horizon/tx/LocalModeTxTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/tx/LocalModeTxTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/tx/LocalModeTxTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -22,61 +22,53 @@
 package org.horizon.tx;
 
 import org.horizon.Cache;
-import org.horizon.UnitTestCacheManager;
 import org.horizon.config.Configuration;
+import org.horizon.manager.CacheManager;
+import org.horizon.test.TestingUtil;
+import org.horizon.test.SingleCacheManagerTest;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.Test;
 
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 
- at Test(groups = "functional")
-public class LocalModeTxTest {
-   private Cache<String, String> createCache() {
+ at Test(groups = "functional", testName = "tx.LocalModeTxTest")
+public class LocalModeTxTest extends SingleCacheManagerTest {
+
+   Cache c;
+
+   protected CacheManager createCacheManager() {
       Configuration cfg = new Configuration();
       cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      UnitTestCacheManager cm = new UnitTestCacheManager(cfg);
-      return cm.createCache("test");
+      CacheManager cm = TestingUtil.createLocalCacheManager();
+      cm.defineCache("test", cfg);
+      c = cm.getCache("test");
+      return cm;
    }
 
    public void testTxCommit1() throws Exception {
-      Cache c = null;
-      try {
-         c = createCache();
-         TransactionManager tm = TestingUtil.getTransactionManager(c);
-         tm.begin();
-         c.put("key", "value");
-         Transaction t = tm.suspend();
-         assert c.isEmpty();
-         tm.resume(t);
-         tm.commit();
-         assert !c.isEmpty();
-      }
-      finally {
-         TestingUtil.killCaches(c);
-      }
+      TransactionManager tm = TestingUtil.getTransactionManager(c);
+      tm.begin();
+      c.put("key", "value");
+      Transaction t = tm.suspend();
+      assert c.isEmpty();
+      tm.resume(t);
+      tm.commit();
+      assert !c.isEmpty();
    }
 
    public void testTxCommit2() throws Exception {
-      Cache c = null;
-      try {
-         c = createCache();
-         TransactionManager tm = TestingUtil.getTransactionManager(c);
-         c.put("key", "old");
-         tm.begin();
-         assert c.get("key").equals("old");
-         c.put("key", "value");
-         assert c.get("key").equals("value");
-         Transaction t = tm.suspend();
-         assert c.get("key").equals("old");
-         tm.resume(t);
-         tm.commit();
-         assert c.get("key").equals("value");
-         assert !c.isEmpty();
-      }
-      finally {
-         TestingUtil.killCaches(c);
-      }
+      TransactionManager tm = TestingUtil.getTransactionManager(c);
+      c.put("key", "old");
+      tm.begin();
+      assert c.get("key").equals("old");
+      c.put("key", "value");
+      assert c.get("key").equals("value");
+      Transaction t = tm.suspend();
+      assert c.get("key").equals("old");
+      tm.resume(t);
+      tm.commit();
+      assert c.get("key").equals("value");
+      assert !c.isEmpty();
    }
 }

Modified: core/branches/flat/src/test/java/org/horizon/tx/MarkAsRollbackTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/tx/MarkAsRollbackTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/tx/MarkAsRollbackTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,77 +1,66 @@
 package org.horizon.tx;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.horizon.Cache;
-import org.horizon.UnitTestCacheFactory;
 import org.horizon.config.Configuration;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+import org.horizon.test.SingleCacheManagerTest;
+import org.horizon.test.TestingUtil;
 import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
 import org.testng.annotations.Test;
 
 import javax.transaction.RollbackException;
 import javax.transaction.TransactionManager;
 
- at Test(groups = "functional")
-public class MarkAsRollbackTest {
-   private static final Log log = LogFactory.getLog(MarkAsRollbackTest.class);
+ at Test(groups = "functional", testName = "tx.MarkAsRollbackTest")
+public class MarkAsRollbackTest extends SingleCacheManagerTest {
 
-   public void testMarkAsRollbackAfterMods() throws Exception {
+   protected CacheManager createCacheManager() throws Exception {
       Configuration c = new Configuration();
       c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      Cache<String, String> cache = new UnitTestCacheFactory<String, String>().createCache(c);
-      try {
-         TransactionManager tm = TestingUtil.getTransactionManager(cache);
-         assert tm != null;
-         tm.begin();
-         cache.put("k", "v");
-         assert cache.get("k").equals("v");
-         tm.setRollbackOnly();
-         try {
-            tm.commit();
-            assert false : "Should have rolled back";
-         }
-         catch (RollbackException expected) {
-         }
+      CacheManager cm = new DefaultCacheManager(c);
+      cache = cm.getCache();
+      return cm;
+   }
 
-         assert tm.getTransaction() == null : "There should be no transaction in scope anymore!";
-         assert cache.get("k") == null : "Expected a null but was " + cache.get("k");
+   public void testMarkAsRollbackAfterMods() throws Exception {
+
+      TransactionManager tm = TestingUtil.getTransactionManager(cache);
+      assert tm != null;
+      tm.begin();
+      cache.put("k", "v");
+      assert cache.get("k").equals("v");
+      tm.setRollbackOnly();
+      try {
+         tm.commit();
+         assert false : "Should have rolled back";
       }
-      finally {
-         log.warn("Cleaning up");
-         TestingUtil.killCaches(cache);
+      catch (RollbackException expected) {
       }
+
+      assert tm.getTransaction() == null : "There should be no transaction in scope anymore!";
+      assert cache.get("k") == null : "Expected a null but was " + cache.get("k");
    }
 
    public void testMarkAsRollbackBeforeMods() throws Exception {
-      Configuration c = new Configuration();
-      c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      Cache<String, String> cache = new UnitTestCacheFactory<String, String>().createCache(c);
+      TransactionManager tm = TestingUtil.getTransactionManager(cache);
+      assert tm != null;
+      tm.begin();
+      tm.setRollbackOnly();
       try {
-         TransactionManager tm = TestingUtil.getTransactionManager(cache);
-         assert tm != null;
-         tm.begin();
-         tm.setRollbackOnly();
-         try {
-            cache.put("k", "v");
-            assert false : "Should have throw an illegal state exception";
-         } catch (IllegalStateException expected) {
+         cache.put("k", "v");
+         assert false : "Should have throw an illegal state exception";
+      } catch (IllegalStateException expected) {
 
-         }
-         try {
-            tm.commit();
-            assert false : "Should have rolled back";
-         }
-         catch (RollbackException expected) {
-
-         }
-
-         assert tm.getTransaction() == null : "There should be no transaction in scope anymore!";
-         assert cache.get("k") == null : "Expected a null but was " + cache.get("k");
       }
-      finally {
-         log.warn("Cleaning up");
-         TestingUtil.killCaches(cache);
+      try {
+         tm.commit();
+         assert false : "Should have rolled back";
       }
+      catch (RollbackException expected) {
+
+      }
+
+      assert tm.getTransaction() == null : "There should be no transaction in scope anymore!";
+      assert cache.get("k") == null : "Expected a null but was " + cache.get("k");
    }
 }

Modified: core/branches/flat/src/test/java/org/horizon/util/BidirectionalLinkedHashMapTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/util/BidirectionalLinkedHashMapTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/util/BidirectionalLinkedHashMapTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -5,7 +5,7 @@
 import java.util.Iterator;
 import java.util.Map;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "util.BidirectionalLinkedHashMapTest")
 public class BidirectionalLinkedHashMapTest {
    public void testIterators() {
       BidirectionalLinkedHashMap<Integer, Object> map = new BidirectionalLinkedHashMap<Integer, Object>();

Deleted: core/branches/flat/src/test/java/org/horizon/util/UnitTestTestNGListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/util/UnitTestTestNGListener.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/util/UnitTestTestNGListener.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -1,93 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.horizon.util;
-
-import org.testng.IClass;
-import org.testng.ITestContext;
-import org.testng.ITestListener;
-import org.testng.ITestResult;
-
-/**
- * @author dpospisi
- * @since 1.0
- */
-public class UnitTestTestNGListener implements ITestListener {
-
-   /**
-    * Holds test classes actually running in all threads.
-    */
-   private ThreadLocal<IClass> threadTestClass = new ThreadLocal<IClass>();
-
-   private int failed = 0;
-   private int succeded = 0;
-   private int skipped = 0;
-
-   public void onTestStart(ITestResult res) {
-      System.out.println(getThreadId() + " Starting test " + getTestDesc(res));
-
-      /*
-      IClass testClass = threadTestClass.get();
-      if ((testClass != null) && (! res.getTestClass().equals(testClass))) {
-
-         System.out.println(getThreadId() + " New test class" + res.getTestClass() + ", was " + testClass);            
-
-         // the thread has started testing a new test class
-
-         // clean all possibly running caches created in current thread
-         boolean cleaned = new UnitTestCacheFactory().cleanUp();
-         if (cleaned) {
-            // previous test left a cache
-            System.out.println(getThreadId() +" WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-            System.out.println(getThreadId() +" A test method in " + testClass.getName() + " did not clean all cache instances properly.");
-            System.out.println(getThreadId() +" Use UnitTestCacheFactory.cleanUp() or TestngUtil.killCaches(...) ");
-            System.out.println(getThreadId() +" WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-         }
-      }
-      */
-
-      threadTestClass.set(res.getTestClass());
-   }
-
-   synchronized public void onTestSuccess(ITestResult arg0) {
-      System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " succeded.");
-      succeded++;
-      printStatus();
-   }
-
-   synchronized public void onTestFailure(ITestResult arg0) {
-      System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " failed.");
-      failed++;
-      printStatus();
-   }
-
-   synchronized public void onTestSkipped(ITestResult arg0) {
-      System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " skipped.");
-      skipped++;
-      printStatus();
-   }
-
-   public void onTestFailedButWithinSuccessPercentage(ITestResult arg0) {
-   }
-
-   public void onStart(ITestContext arg0) {
-   }
-
-   public void onFinish(ITestContext arg0) {
-   }
-
-   private String getThreadId() {
-      return "[" + Thread.currentThread().getName() + "]";
-   }
-
-   private String getTestDesc(ITestResult res) {
-      return res.getMethod().getMethodName() + "(" + res.getTestClass().getName() + ")";
-   }
-
-   private void printStatus() {
-      System.out.println("Testsuite execution progress: tests succeded " + succeded + ", failed " + failed + ", skipped " + skipped + ".");
-   }
-
-}

Modified: core/branches/flat/src/test/java/org/horizon/util/VisitableLinkedHashSetTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/util/VisitableLinkedHashSetTest.java	2009-02-17 14:31:02 UTC (rev 7698)
+++ core/branches/flat/src/test/java/org/horizon/util/VisitableLinkedHashSetTest.java	2009-02-17 14:38:40 UTC (rev 7699)
@@ -5,7 +5,7 @@
 import java.util.Iterator;
 import java.util.Set;
 
- at Test(groups = "unit")
+ at Test(groups = "unit", testName = "util.VisitableLinkedHashSetTest")
 public class VisitableLinkedHashSetTest {
 
    public void testVisitableSet() {
@@ -66,4 +66,4 @@
       }
       assert index == -1 : "Was " + index + ", instead of -1";
    }
-}
\ No newline at end of file
+}

Added: core/branches/flat/src/test/resources/stacks/tcp.xml
===================================================================
--- core/branches/flat/src/test/resources/stacks/tcp.xml	                        (rev 0)
+++ core/branches/flat/src/test/resources/stacks/tcp.xml	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,59 @@
+<config>
+   <TCP bind_port="7800"
+        port_range="10"
+        loopback="true"
+        recv_buf_size="20000000"
+        send_buf_size="640000"
+        discard_incompatible_packets="true"
+        max_bundle_size="64000"
+        max_bundle_timeout="30"
+        enable_bundling="false"
+        use_send_queues="false"
+        sock_conn_timeout="300"
+        skip_suspected_members="true"
+        thread_pool.enabled="true"
+        thread_pool.min_threads="1"
+        thread_pool.max_threads="25"
+        thread_pool.keep_alive_time="5000"
+        thread_pool.queue_enabled="false"
+        thread_pool.queue_max_size="100"
+        thread_pool.rejection_policy="run"
+
+        oob_thread_pool.enabled="true"
+        oob_thread_pool.min_threads="1"
+        oob_thread_pool.max_threads="8"
+        oob_thread_pool.keep_alive_time="5000"
+        oob_thread_pool.queue_enabled="false"
+        oob_thread_pool.queue_max_size="100"
+        oob_thread_pool.rejection_policy="run"/>
+
+   <TCPPING timeout="3000"
+            initial_hosts="127.0.0.1[7800]"
+            port_range="1"
+            num_initial_members="1"/>
+   <MERGE2 max_interval="100000"
+           min_interval="20000"/>
+   <FD_SOCK/>
+   <!--
+      Note that this is an atypically short timeout and a small number of retries
+      configured this way to speed up unit testing, since we know all nodes run in the same JVM
+      and hence failure detections will be very quick.
+   -->
+   <FD timeout="1000" max_tries="5" shun="true"/>
+   <VERIFY_SUSPECT timeout="1500"/>
+   <BARRIER/>
+   <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+                  retransmit_timeout="300,600,1200,2400,4800"
+                  discard_delivered_msgs="true"/>
+   <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                  max_bytes="400000"/>
+   <VIEW_SYNC avg_send_interval="60000"/>
+   <pbcast.GMS print_local_addr="false" join_timeout="3000" shun="true"
+               view_bundling="true"/>
+   <FC max_credits="2000000"
+       min_threshold="0.10"/>
+   <FRAG2 frag_size="60000"/>
+   <pbcast.STREAMING_STATE_TRANSFER/>
+   <!-- <pbcast.STATE_TRANSFER/> -->
+   <pbcast.FLUSH timeout="0"/>
+</config>


Property changes on: core/branches/flat/src/test/resources/stacks/tcp.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: core/branches/flat/src/test/resources/stacks/udp.xml
===================================================================
--- core/branches/flat/src/test/resources/stacks/udp.xml	                        (rev 0)
+++ core/branches/flat/src/test/resources/stacks/udp.xml	2009-02-17 14:38:40 UTC (rev 7699)
@@ -0,0 +1,63 @@
+<config>
+   <UDP mcast_addr="228.10.10.10"
+        mcast_port="45588"
+        tos="8"
+        ucast_recv_buf_size="20000000"
+        ucast_send_buf_size="640000"
+        mcast_recv_buf_size="25000000"
+        mcast_send_buf_size="640000"
+        loopback="false"
+        discard_incompatible_packets="true"
+        max_bundle_size="64000"
+        max_bundle_timeout="30"
+        use_incoming_packet_handler="true"
+        ip_ttl="2"
+        enable_bundling="false"
+        enable_diagnostics="true"
+
+        use_concurrent_stack="true"
+
+        thread_naming_pattern="pl"
+
+        thread_pool.enabled="true"
+        thread_pool.min_threads="1"
+        thread_pool.max_threads="25"
+        thread_pool.keep_alive_time="30000"
+        thread_pool.queue_enabled="false"
+        thread_pool.queue_max_size="100"
+        thread_pool.rejection_policy="Run"
+
+        oob_thread_pool.enabled="true"
+        oob_thread_pool.min_threads="1"
+        oob_thread_pool.max_threads="4"
+        oob_thread_pool.keep_alive_time="10000"
+        oob_thread_pool.queue_enabled="false"
+        oob_thread_pool.queue_max_size="10"
+        oob_thread_pool.rejection_policy="Run"/>
+
+   <PING timeout="2000" num_initial_members="3"/>
+   <MERGE2 max_interval="30000" min_interval="10000"/>
+   <FD_SOCK/>
+   <!--
+      Note that this is an atypically short timeout and a small number of retries
+      configured this way to speed up unit testing, since we know all nodes run in the same JVM
+      and hence failure detections will be very quick.
+   -->
+   <FD timeout="1000" max_tries="2" shun="true"/>
+   <VERIFY_SUSPECT timeout="250"/>
+   <!-- this is a more typical configuration of FD and VERIFY_SUSPECT-->
+   <!--<FD timeout="10000" max_tries="5" shun="true"/>-->
+   <!--<VERIFY_SUSPECT timeout="1500"/>-->
+   <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+                  retransmit_timeout="300,600,900,1200"
+                  discard_delivered_msgs="true"/>
+   <UNICAST timeout="300,600,900,1200"/>
+   <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                  max_bytes="400000"/>
+   <pbcast.GMS print_local_addr="false" join_timeout="1000" shun="false"
+               view_bundling="true" view_ack_collection_timeout="1000"/>
+   <FRAG2 frag_size="60000"/>
+   <pbcast.STREAMING_STATE_TRANSFER/>
+   <!-- <pbcast.STATE_TRANSFER/> -->
+   <pbcast.FLUSH timeout="0"/>
+</config>


Property changes on: core/branches/flat/src/test/resources/stacks/udp.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbosscache-commits mailing list