[jboss-cvs] JBossAS SVN: r107743 - in projects/cluster/ha-server-ispn/trunk/src: test/java/org/jboss/ha/ispn and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 23 16:53:00 EDT 2010


Author: pferraro
Date: 2010-08-23 16:52:59 -0400 (Mon, 23 Aug 2010)
New Revision: 107743

Added:
   projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultAdvancedCache.java
   projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainer.java
   projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultAdvancedCacheTest.java
   projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerTest.java
Removed:
   projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/AliasAwareCacheContainer.java
Modified:
   projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/CacheContainerFactory.java
   projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/CacheContainerRegistry.java
   projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerFactory.java
   projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerRegistry.java
   projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerFactoryTest.java
   projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerRegistryTest.java
Log:
Let CacheContainerRegistry return EmbeddedCacheManager

Deleted: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/AliasAwareCacheContainer.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/AliasAwareCacheContainer.java	2010-08-23 20:03:55 UTC (rev 107742)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/AliasAwareCacheContainer.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.jboss.ha.ispn;
-
-import java.util.Map;
-
-import org.infinispan.Cache;
-import org.infinispan.manager.CacheContainer;
-
-/**
- * Cache container decorator that returns the same cache instance for all aliases of a given cache name.
- * @author Paul Ferraro
- */
-public class AliasAwareCacheContainer implements CacheContainer
-{
-   private final CacheContainer container;
-   private final Map<String, String> aliases;
-   
-   /**
-    * Creates a new alias-aware cache container.
-    * @param container the proxied cache container
-    * @param aliases an map of cache name aliases
-    */
-   public AliasAwareCacheContainer(CacheContainer container, Map<String, String> aliases)
-   {
-      this.container = container;
-      this.aliases = aliases;
-   }
-   
-   /**
-    * {@inheritDoc}
-    * @see org.infinispan.lifecycle.Lifecycle#start()
-    */
-   @Override
-   public void start()
-   {
-      this.container.start();
-   }
-
-   /**
-    * {@inheritDoc}
-    * @see org.infinispan.lifecycle.Lifecycle#stop()
-    */
-   @Override
-   public void stop()
-   {
-      this.container.stop();
-   }
-
-   /**
-    * {@inheritDoc}
-    * @see org.infinispan.manager.CacheContainer#getCache()
-    */
-   @Override
-   public <K, V> Cache<K, V> getCache()
-   {
-      return this.container.getCache();
-   }
-
-   /**
-    * {@inheritDoc}
-    * @see org.infinispan.manager.CacheContainer#getCache(java.lang.String)
-    */
-   @Override
-   public <K, V> Cache<K, V> getCache(String alias)
-   {
-      String name = this.aliases.get(alias);
-      
-      return this.container.getCache((name == null) ? alias : name);
-   }
-}

Modified: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/CacheContainerFactory.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/CacheContainerFactory.java	2010-08-23 20:03:55 UTC (rev 107742)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/CacheContainerFactory.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -22,6 +22,7 @@
 package org.jboss.ha.ispn;
 
 import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
 
 /**
  * Creates an Infinispan {@link CacheContainer} instance from configuration.
@@ -35,5 +36,5 @@
     * @param configuration a cache container configuration
     * @return an Infinispan cache container
     */
-   CacheContainer createCacheContainer(CacheContainerConfiguration configuration);
+   EmbeddedCacheManager createCacheContainer(CacheContainerConfiguration configuration);
 }

Modified: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/CacheContainerRegistry.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/CacheContainerRegistry.java	2010-08-23 20:03:55 UTC (rev 107742)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/CacheContainerRegistry.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -23,7 +23,7 @@
 
 import java.util.Set;
 
-import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
 
 /**
  * A registry of Infinispan cache containers.
@@ -36,7 +36,7 @@
     * Equivalent to getCacheContainer(null).
     * @return an Infinispan cache container.
     */
-   CacheContainer getCacheContainer();
+   EmbeddedCacheManager getCacheContainer();
    
    /**
     * Returns the cache container associated with the specified identifier,
@@ -45,7 +45,7 @@
     * @param id a cache container identifier
     * @return an Infinispan cache container.
     */
-   CacheContainer getCacheContainer(String id);
+   EmbeddedCacheManager getCacheContainer(String id);
    
    /**
     * Returns the identifiers of all cache containers in this registry.

Added: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultAdvancedCache.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultAdvancedCache.java	                        (rev 0)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultAdvancedCache.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jboss.ha.ispn;
+
+import org.infinispan.AbstractDelegatingAdvancedCache;
+import org.infinispan.AdvancedCache;
+import org.infinispan.manager.CacheContainer;
+import org.infinispan.stats.Stats;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class DefaultAdvancedCache<K, V> extends AbstractDelegatingAdvancedCache<K, V>
+{
+   private final CacheContainer container;
+   private final AdvancedCache<K, V> cache;
+   
+   public DefaultAdvancedCache(CacheContainer container, AdvancedCache<K, V> cache)
+   {
+      super(cache);
+      this.container = container;
+      this.cache = cache;
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.infinispan.AdvancedCache#getStats()
+    */
+   @Override
+   public Stats getStats()
+   {
+      return this.cache.getStats();
+   }
+
+   @Override
+   public AdvancedCache<K, V> getAdvancedCache()
+   {
+      return this;
+   }
+
+   @Override
+   public CacheContainer getCacheManager()
+   {
+      return this.container;
+   }
+}

Copied: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainer.java (from rev 107724, projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/AliasAwareCacheContainer.java)
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainer.java	                        (rev 0)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainer.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jboss.ha.ispn;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.remoting.transport.Address;
+
+/**
+ * Cache container decorator that returns the same cache instance for all aliases of a given cache name.
+ * @author Paul Ferraro
+ */
+public class DefaultCacheContainer implements EmbeddedCacheManager
+{
+   private final EmbeddedCacheManager container;
+   private final Map<String, String> aliases;
+   
+   /**
+    * Creates a new alias-aware cache container.
+    * @param container the proxied cache container
+    * @param aliases an map of cache name aliases
+    */
+   public DefaultCacheContainer(EmbeddedCacheManager container, Map<String, String> aliases)
+   {
+      this.container = container;
+      this.aliases = aliases;
+   }
+   
+   /**
+    * {@inheritDoc}
+    * @see org.infinispan.lifecycle.Lifecycle#start()
+    */
+   @Override
+   public void start()
+   {
+      this.container.start();
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.infinispan.lifecycle.Lifecycle#stop()
+    */
+   @Override
+   public void stop()
+   {
+      this.container.stop();
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.infinispan.manager.CacheContainer#getCache()
+    */
+   @Override
+   public <K, V> Cache<K, V> getCache()
+   {
+      return this.decorate(this.container.<K, V>getCache());
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.infinispan.manager.CacheContainer#getCache(java.lang.String)
+    */
+   @Override
+   public <K, V> Cache<K, V> getCache(String alias)
+   {
+      String name = this.aliases.get(alias);
+      
+      return this.decorate(this.container.<K, V>getCache((name == null) ? alias : name));
+   }
+
+   private <K, V> Cache<K, V> decorate(Cache<K, V> cache)
+   {
+      return new DefaultAdvancedCache<K, V>(this, cache.getAdvancedCache());
+   }
+   
+   @Override
+   public void addListener(Object listener)
+   {
+      this.container.addListener(listener);
+   }
+
+   @Override
+   public void removeListener(Object listener)
+   {
+      this.container.removeListener(listener);
+   }
+
+   @Override
+   public Set<Object> getListeners()
+   {
+      return this.container.getListeners();
+   }
+
+   @Override
+   public Configuration defineConfiguration(String cacheName, Configuration configurationOverride)
+   {
+      return this.container.defineConfiguration(cacheName, configurationOverride);
+   }
+
+   @Override
+   public Configuration defineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride)
+   {
+      return this.container.defineConfiguration(cacheName, templateCacheName, configurationOverride);
+   }
+
+   @Override
+   public String getClusterName()
+   {
+      return this.container.getClusterName();
+   }
+
+   @Override
+   public List<Address> getMembers()
+   {
+      return this.container.getMembers();
+   }
+
+   @Override
+   public Address getAddress()
+   {
+      return this.container.getAddress();
+   }
+
+   @Override
+   public boolean isCoordinator()
+   {
+      return this.container.isCoordinator();
+   }
+
+   @Override
+   public ComponentStatus getStatus()
+   {
+      return this.container.getStatus();
+   }
+
+   @Override
+   public GlobalConfiguration getGlobalConfiguration()
+   {
+      return this.container.getGlobalConfiguration();
+   }
+
+   @Override
+   public Configuration getDefaultConfiguration()
+   {
+      return this.container.getDefaultConfiguration();
+   }
+
+   @Override
+   public Set<String> getCacheNames()
+   {
+      return this.container.getCacheNames();
+   }
+}

Modified: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerFactory.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerFactory.java	2010-08-23 20:03:55 UTC (rev 107742)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerFactory.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -25,7 +25,6 @@
 
 import org.infinispan.config.Configuration;
 import org.infinispan.config.GlobalConfiguration;
-import org.infinispan.manager.CacheContainer;
 import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.manager.EmbeddedCacheManager;
 import org.infinispan.remoting.transport.jgroups.JGroupsChannelLookup;
@@ -60,7 +59,7 @@
     * @see org.jboss.ha.ispn.CacheContainerFactory#createCacheContainer(org.jboss.ha.ispn.CacheContainerConfiguration)
     */
    @Override
-   public CacheContainer createCacheContainer(CacheContainerConfiguration configuration)
+   public EmbeddedCacheManager createCacheContainer(CacheContainerConfiguration configuration)
    {
       GlobalConfiguration globalConfiguration = configuration.getGlobalConfiguration();
       Properties properties = globalConfiguration.getTransportProperties();

Modified: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerRegistry.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerRegistry.java	2010-08-23 20:03:55 UTC (rev 107742)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerRegistry.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -34,7 +34,7 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
-import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
 import org.jboss.ha.ispn.config.Alias;
 import org.jboss.ha.ispn.config.CacheContainerRegistryConfiguration;
 import org.jboss.ha.ispn.config.CacheContainerRegistryConfigurationEntry;
@@ -61,9 +61,9 @@
    private final CacheContainerFactory factory;
    private final CacheContainerRegistryConfigurationSource source;
    private final Context context;
-   private final Map<String, Map.Entry<String, CacheContainer>> containers = new ConcurrentHashMap<String, Map.Entry<String, CacheContainer>>();
+   private final Map<String, Map.Entry<String, EmbeddedCacheManager>> containers = new ConcurrentHashMap<String, Map.Entry<String, EmbeddedCacheManager>>();
 
-   private CacheContainer defaultContainer;
+   private EmbeddedCacheManager defaultContainer;
    
    /**
     * Creates a new cache container registry using the specified factory and source.
@@ -119,7 +119,7 @@
    {
       singleton.set(null);
       
-      for (Map.Entry<String, CacheContainer> entry: this.containers.values())
+      for (Map.Entry<String, EmbeddedCacheManager> entry: this.containers.values())
       {
          String jndiName = entry.getKey();
          
@@ -155,7 +155,7 @@
     * @see org.jboss.ha.ispn.CacheContainerRegistry#getCacheContainer()
     */
    @Override
-   public CacheContainer getCacheContainer()
+   public EmbeddedCacheManager getCacheContainer()
    {
       return this.defaultContainer;
    }
@@ -165,9 +165,9 @@
     * @see org.jboss.ha.ispn.CacheContainerRegistry#getCacheContainer(java.lang.String)
     */
    @Override
-   public CacheContainer getCacheContainer(String name)
+   public EmbeddedCacheManager getCacheContainer(String name)
    {
-      Map.Entry<String, CacheContainer> entry = (name != null) ? this.containers.get(name) : null;
+      Map.Entry<String, EmbeddedCacheManager> entry = (name != null) ? this.containers.get(name) : null;
       
       // Return default cache manager, if name was not found or if it was null
       return (entry != null) ? entry.getValue() : this.defaultContainer;
@@ -175,18 +175,12 @@
    
    public void add(CacheContainerRegistryConfigurationEntry entry) throws NamingException
    {
-      CacheContainer container = this.factory.createCacheContainer(entry.getConfiguration());
-
-      Map<String, String> aliases = this.mapAliases(entry);
-      if (!aliases.isEmpty())
-      {
-         container = new AliasAwareCacheContainer(container, aliases);
-      }
+      EmbeddedCacheManager container = new DefaultCacheContainer(this.factory.createCacheContainer(entry.getConfiguration()), this.mapAliases(entry));
       
       String jndiName = entry.getJndiName();
       
       // Store cache containers with jndi name, so they can be unbound during stop()
-      this.containers.put(entry.getId(), new AbstractMap.SimpleImmutableEntry<String, CacheContainer>(jndiName, container));
+      this.containers.put(entry.getId(), new AbstractMap.SimpleImmutableEntry<String, EmbeddedCacheManager>(jndiName, container));
       
       // Bind cache container to jndi
       this.bind(jndiName, container);
@@ -216,7 +210,7 @@
    
    public void remove(CacheContainerRegistryConfigurationEntry config) throws NamingException
    {
-      Map.Entry<String, CacheContainer> entry = this.containers.remove(config.getId());
+      Map.Entry<String, EmbeddedCacheManager> entry = this.containers.remove(config.getId());
       
       if (entry != null)
       {

Added: projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultAdvancedCacheTest.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultAdvancedCacheTest.java	                        (rev 0)
+++ projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultAdvancedCacheTest.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -0,0 +1,1407 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jboss.ha.ispn;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import javax.transaction.TransactionManager;
+
+import org.easymock.EasyMock;
+import org.infinispan.AdvancedCache;
+import org.infinispan.batch.BatchContainer;
+import org.infinispan.config.Configuration;
+import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.container.DataContainer;
+import org.infinispan.context.Flag;
+import org.infinispan.context.InvocationContextContainer;
+import org.infinispan.distribution.DistributionManager;
+import org.infinispan.eviction.EvictionManager;
+import org.infinispan.factories.ComponentRegistry;
+import org.infinispan.factories.GlobalComponentRegistry;
+import org.infinispan.interceptors.CallInterceptor;
+import org.infinispan.interceptors.base.CommandInterceptor;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.remoting.rpc.RpcManager;
+import org.infinispan.stats.Stats;
+import org.infinispan.util.concurrent.NotifyingFuture;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DefaultAdvancedCacheTest
+{
+   private final EmbeddedCacheManager container = EasyMock.createStrictMock(EmbeddedCacheManager.class);
+   @SuppressWarnings("unchecked")
+   private final AdvancedCache<Object, Object> advancedCache = EasyMock.createStrictMock(AdvancedCache.class);
+   private final AdvancedCache<Object, Object> cache = new DefaultAdvancedCache<Object, Object>(this.container, this.advancedCache);
+   
+   @After
+   public void after()
+   {
+      EasyMock.reset(this.advancedCache);
+   }
+   
+   @Test
+   public void putForExternalRead()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      
+      this.advancedCache.putForExternalRead(EasyMock.same(key), EasyMock.same(value));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.putForExternalRead(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void evict()
+   {
+      Object key = new Object();
+      
+      this.advancedCache.evict(EasyMock.same(key));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.evict(key);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void getConfiguration()
+   {
+      Configuration configuration = new Configuration();
+      
+      EasyMock.expect(this.advancedCache.getConfiguration()).andReturn(configuration);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Configuration result = this.cache.getConfiguration();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(configuration, result);
+   }
+
+   @Test
+   public void startBatch()
+   {
+      EasyMock.expect(this.advancedCache.startBatch()).andReturn(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      boolean result = this.cache.startBatch();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertTrue(result);
+   }
+
+   @Test
+   public void endBatch()
+   {
+      this.advancedCache.endBatch(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.endBatch(true);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void getName()
+   {
+      String name = "name";
+      
+      EasyMock.expect(this.advancedCache.getName()).andReturn(name);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      String result = this.cache.getName();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(name, result);
+   }
+
+   @Test
+   public void getVersion()
+   {
+      String version = "name";
+      
+      EasyMock.expect(this.advancedCache.getVersion()).andReturn(version);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      String result = this.cache.getVersion();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(version, result);
+   }
+
+   @Test
+   public void getCacheManager()
+   {
+      CacheContainer result = this.cache.getCacheManager();
+      
+      Assert.assertSame(this.container, result);
+   }
+
+   @Test
+   public void putLifespan()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit unit = TimeUnit.SECONDS;
+      Object expected = new Object();
+      
+      EasyMock.expect(this.advancedCache.put(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(unit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.put(key, value, lifespan, unit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putIfAbsentLifespan()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit unit = TimeUnit.SECONDS;
+      Object expected = new Object();
+      
+      EasyMock.expect(this.advancedCache.putIfAbsent(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(unit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.putIfAbsent(key, value, lifespan, unit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putAllLifespan()
+   {
+      Map<Object, Object> map = Collections.emptyMap();
+      long lifespan = 1;
+      TimeUnit unit = TimeUnit.SECONDS;
+      
+      this.advancedCache.putAll(EasyMock.same(map), EasyMock.eq(lifespan), EasyMock.same(unit));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.putAll(map, lifespan, unit);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void replaceLifespan()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit unit = TimeUnit.SECONDS;
+      Object expected = new Object();
+      
+      EasyMock.expect(this.advancedCache.replace(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(unit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.replace(key, value, lifespan, unit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void replaceIfLifespan()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit unit = TimeUnit.SECONDS;
+      Object oldValue = new Object();
+      
+      EasyMock.expect(this.advancedCache.replace(EasyMock.same(key), EasyMock.same(oldValue), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(unit))).andReturn(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      boolean result = this.cache.replace(key, oldValue, value, lifespan, unit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertTrue(result);
+   }
+
+   @Test
+   public void putTimeout()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdleTime = 2;
+      TimeUnit maxIdleTimeUnit = TimeUnit.MILLISECONDS;
+      
+      Object expected = new Object();
+      
+      EasyMock.expect(this.advancedCache.put(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdleTime), EasyMock.same(maxIdleTimeUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.put(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putIfAbsentTimeout()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdleTime = 2;
+      TimeUnit maxIdleTimeUnit = TimeUnit.MILLISECONDS;
+      
+      Object expected = new Object();
+      
+      EasyMock.expect(this.advancedCache.putIfAbsent(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdleTime), EasyMock.same(maxIdleTimeUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.putIfAbsent(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putAllTimeout()
+   {
+      Map<Object, Object> map = Collections.emptyMap();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdleTime = 2;
+      TimeUnit maxIdleTimeUnit = TimeUnit.MILLISECONDS;
+      
+      this.advancedCache.putAll(EasyMock.same(map), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdleTime), EasyMock.same(maxIdleTimeUnit));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.putAll(map, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void replaceTimeout()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdleTime = 2;
+      TimeUnit maxIdleTimeUnit = TimeUnit.MILLISECONDS;
+      
+      Object expected = new Object();
+      
+      EasyMock.expect(this.advancedCache.replace(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdleTime), EasyMock.same(maxIdleTimeUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.replace(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void replaceIfTimeout()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      Object oldValue = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdleTime = 2;
+      TimeUnit maxIdleTimeUnit = TimeUnit.MILLISECONDS;
+      
+      EasyMock.expect(this.advancedCache.replace(EasyMock.same(key), EasyMock.same(oldValue), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdleTime), EasyMock.same(maxIdleTimeUnit))).andReturn(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      boolean result = this.cache.replace(key, oldValue, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertTrue(result);
+   }
+
+   @Test
+   public void putAsync()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.putAsync(EasyMock.same(key), EasyMock.same(value))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.putAsync(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putAsyncLifespan()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit unit = TimeUnit.SECONDS;
+      
+      EasyMock.expect(this.advancedCache.putAsync(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(unit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.putAsync(key, value, lifespan, unit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putAsyncTimeout()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdle = 2;
+      TimeUnit maxIdleUnit = TimeUnit.MILLISECONDS;
+      
+      EasyMock.expect(this.advancedCache.putAsync(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdle), EasyMock.same(maxIdleUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.putAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putAllAsync()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Void> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Map<Object, Object> map = Collections.emptyMap();
+      
+      EasyMock.expect(this.advancedCache.putAllAsync(EasyMock.same(map))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Void> result = this.cache.putAllAsync(map);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putAllAsyncLifespan()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Void> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Map<Object, Object> map = Collections.emptyMap();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      
+      EasyMock.expect(this.advancedCache.putAllAsync(EasyMock.same(map), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Void> result = this.cache.putAllAsync(map, lifespan, lifespanUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putAllAsyncTimeout()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Void> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Map<Object, Object> map = Collections.emptyMap();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdle = 2;
+      TimeUnit maxIdleUnit = TimeUnit.MILLISECONDS;
+      
+      EasyMock.expect(this.advancedCache.putAllAsync(EasyMock.same(map), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdle), EasyMock.same(maxIdleUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Void> result = this.cache.putAllAsync(map, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void clearAsync()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Void> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      EasyMock.expect(this.advancedCache.clearAsync()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Void> result = this.cache.clearAsync();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putIfAbsentAsync()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.putIfAbsentAsync(EasyMock.same(key), EasyMock.same(value))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.putIfAbsentAsync(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putIfAbsentAsyncLifespan()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      
+      EasyMock.expect(this.advancedCache.putIfAbsentAsync(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.putIfAbsentAsync(key, value, lifespan, lifespanUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putIfAbsentAsyncTimeout()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdle = 2;
+      TimeUnit maxIdleUnit = TimeUnit.MILLISECONDS;
+      
+      EasyMock.expect(this.advancedCache.putIfAbsentAsync(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdle), EasyMock.same(maxIdleUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.putIfAbsentAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void removeAsync()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      
+      EasyMock.expect(this.advancedCache.removeAsync(EasyMock.same(key))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.removeAsync(key);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void removeAsyncIf()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Boolean> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.removeAsync(EasyMock.same(key), EasyMock.same(value))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Boolean> result = this.cache.removeAsync(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void replaceAsync()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.replaceAsync(EasyMock.same(key), EasyMock.same(value))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.replaceAsync(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void replaceAsyncLifespan()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      
+      EasyMock.expect(this.advancedCache.replaceAsync(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.replaceAsync(key, value, lifespan, lifespanUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void replaceAsyncTimeout()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Object> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdle = 2;
+      TimeUnit maxIdleUnit = TimeUnit.MILLISECONDS;
+      
+      EasyMock.expect(this.advancedCache.replaceAsync(EasyMock.same(key), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdle), EasyMock.same(maxIdleUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Object> result = this.cache.replaceAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void replaceAsyncIf()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Boolean> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object oldValue = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.replaceAsync(EasyMock.same(key), EasyMock.same(oldValue), EasyMock.same(value))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Boolean> result = this.cache.replaceAsync(key, oldValue, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void replaceAsyncIfLifespan()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Boolean> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object oldValue = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      
+      EasyMock.expect(this.advancedCache.replaceAsync(EasyMock.same(key), EasyMock.same(oldValue), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Boolean> result = this.cache.replaceAsync(key, oldValue, value, lifespan, lifespanUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void replaceAsyncIfTimeout()
+   {
+      @SuppressWarnings("unchecked")
+      NotifyingFuture<Boolean> expected = EasyMock.createStrictMock(NotifyingFuture.class);
+      
+      Object key = new Object();
+      Object oldValue = new Object();
+      Object value = new Object();
+      long lifespan = 1;
+      TimeUnit lifespanUnit = TimeUnit.SECONDS;
+      long maxIdle = 2;
+      TimeUnit maxIdleUnit = TimeUnit.MILLISECONDS;
+      
+      EasyMock.expect(this.advancedCache.replaceAsync(EasyMock.same(key), EasyMock.same(oldValue), EasyMock.same(value), EasyMock.eq(lifespan), EasyMock.same(lifespanUnit), EasyMock.eq(maxIdle), EasyMock.same(maxIdleUnit))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      NotifyingFuture<Boolean> result = this.cache.replaceAsync(key, oldValue, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getAdvancedCache()
+   {
+      Assert.assertSame(this.cache, this.cache.getAdvancedCache());
+   }
+
+   @Test
+   public void compact()
+   {
+      this.advancedCache.compact();
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.compact();
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void getStatus()
+   {
+      ComponentStatus expected = ComponentStatus.INITIALIZING;
+      
+      EasyMock.expect(this.advancedCache.getStatus()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      ComponentStatus result = this.cache.getStatus();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void keySet()
+   {
+      Set<Object> expected = Collections.emptySet();
+      
+      EasyMock.expect(this.advancedCache.keySet()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Set<Object> result = this.cache.keySet();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void values()
+   {
+      Collection<Object> expected = Collections.emptySet();
+      
+      EasyMock.expect(this.advancedCache.values()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Collection<Object> result = this.cache.values();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void entrySet()
+   {
+      Set<java.util.Map.Entry<Object, Object>> expected = Collections.emptySet();
+      
+      EasyMock.expect(this.advancedCache.entrySet()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Set<java.util.Map.Entry<Object, Object>> result = this.cache.entrySet();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putIfAbsent()
+   {
+      Object expected = new Object();
+      Object key = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.putIfAbsent(EasyMock.same(key), EasyMock.same(value))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.putIfAbsent(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void removeIf()
+   {
+      Object key = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.remove(EasyMock.same(key), EasyMock.same(value))).andReturn(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      boolean result = this.cache.remove(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertTrue(result);
+   }
+
+   @Test
+   public void replaceIf()
+   {
+      Object key = new Object();
+      Object oldValue = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.replace(EasyMock.same(key), EasyMock.same(oldValue), EasyMock.same(value))).andReturn(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      boolean result = this.cache.replace(key, oldValue, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertTrue(result);
+   }
+
+   @Test
+   public void replace()
+   {
+      Object expected = new Object();
+      Object key = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.replace(EasyMock.same(key), EasyMock.same(value))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.replace(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void size()
+   {
+      EasyMock.expect(this.advancedCache.size()).andReturn(1);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      int result = this.cache.size();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertEquals(1, result);
+   }
+
+   @Test
+   public void isEmpty()
+   {
+      EasyMock.expect(this.advancedCache.isEmpty()).andReturn(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      boolean result = this.cache.isEmpty();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertTrue(result);
+   }
+
+   @Test
+   public void containsKey()
+   {
+      Object key = new Object();
+      
+      EasyMock.expect(this.advancedCache.containsKey(EasyMock.same(key))).andReturn(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      boolean result = this.cache.containsKey(key);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertTrue(result);
+   }
+
+   @Test
+   public void containsValue()
+   {
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.containsValue(EasyMock.same(value))).andReturn(true);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      boolean result = this.cache.containsValue(value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertTrue(result);
+   }
+
+   @Test
+   public void get()
+   {
+      Object expected = new Object();
+      Object key = new Object();
+      
+      EasyMock.expect(this.advancedCache.get(EasyMock.same(key))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.get(key);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void put()
+   {
+      Object expected = new Object();
+      Object key = new Object();
+      Object value = new Object();
+      
+      EasyMock.expect(this.advancedCache.put(EasyMock.same(key), EasyMock.same(value))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.put(key, value);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void remove()
+   {
+      Object expected = new Object();
+      Object key = new Object();
+      
+      EasyMock.expect(this.advancedCache.remove(EasyMock.same(key))).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Object result = this.cache.remove(key);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void putAll()
+   {
+      Map<Object, Object> map = Collections.emptyMap();
+      
+      this.advancedCache.putAll(EasyMock.same(map));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.putAll(map);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void clear()
+   {
+      this.advancedCache.clear();
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.clear();
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void start()
+   {
+      this.advancedCache.start();
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.start();
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void stop()
+   {
+      this.advancedCache.stop();
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.stop();
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void addListener()
+   {
+      Object listener = new Object();
+      
+      this.advancedCache.addListener(EasyMock.same(listener));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.addListener(listener);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void removeListener()
+   {
+      Object listener = new Object();
+      
+      this.advancedCache.removeListener(EasyMock.same(listener));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.removeListener(listener);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void getListeners()
+   {
+      Set<Object> expected = Collections.emptySet();
+      
+      EasyMock.expect(this.advancedCache.getListeners()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Set<Object> result = this.cache.getListeners();
+      
+      EasyMock.verify(this.advancedCache);
+
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void withFlags()
+   {
+      Flag[] flags = new Flag[0];
+      
+      EasyMock.expect(this.advancedCache.withFlags(flags)).andReturn(this.advancedCache);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      AdvancedCache<Object, Object> result = this.cache.withFlags(flags);
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(this.cache, result);
+   }
+
+   @Test
+   public void addInterceptor()
+   {
+      CommandInterceptor interceptor = new CallInterceptor();
+      int position = 1;
+      
+      this.advancedCache.addInterceptor(EasyMock.same(interceptor), EasyMock.eq(position));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.addInterceptor(interceptor, position);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void addInterceptorAfter()
+   {
+      CommandInterceptor interceptor = new CallInterceptor();
+      Class<? extends CommandInterceptor> afterInterceptor = CallInterceptor.class;
+      
+      this.advancedCache.addInterceptorAfter(EasyMock.same(interceptor), EasyMock.same(afterInterceptor));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.addInterceptorAfter(interceptor, afterInterceptor);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void addInterceptorBefore()
+   {
+      CommandInterceptor interceptor = new CallInterceptor();
+      Class<? extends CommandInterceptor> afterInterceptor = CallInterceptor.class;
+      
+      this.advancedCache.addInterceptorBefore(EasyMock.same(interceptor), EasyMock.same(afterInterceptor));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.addInterceptorBefore(interceptor, afterInterceptor);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void removeInterceptorPosition()
+   {
+      int position = 1;
+      
+      this.advancedCache.removeInterceptor(position);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.removeInterceptor(position);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void removeInterceptor()
+   {
+      Class<? extends CommandInterceptor> interceptorType = CallInterceptor.class;
+      
+      this.advancedCache.removeInterceptor(interceptorType);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.removeInterceptor(interceptorType);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void getInterceptorChain()
+   {
+      List<CommandInterceptor> expected = Collections.emptyList();
+
+      EasyMock.expect(this.advancedCache.getInterceptorChain()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      List<CommandInterceptor> result = this.cache.getInterceptorChain();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getEvictionManager()
+   {
+      EvictionManager expected = EasyMock.createStrictMock(EvictionManager.class);
+      
+      EasyMock.expect(this.advancedCache.getEvictionManager()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      EvictionManager result = this.cache.getEvictionManager();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getComponentRegistry()
+   {
+      ComponentRegistry expected = new ComponentRegistry("test", new Configuration(), this.cache, new GlobalComponentRegistry(new GlobalConfiguration(), this.container));
+      
+      EasyMock.expect(this.advancedCache.getComponentRegistry()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      ComponentRegistry result = this.cache.getComponentRegistry();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getDistributionManager()
+   {
+      DistributionManager expected = EasyMock.createStrictMock(DistributionManager.class);
+      
+      EasyMock.expect(this.advancedCache.getDistributionManager()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      DistributionManager result = this.cache.getDistributionManager();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void lock()
+   {
+      Object key = new Object();
+      
+      this.advancedCache.lock(EasyMock.same(key));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.lock(key);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void lockMany()
+   {
+      Collection<Object> keys = Collections.emptyList();
+      
+      this.advancedCache.lock(EasyMock.same(keys));
+      
+      EasyMock.replay(this.advancedCache);
+      
+      this.cache.lock(keys);
+      
+      EasyMock.verify(this.advancedCache);
+   }
+
+   @Test
+   public void getRpcManager()
+   {
+      RpcManager expected = EasyMock.createStrictMock(RpcManager.class);
+      
+      EasyMock.expect(this.advancedCache.getRpcManager()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      RpcManager result = this.cache.getRpcManager();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getBatchContainer()
+   {
+      BatchContainer expected = new BatchContainer();
+      
+      EasyMock.expect(this.advancedCache.getBatchContainer()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      BatchContainer result = this.cache.getBatchContainer();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getInvocationContextContainer()
+   {
+      InvocationContextContainer expected = EasyMock.createStrictMock(InvocationContextContainer.class);
+      
+      EasyMock.expect(this.advancedCache.getInvocationContextContainer()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      InvocationContextContainer result = this.cache.getInvocationContextContainer();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getDataContainer()
+   {
+      DataContainer expected = EasyMock.createStrictMock(DataContainer.class);
+      
+      EasyMock.expect(this.advancedCache.getDataContainer()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      DataContainer result = this.cache.getDataContainer();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getTransactionManager()
+   {
+      TransactionManager expected = EasyMock.createStrictMock(TransactionManager.class);
+      
+      EasyMock.expect(this.advancedCache.getTransactionManager()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      TransactionManager result = this.cache.getTransactionManager();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+
+   @Test
+   public void getStats()
+   {
+      Stats expected = EasyMock.createStrictMock(Stats.class);
+      
+      EasyMock.expect(this.advancedCache.getStats()).andReturn(expected);
+      
+      EasyMock.replay(this.advancedCache);
+      
+      Stats result = this.cache.getStats();
+      
+      EasyMock.verify(this.advancedCache);
+      
+      Assert.assertSame(expected, result);
+   }
+}

Modified: projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerFactoryTest.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerFactoryTest.java	2010-08-23 20:03:55 UTC (rev 107742)
+++ projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerFactoryTest.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jboss.ha.ispn;
 
 import java.net.URL;
@@ -17,6 +38,10 @@
 import org.jgroups.JChannel;
 import org.junit.Test;
 
+/**
+ * @author Paul Ferraro
+ *
+ */
 @SuppressWarnings("deprecation")
 public class DefaultCacheContainerFactoryTest
 {

Modified: projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerRegistryTest.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerRegistryTest.java	2010-08-23 20:03:55 UTC (rev 107742)
+++ projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerRegistryTest.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jboss.ha.ispn;
 
 import java.util.Arrays;
@@ -14,10 +35,11 @@
 import org.easymock.Capture;
 import org.easymock.CaptureType;
 import org.easymock.EasyMock;
-import org.infinispan.Cache;
+import org.infinispan.AdvancedCache;
 import org.infinispan.config.Configuration;
 import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
 import org.jboss.ha.ispn.config.Alias;
 import org.jboss.ha.ispn.config.CacheContainerRegistryConfiguration;
 import org.jboss.ha.ispn.config.CacheContainerRegistryConfigurationEntry;
@@ -25,6 +47,10 @@
 import org.jboss.util.naming.NonSerializableFactory;
 import org.junit.Test;
 
+/**
+ * @author Paul Ferraro
+ *
+ */
 public class DefaultCacheContainerRegistryTest
 {
    /**
@@ -36,8 +62,8 @@
    {
       CacheContainerFactory factory = EasyMock.createStrictMock(CacheContainerFactory.class);
       CacheContainerRegistryConfigurationSource source = EasyMock.createStrictMock(CacheContainerRegistryConfigurationSource.class);
-      CacheContainer defaultCacheManager = EasyMock.createStrictMock(CacheContainer.class);
-      CacheContainer otherCacheManager = EasyMock.createStrictMock(CacheContainer.class);
+      EmbeddedCacheManager defaultContainer = EasyMock.createStrictMock(EmbeddedCacheManager.class);
+      EmbeddedCacheManager otherContainer = EasyMock.createStrictMock(EmbeddedCacheManager.class);
       Context context = EasyMock.createNiceMock(Context.class);
       Capture<Reference> capturedReferences = new Capture<Reference>(CaptureType.ALL);
       
@@ -62,33 +88,27 @@
       
       EasyMock.expect(source.getRegistryConfiguration()).andReturn(configRegistry);
       
-      EasyMock.expect(factory.createCacheContainer(EasyMock.same(defaultConfig))).andReturn(defaultCacheManager);
+      EasyMock.expect(factory.createCacheContainer(EasyMock.same(defaultConfig))).andReturn(defaultContainer);
       EasyMock.expect(context.composeName("default", "java:CacheManager")).andReturn("java:CacheManager/default");
       
       context.rebind(EasyMock.eq("java:CacheManager/default"), EasyMock.capture(capturedReferences));
 
-      EasyMock.expect(factory.createCacheContainer(EasyMock.same(otherConfig))).andReturn(otherCacheManager);
+      EasyMock.expect(factory.createCacheContainer(EasyMock.same(otherConfig))).andReturn(otherContainer);
       EasyMock.expect(context.composeName("other", "java:CacheManager")).andReturn("java:CacheManager/other");
       
       context.rebind(EasyMock.eq("java:CacheManager/other"), EasyMock.capture(capturedReferences));
 
-      EasyMock.replay(factory, source, context, defaultCacheManager, otherCacheManager);
+      EasyMock.replay(factory, source, context, defaultContainer, otherContainer);
       
       registry.start();
       
-      EasyMock.verify(factory, source, context, defaultCacheManager, otherCacheManager);
+      EasyMock.verify(factory, source, context, defaultContainer, otherContainer);
       
       Set<String> names = registry.getCacheContainers();
       Assert.assertEquals(2, names.size());
       Assert.assertTrue(names.contains("default"));
       Assert.assertTrue(names.contains("other"));
       
-      Assert.assertSame(defaultCacheManager, registry.getCacheContainer());
-      Assert.assertSame(defaultCacheManager, registry.getCacheContainer(null));
-      Assert.assertSame(defaultCacheManager, registry.getCacheContainer("default"));
-      Assert.assertSame(defaultCacheManager, registry.getCacheContainer("unknown"));
-      Assert.assertSame(otherCacheManager, registry.getCacheContainer("other"));
-
       Assert.assertSame(registry, DefaultCacheContainerRegistry.getInstance());
       
       List<Reference> references = capturedReferences.getValues();
@@ -97,34 +117,53 @@
       RefAddr addr = reference.get("nns");
       Assert.assertNotNull(addr);
       Assert.assertEquals("java:CacheManager/default", addr.getContent());
-      Assert.assertSame(defaultCacheManager, NonSerializableFactory.lookup("java:CacheManager/default"));
+      Assert.assertSame(registry.getCacheContainer("default"), NonSerializableFactory.lookup("java:CacheManager/default"));
       reference = references.get(1);
       addr = reference.get("nns");
       Assert.assertNotNull(addr);
       Assert.assertEquals("java:CacheManager/other", addr.getContent());
-      Assert.assertSame(otherCacheManager, NonSerializableFactory.lookup("java:CacheManager/other"));
+      Assert.assertSame(registry.getCacheContainer("other"), NonSerializableFactory.lookup("java:CacheManager/other"));
       
-      EasyMock.reset(factory, source, context, defaultCacheManager, otherCacheManager);
+      EasyMock.reset(factory, source, context, defaultContainer, otherContainer);
+
       
+      this.verifyContainer(defaultContainer, registry.getCacheContainer());
+      this.verifyContainer(defaultContainer, registry.getCacheContainer(null));
+      this.verifyContainer(defaultContainer, registry.getCacheContainer("default"));
+      this.verifyContainer(defaultContainer, registry.getCacheContainer("unknown"));
+      this.verifyContainer(otherContainer, registry.getCacheContainer("other"));
       
-      defaultCacheManager.stop();
+      
+      defaultContainer.stop();
       context.unbind("java:CacheManager/default");
-      otherCacheManager.stop();
+      otherContainer.stop();
       context.unbind("java:CacheManager/other");
       
-      EasyMock.replay(factory, source, context, defaultCacheManager, otherCacheManager);
+      EasyMock.replay(factory, source, context, defaultContainer, otherContainer);
       
       registry.stop();
       
-      EasyMock.verify(factory, source, context, defaultCacheManager, otherCacheManager);
+      EasyMock.verify(factory, source, context, defaultContainer, otherContainer);
 
       Assert.assertNull(DefaultCacheContainerRegistry.getInstance());
       Assert.assertNull(NonSerializableFactory.lookup("java:CacheManager/default"));
       Assert.assertNull(NonSerializableFactory.lookup("java:CacheManager/other"));
       
-      EasyMock.reset(factory, source, context, defaultCacheManager, otherCacheManager);
+      EasyMock.reset(factory, source, context, defaultContainer, otherContainer);
    }
    
+   private void verifyContainer(CacheContainer mockContainer, CacheContainer container)
+   {
+      mockContainer.start();
+      
+      EasyMock.replay(mockContainer);
+      
+      container.start();
+      
+      EasyMock.verify(mockContainer);
+      EasyMock.reset(mockContainer);
+   }
+   
    /**
     * Test with custom default config and custom base jndi name
     * @throws Exception
@@ -134,8 +173,8 @@
    {
       CacheContainerFactory factory = EasyMock.createStrictMock(CacheContainerFactory.class);
       CacheContainerRegistryConfigurationSource provider = EasyMock.createStrictMock(CacheContainerRegistryConfigurationSource.class);
-      CacheContainer defaultCacheManager = EasyMock.createStrictMock(CacheContainer.class);
-      CacheContainer otherCacheManager = EasyMock.createStrictMock(CacheContainer.class);
+      EmbeddedCacheManager defaultContainer = EasyMock.createStrictMock(EmbeddedCacheManager.class);
+      EmbeddedCacheManager otherContainer = EasyMock.createStrictMock(EmbeddedCacheManager.class);
       Context context = EasyMock.createStrictMock(Context.class);
       Capture<Reference> capturedReferences = new Capture<Reference>(CaptureType.ALL);
       
@@ -173,36 +212,26 @@
       
       EasyMock.expect(provider.getRegistryConfiguration()).andReturn(configRegistry);
       
-      EasyMock.expect(factory.createCacheContainer(EasyMock.same(otherConfig))).andReturn(otherCacheManager);
+      EasyMock.expect(factory.createCacheContainer(EasyMock.same(otherConfig))).andReturn(otherContainer);
       
       context.rebind(EasyMock.eq("java:other"), EasyMock.capture(capturedReferences));
 
-      EasyMock.expect(factory.createCacheContainer(EasyMock.same(defaultConfig))).andReturn(defaultCacheManager);
+      EasyMock.expect(factory.createCacheContainer(EasyMock.same(defaultConfig))).andReturn(defaultContainer);
       EasyMock.expect(context.composeName("default", "java:Infinispan")).andReturn("java:Infinispan/default");
       
       context.rebind(EasyMock.eq("java:Infinispan/default"), EasyMock.capture(capturedReferences));
 
-      EasyMock.replay(factory, provider, context, defaultCacheManager, otherCacheManager);
+      EasyMock.replay(factory, provider, context, defaultContainer, otherContainer);
       
       registry.start();
       
-      EasyMock.verify(factory, provider, context, defaultCacheManager, otherCacheManager);
+      EasyMock.verify(factory, provider, context, defaultContainer, otherContainer);
       
       Set<String> names = registry.getCacheContainers();
       Assert.assertEquals(2, names.size());
       Assert.assertTrue(names.contains("default"));
       Assert.assertTrue(names.contains("other"));
       
-      CacheContainer defaultContainer = registry.getCacheContainer();
-      
-      Assert.assertSame(defaultContainer, registry.getCacheContainer(null));
-      Assert.assertSame(defaultContainer, registry.getCacheContainer("default"));
-      Assert.assertSame(defaultContainer, registry.getCacheContainer("unknown"));
-      
-      CacheContainer otherContainer = registry.getCacheContainer("other");
-      
-      Assert.assertNotSame(defaultContainer, otherContainer);
-      
       Assert.assertSame(registry, DefaultCacheContainerRegistry.getInstance());
       
       List<Reference> references = capturedReferences.getValues();
@@ -211,54 +240,59 @@
       RefAddr addr = reference.get("nns");
       Assert.assertNotNull(addr);
       Assert.assertEquals("java:other", addr.getContent());
-      Assert.assertSame(otherContainer, NonSerializableFactory.lookup("java:other"));
+      Assert.assertSame(registry.getCacheContainer("other"), NonSerializableFactory.lookup("java:other"));
       reference = references.get(1);
       addr = reference.get("nns");
       Assert.assertNotNull(addr);
       Assert.assertEquals("java:Infinispan/default", addr.getContent());
-      Assert.assertSame(defaultContainer, NonSerializableFactory.lookup("java:Infinispan/default"));
+      Assert.assertSame(registry.getCacheContainer("default"), NonSerializableFactory.lookup("java:Infinispan/default"));
       
-      EasyMock.reset(factory, provider, context, defaultCacheManager, otherCacheManager);
+      EasyMock.reset(factory, provider, context, defaultContainer, otherContainer);
       
-      this.verifyCacheAlias(defaultContainer, defaultCacheManager, "default-cache", "default-cache");
-      this.verifyCacheAlias(defaultContainer, defaultCacheManager, "legacy-default-cache", "default-cache");
+      this.verifyContainer(defaultContainer, registry.getCacheContainer());
+      this.verifyContainer(defaultContainer, registry.getCacheContainer(null));
+      this.verifyContainer(defaultContainer, registry.getCacheContainer("default"));
+      this.verifyContainer(defaultContainer, registry.getCacheContainer("unknown"));
+      this.verifyContainer(otherContainer, registry.getCacheContainer("other"));
+            
+      this.verifyCacheAlias(defaultContainer, registry.getCacheContainer("default"), "default-cache", "default-cache");
+      this.verifyCacheAlias(defaultContainer, registry.getCacheContainer("default"), "legacy-default-cache", "default-cache");
       
-      this.verifyCacheAlias(otherContainer, otherCacheManager, "other-cache", "other-cache");
-      this.verifyCacheAlias(otherContainer, otherCacheManager, "legacy-other-cache", "other-cache");
+      this.verifyCacheAlias(otherContainer, registry.getCacheContainer("other"), "other-cache", "other-cache");
+      this.verifyCacheAlias(otherContainer, registry.getCacheContainer("other"), "legacy-other-cache", "other-cache");
       
-      defaultCacheManager.stop();
+      defaultContainer.stop();
       context.unbind("java:Infinispan/default");
-      otherCacheManager.stop();
+      otherContainer.stop();
       context.unbind("java:other");
       
-      EasyMock.replay(factory, context, defaultCacheManager, otherCacheManager);
+      EasyMock.replay(factory, context, defaultContainer, otherContainer);
       
       registry.stop();
       
-      EasyMock.verify(factory, context, defaultCacheManager, otherCacheManager);
+      EasyMock.verify(factory, context, defaultContainer, otherContainer);
       
       Assert.assertNull(DefaultCacheContainerRegistry.getInstance());
       Assert.assertNull(NonSerializableFactory.lookup("java:other"));
       Assert.assertNull(NonSerializableFactory.lookup("java:Infinispan/default"));
       
-      EasyMock.reset(factory, context, defaultCacheManager, otherCacheManager);
+      EasyMock.reset(factory, context, defaultContainer, otherContainer);
    }
    
-   private void verifyCacheAlias(CacheContainer container, CacheContainer mockContainer, String cacheName, String expectedCacheName)
+   private void verifyCacheAlias(CacheContainer mockContainer, CacheContainer container, String cacheName, String expectedCacheName)
    {
       @SuppressWarnings("unchecked")
-      Cache<Object, Object> cache = EasyMock.createMock(Cache.class);
+      AdvancedCache<Object, Object> cache = EasyMock.createMock(AdvancedCache.class);
       
       EasyMock.expect(mockContainer.getCache(expectedCacheName)).andReturn(cache);
+      EasyMock.expect(cache.getAdvancedCache()).andReturn(cache);
+      cache.start();
       
-      EasyMock.replay(mockContainer);
+      EasyMock.replay(mockContainer, cache);
       
-      Cache<Object, Object> result = container.getCache(cacheName);
+      container.getCache(cacheName).start();
 
-      EasyMock.verify(mockContainer);
-      
-      Assert.assertSame(cache, result);
-      
-      EasyMock.reset(mockContainer);
+      EasyMock.verify(mockContainer, cache);
+      EasyMock.reset(mockContainer, cache);
    }
 }

Added: projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerTest.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerTest.java	                        (rev 0)
+++ projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerTest.java	2010-08-23 20:52:59 UTC (rev 107743)
@@ -0,0 +1,318 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jboss.ha.ispn;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import org.easymock.EasyMock;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.remoting.transport.Address;
+import org.junit.After;
+import org.junit.Test;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class DefaultCacheContainerTest
+{
+   private final EmbeddedCacheManager mock = EasyMock.createStrictMock(EmbeddedCacheManager.class);
+   private final EmbeddedCacheManager container = new DefaultCacheContainer(this.mock, Collections.singletonMap("alias", "default"));
+
+   @After
+   public void reset()
+   {
+      EasyMock.reset(this.mock);
+   }
+   
+   @Test
+   public void getCache()
+   {
+      @SuppressWarnings("unchecked")
+      Cache<Object, Object> cache = EasyMock.createMock(Cache.class);
+      
+      EasyMock.expect(this.mock.getCache()).andReturn(cache);
+
+      EasyMock.replay(this.mock);
+      
+      Cache<Object, Object> result = this.container.getCache();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertNotSame(cache, result);
+      Assert.assertSame(this.container, result.getCacheManager());
+   }
+   
+   @Test
+   public void getNamedCache()
+   {
+      @SuppressWarnings("unchecked")
+      Cache<Object, Object> cache = EasyMock.createMock(Cache.class);
+      
+      EasyMock.expect(this.mock.getCache("test")).andReturn(cache);
+
+      EasyMock.replay(this.mock);
+      
+      Cache<Object, Object> result = this.container.getCache("test");
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertNotSame(cache, result);
+      Assert.assertSame(this.container, result.getCacheManager());
+   }
+
+   @Test
+   public void start()
+   {
+      this.mock.start();
+
+      EasyMock.replay(this.mock);
+      
+      this.container.start();
+      
+      EasyMock.verify(this.mock);      
+   }
+   
+   @Test
+   public void stop()
+   {
+      this.mock.start();
+
+      EasyMock.replay(this.mock);
+      
+      this.container.start();
+      
+      EasyMock.verify(this.mock);      
+   }
+   
+   @Test
+   public void addListener()
+   {
+      Object listener = new Object();
+      
+      this.mock.addListener(EasyMock.same(listener));
+
+      EasyMock.replay(this.mock);
+      
+      this.container.addListener(listener);
+      
+      EasyMock.verify(this.mock);      
+   }
+   
+   @Test
+   public void removeListener()
+   {
+      Object listener = new Object();
+      
+      this.mock.removeListener(EasyMock.same(listener));
+
+      EasyMock.replay(this.mock);
+      
+      this.container.removeListener(listener);
+      
+      EasyMock.verify(this.mock);      
+   }
+   
+   @Test
+   public void getListeners()
+   {
+      Set<Object> expected = Collections.emptySet();
+      
+      EasyMock.expect(this.mock.getListeners()).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      Set<Object> result = this.container.getListeners();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void defineConfiguration()
+   {
+      Configuration expected = new Configuration();
+      Configuration override = new Configuration();
+      
+      EasyMock.expect(this.mock.defineConfiguration(EasyMock.eq("test"), EasyMock.same(override))).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      Configuration result = this.container.defineConfiguration("test", override);
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void defineConfigurationFromTemplate()
+   {
+      Configuration expected = new Configuration();
+      Configuration override = new Configuration();
+      
+      EasyMock.expect(this.mock.defineConfiguration(EasyMock.eq("test"), EasyMock.eq("template"), EasyMock.same(override))).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      Configuration result = this.container.defineConfiguration("test", "template", override);
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void getClusterName()
+   {
+      String expected = "cluster";
+      
+      EasyMock.expect(this.mock.getClusterName()).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      String result = this.container.getClusterName();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void getMembers()
+   {
+      List<Address> expected = Collections.emptyList();
+      
+      EasyMock.expect(this.mock.getMembers()).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      List<Address> result = this.container.getMembers();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void getAddress()
+   {
+      Address expected = EasyMock.createMock(Address.class);
+      
+      EasyMock.expect(this.mock.getAddress()).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      Address result = this.container.getAddress();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void isCoordinator()
+   {
+      EasyMock.expect(this.mock.isCoordinator()).andReturn(true);
+      
+      EasyMock.replay(this.mock);
+
+      boolean result = this.container.isCoordinator();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertTrue(result);
+   }
+   
+   @Test
+   public void getStatus()
+   {
+      ComponentStatus expected = ComponentStatus.INITIALIZING;
+      
+      EasyMock.expect(this.mock.getStatus()).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      ComponentStatus result = this.container.getStatus();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void getGlobalConfiguration()
+   {
+      GlobalConfiguration expected = new GlobalConfiguration();
+      
+      EasyMock.expect(this.mock.getGlobalConfiguration()).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      GlobalConfiguration result = this.container.getGlobalConfiguration();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void getDefaultConfiguration()
+   {
+      Configuration expected = new Configuration();
+      
+      EasyMock.expect(this.mock.getDefaultConfiguration()).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      Configuration result = this.container.getDefaultConfiguration();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+   
+   @Test
+   public void getCacheNames()
+   {
+      Set<String> expected = Collections.emptySet();
+      
+      EasyMock.expect(this.mock.getCacheNames()).andReturn(expected);
+      
+      EasyMock.replay(this.mock);
+      
+      Set<String> result = this.container.getCacheNames();
+      
+      EasyMock.verify(this.mock);
+      
+      Assert.assertSame(expected, result);
+   }
+}



More information about the jboss-cvs-commits mailing list