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

Vladmir Blagojevic vladimir.blagojevic at jboss.com
Mon Sep 11 09:54:11 EDT 2006


  User: vblagojevic
  Date: 06/09/11 09:54:11

  Modified:    tests/functional/org/jboss/cache/loader 
                        CacheLoaderTestsBase.java
  Log:
  improve testLoadAndStore exception handling
  
  Revision  Changes    Path
  1.30      +21 -12    JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderTestsBase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderTestsBase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderTestsBase.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -b -r1.29 -r1.30
  --- CacheLoaderTestsBase.java	6 Sep 2006 15:30:58 -0000	1.29
  +++ CacheLoaderTestsBase.java	11 Sep 2006 13:54:11 -0000	1.30
  @@ -30,7 +30,7 @@
    * Commons tests for all CacheLoaders
    *
    * @author Bela Ban
  - * @version $Id: CacheLoaderTestsBase.java,v 1.29 2006/09/06 15:30:58 msurtani Exp $
  + * @version $Id: CacheLoaderTestsBase.java,v 1.30 2006/09/11 13:54:11 vblagojevic Exp $
    */
   abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
   {
  @@ -1662,34 +1662,43 @@
         assertEquals(2, loader.get(FQN).size());
   
         // Save state
  -      byte[] state = null;
  +      byte[] state = new byte[0];
  +      ByteArrayOutputStream baos = null;
  +      MarshalledValueOutputStream os = null;
         try
         {
  -         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
  -         MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
  +         baos = new ByteArrayOutputStream(1024);
  +         os = new MarshalledValueOutputStream(baos);
            loader.loadEntireState(os);
  -         os.writeObject(StateTransferManager.STREAMING_DELIMETER_NODE);
  -         os.close();
  -         assertTrue(baos.size() > 0);
  -         state = baos.toByteArray();
         }
         catch (UnsupportedOperationException ex)
         {
            System.out.println("caught unsupported operation exception (this is expected): " + ex);
         }
  +      finally
  +      {
  +         os.writeObject(StateTransferManager.STREAMING_DELIMETER_NODE);
  +         os.close();
  +         assertTrue(baos.size() > 0);
  +         state = baos.toByteArray();
  +      }
   
         /* Restore state. */
  +      MarshalledValueInputStream is =null;
         try
         {
            ByteArrayInputStream bais = new ByteArrayInputStream(state);
  -         MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
  +         is = new MarshalledValueInputStream(bais);
            loader.storeEntireState(is);
  -         is.close();
         }
         catch (UnsupportedOperationException ex)
         {
            System.out.println("caught unsupported operation exception (this is expected): " + ex);
         }
  +      finally
  +      {
  +         is.close();
  +      }
   
         addDelay();
         assertEquals(c1, loader.get(FQN).get(new Integer(1)));
  
  
  



More information about the jboss-cvs-commits mailing list