[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/statetransfer ...

Vladmir Blagojevic vladimir.blagojevic at jboss.com
Thu Sep 7 13:42:29 EDT 2006


  User: vblagojevic
  Date: 06/09/07 13:42:29

  Modified:    tests/functional/org/jboss/cache/statetransfer   
                        StateTransferTestBase.java
                        StateTransfer200Test.java
  Added:       tests/functional/org/jboss/cache/statetransfer   
                        CorruptedFileCacheLoader.java
  Log:
  test state transfer error handling
  
  Revision  Changes    Path
  1.20      +29 -8     JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransferTestBase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: StateTransferTestBase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransferTestBase.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -b -r1.19 -r1.20
  --- StateTransferTestBase.java	20 Jul 2006 21:58:21 -0000	1.19
  +++ StateTransferTestBase.java	7 Sep 2006 17:42:29 -0000	1.20
  @@ -81,6 +81,19 @@
                                           boolean startCache) 
         throws Exception
      {
  +     if(useCacheLoader)
  +     {
  +        return createCache(cacheID, sync, useMarshalling, "org.jboss.cache.loader.FileCacheLoader", cacheLoaderAsync, startCache);
  +     }
  +     else
  +     {
  +        return createCache(cacheID, sync, useMarshalling, null, cacheLoaderAsync, startCache);
  +     }
  +   }
  +   
  +   protected CacheSPI createCache(String cacheID, boolean sync, boolean useMarshalling,String cacheLoaderClass,
  +         boolean cacheLoaderAsync, boolean startCache) throws Exception
  +   {
         if (caches.get(cacheID) != null)
            throw new IllegalStateException(cacheID + " already created");
         
  @@ -99,8 +112,9 @@
            c.setUseRegionBasedMarshalling(true);
            c.setInactiveOnStartup(true);
         }
  -      if (useCacheLoader) {
  -         configureCacheLoader(c, cacheID, useMarshalling, cacheLoaderAsync);
  +      if (cacheLoaderClass!=null && cacheLoaderClass.length()>0)
  +      {
  +         configureCacheLoader(c,cacheLoaderClass,cacheID, useMarshalling, cacheLoaderAsync);
         }
   //      tree.setConfiguration(c);
         CacheFactory factory = new DefaultCacheFactory();
  @@ -130,6 +144,12 @@
                                          boolean async) 
         throws Exception
      {
  +      configureCacheLoader(c, "org.jboss.cache.loader.FileCacheLoader", cacheID, useExtended, async);          
  +   }
  +   
  +   protected void configureCacheLoader(Configuration c, String cacheloaderClass, String cacheID, boolean useExtended, boolean async)
  +         throws Exception
  +   {
         String tmp_location = getTempLocation(cacheID);
         
         // Do cleanup in case it failed before
  @@ -140,7 +160,8 @@
         
         tmp_location = escapeWindowsPath(tmp_location);
         
  -      c.setCacheLoaderConfiguration(getCacheLoaderConfig("org.jboss.cache.loader.FileCacheLoader", tmp_location, async));
  +      c.setCacheLoaderConfiguration(getCacheLoaderConfig(cacheloaderClass, tmp_location,
  +                  async));
      }
   
      protected Element getCacheLoaderConfig(String cl, String loc, boolean async) throws Exception
  
  
  
  1.7       +18 -1     JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransfer200Test.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: StateTransfer200Test.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransfer200Test.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- StateTransfer200Test.java	5 Sep 2006 16:57:49 -0000	1.6
  +++ StateTransfer200Test.java	7 Sep 2006 17:42:29 -0000	1.7
  @@ -23,7 +23,7 @@
    * Tests that state transfer works properly if the version is 2.0.0.GA.
    *
    * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class StateTransfer200Test extends VersionedTestBase
   {
  @@ -95,6 +95,23 @@
         assertEquals("/a/d state integrated in backup region", JANE, cache1.get(test, "name"));
      }
   
  +   public void testCacheLoaderFailure() throws Exception
  +   {
  +      CacheSPI cache1 = createCache("cache1", false, false, "org.jboss.cache.statetransfer.CorruptedFileCacheLoader",false,true);
  +
  +      cache1.put(A_B, "name", JOE);
  +      cache1.put(A_B, "age", TWENTY);
  +      cache1.put(A_C, "name", BOB);
  +      cache1.put(A_C, "age", FORTY);
  +
  +      CacheSPI cache2 = createCache("cache2", false, false, true,false,true);            
  +      // Pause to give caches time to see each other
  +      TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
  +      
  +      //when persistent transfer fails as in this case state recipient cacheloader should be wiped clean
  +      assertFalse("/a/b is not in cache loader ",cache2.getCacheLoader().exists(A_B));
  +   }
  +
   
      private Element getBuddyConfig() throws Exception
      {
  
  
  
  1.1      date: 2006/09/07 17:42:29;  author: vblagojevic;  state: Exp;JBossCache/tests/functional/org/jboss/cache/statetransfer/CorruptedFileCacheLoader.java
  
  Index: CorruptedFileCacheLoader.java
  ===================================================================
  package org.jboss.cache.statetransfer;
  
  import java.io.IOException;
  import java.io.ObjectOutputStream;
  import org.jboss.cache.Fqn;
  import org.jboss.cache.loader.FileCacheLoader;
  
  public class CorruptedFileCacheLoader extends FileCacheLoader
  {  
     public CorruptedFileCacheLoader()
     {
        super();      
     }
     
     @Override
     public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
     {
        super.loadState(subtree, os);
        throw new IOException("see StateTransfer200Test#testCacheLoaderFailure()");
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list