[jboss-cvs] JBossAS SVN: r109260 - 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
Wed Nov 10 21:13:01 EST 2010


Author: pferraro
Date: 2010-11-10 21:13:00 -0500 (Wed, 10 Nov 2010)
New Revision: 109260

Modified:
   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/DefaultCacheContainerTest.java
Log:
Support getCache(CacheContainer.DEFAULT_CACHE_NAME)

Modified: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainer.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainer.java	2010-11-10 21:09:30 UTC (rev 109259)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainer.java	2010-11-11 02:13:00 UTC (rev 109260)
@@ -63,13 +63,13 @@
    @Override
    public <K, V> Cache<K, V> getCache()
    {
-      return this.getCache(CacheContainer.DEFAULT_CACHE_NAME, this.container.getDefaultConfiguration());
+      return this.getCache(CacheContainer.DEFAULT_CACHE_NAME);
    }
 
    @Override
    public <K, V> Cache<K, V> getCache(String cacheName)
    {
-      return this.getCache(cacheName, this.container.defineConfiguration(cacheName, new Configuration()));
+      return this.getCache(cacheName, cacheName.equals(CacheContainer.DEFAULT_CACHE_NAME) ? this.container.getDefaultConfiguration() : this.container.defineConfiguration(cacheName, new Configuration()));
    }
    
    // Until ISPN-658 is fixed, we need to create a separate adhoc cache manager if requested cache uses DIST mode.

Modified: 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	2010-11-10 21:09:30 UTC (rev 109259)
+++ projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerTest.java	2010-11-11 02:13:00 UTC (rev 109260)
@@ -54,28 +54,28 @@
    @Test
    public void getDefaultCache()
    {
-      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, CacheMode.DIST_ASYNC, true);
-      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, CacheMode.DIST_SYNC, true);
-      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, CacheMode.INVALIDATION_ASYNC, false);
-      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, CacheMode.INVALIDATION_SYNC, false);
-      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, CacheMode.LOCAL, false);
-      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, CacheMode.REPL_ASYNC, false);
-      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, CacheMode.REPL_SYNC, false);
+      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, true, CacheMode.DIST_ASYNC, true);
+      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, true, CacheMode.DIST_SYNC, true);
+      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, true, CacheMode.INVALIDATION_ASYNC, false);
+      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, true, CacheMode.INVALIDATION_SYNC, false);
+      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, true, CacheMode.LOCAL, false);
+      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, true, CacheMode.REPL_ASYNC, false);
+      this.getCache(CacheContainer.DEFAULT_CACHE_NAME, true, CacheMode.REPL_SYNC, false);
    }
    
    @Test
    public void getCache()
    {
-      this.getCache("test", CacheMode.DIST_ASYNC, true);
-      this.getCache("test", CacheMode.DIST_SYNC, true);
-      this.getCache("test", CacheMode.INVALIDATION_ASYNC, false);
-      this.getCache("test", CacheMode.INVALIDATION_SYNC, false);
-      this.getCache("test", CacheMode.LOCAL, false);
-      this.getCache("test", CacheMode.REPL_ASYNC, false);
-      this.getCache("test", CacheMode.REPL_SYNC, false);
+      this.getCache("test", false, CacheMode.DIST_ASYNC, true);
+      this.getCache("test", false, CacheMode.DIST_SYNC, true);
+      this.getCache("test", false, CacheMode.INVALIDATION_ASYNC, false);
+      this.getCache("test", false, CacheMode.INVALIDATION_SYNC, false);
+      this.getCache("test", false, CacheMode.LOCAL, false);
+      this.getCache("test", false, CacheMode.REPL_ASYNC, false);
+      this.getCache("test", false, CacheMode.REPL_SYNC, false);
    }
    
-   private void getCache(String cacheName, CacheMode mode, boolean singleton)
+   private void getCache(String cacheName, boolean useDefault, CacheMode mode, boolean singleton)
    {
       Configuration config = new Configuration();
       config.setCacheMode(mode);
@@ -85,7 +85,7 @@
       global.setClusterName("cluster");
       Object listener = new DummyListener();
       
-      if (cacheName.equals(CacheContainer.DEFAULT_CACHE_NAME))
+      if (useDefault)
       {
          EasyMock.expect(this.manager.getDefaultConfiguration()).andReturn(config);
       }
@@ -106,7 +106,7 @@
       
       this.control.replay();
       
-      Cache<Object, Object> result = (CacheContainer.DEFAULT_CACHE_NAME == cacheName) ? this.container.getCache() : this.container.getCache(cacheName);
+      Cache<Object, Object> result = this.container.getCache(cacheName);
       
       this.control.verify();
       
@@ -134,7 +134,14 @@
       
       // Validate 2nd attempt
       
-      EasyMock.expect(this.manager.defineConfiguration(cacheName, new Configuration())).andReturn(config);
+      if (useDefault)
+      {
+         EasyMock.expect(this.manager.getDefaultConfiguration()).andReturn(config);
+      }
+      else
+      {
+         EasyMock.expect(this.manager.defineConfiguration(cacheName, new Configuration())).andReturn(config);
+      }
       
       if (singleton)
       {



More information about the jboss-cvs-commits mailing list