[jboss-cvs] JBossAS SVN: r108994 - projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 29 11:35:29 EDT 2010


Author: pferraro
Date: 2010-10-29 11:35:29 -0400 (Fri, 29 Oct 2010)
New Revision: 108994

Modified:
   projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerTest.java
Log:
Ensure our @CacheStopped listener is invoked last.
Allow more transparency between singleton cache container and parent cache container.

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-10-29 15:35:17 UTC (rev 108993)
+++ projects/cluster/ha-server-ispn/trunk/src/test/java/org/jboss/ha/ispn/DefaultCacheContainerTest.java	2010-10-29 15:35:29 UTC (rev 108994)
@@ -54,37 +54,29 @@
    @Test
    public void getDefaultCache()
    {
-      @SuppressWarnings("unchecked")
-      Cache<Object, Object> cache = this.control.createMock(Cache.class);
-      
-      EasyMock.expect(this.manager.<Object, Object>getCache()).andReturn(cache);
-      
-      this.control.replay();
-      
-      Cache<Object, Object> result = this.container.getCache();
-      
-      this.control.verify();
-      
-      Assert.assertSame(cache, result);
-      
-      this.control.reset();
+      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);
    }
    
    @Test
    public void getCache()
    {
-      this.getCache(CacheMode.DIST_ASYNC, true);
-      this.getCache(CacheMode.DIST_SYNC, true);
-      this.getCache(CacheMode.INVALIDATION_ASYNC, false);
-      this.getCache(CacheMode.INVALIDATION_SYNC, false);
-      this.getCache(CacheMode.LOCAL, false);
-      this.getCache(CacheMode.REPL_ASYNC, false);
-      this.getCache(CacheMode.REPL_SYNC, false);
+      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);
    }
    
-   private void getCache(CacheMode mode, boolean singleton)
+   private void getCache(String cacheName, CacheMode mode, boolean singleton)
    {
-      String cacheName = "test";
       Configuration config = new Configuration();
       config.setCacheMode(mode);
       @SuppressWarnings("unchecked")
@@ -93,7 +85,14 @@
       global.setClusterName("cluster");
       Object listener = new DummyListener();
       
-      EasyMock.expect(this.manager.defineConfiguration(cacheName, new Configuration())).andReturn(config);
+      if (cacheName.equals(CacheContainer.DEFAULT_CACHE_NAME))
+      {
+         EasyMock.expect(this.manager.getDefaultConfiguration()).andReturn(config);
+      }
+      else
+      {
+         EasyMock.expect(this.manager.defineConfiguration(cacheName, new Configuration())).andReturn(config);
+      }
       
       if (singleton)
       {
@@ -107,7 +106,7 @@
       
       this.control.replay();
       
-      Cache<Object, Object> result = this.container.getCache(cacheName);
+      Cache<Object, Object> result = (CacheContainer.DEFAULT_CACHE_NAME == cacheName) ? this.container.getCache() : this.container.getCache(cacheName);
       
       this.control.verify();
       
@@ -118,8 +117,8 @@
          EmbeddedCacheManager manager = (EmbeddedCacheManager) result.getCacheManager();
          Assert.assertEquals(config, manager.getDefaultConfiguration());
          GlobalConfiguration globalConfig = manager.getGlobalConfiguration();
-         Assert.assertEquals("cluster/test", globalConfig.getClusterName());
-         Assert.assertEquals("cluster/test", globalConfig.getTransportProperties().getProperty("clusterId"));
+         Assert.assertEquals("cluster/" + cacheName, globalConfig.getClusterName());
+         Assert.assertEquals("cluster/" + cacheName, globalConfig.getTransportProperties().getProperty("clusterId"));
          Assert.assertEquals(CacheContainer.DEFAULT_CACHE_NAME, result.getName());
          Set<Object> listeners = manager.getListeners();
          Assert.assertTrue(listeners.contains(this.container));



More information about the jboss-cvs-commits mailing list