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

Manik Surtani msurtani at belmont.prod.atl2.jboss.com
Wed Aug 30 14:32:17 EDT 2006


  User: msurtani
  Date: 06/08/30 14:32:17

  Modified:    tests/functional/org/jboss/cache/eviction 
                        ReplicatedAopLRUPolicyTest.java
  Log:
  Fixed some failing tests
  
  Revision  Changes    Path
  1.9       +91 -55    JBossCache/tests/functional/org/jboss/cache/eviction/ReplicatedAopLRUPolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedAopLRUPolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/ReplicatedAopLRUPolicyTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- ReplicatedAopLRUPolicyTest.java	20 Jul 2006 11:14:17 -0000	1.8
  +++ ReplicatedAopLRUPolicyTest.java	30 Aug 2006 18:32:17 -0000	1.9
  @@ -15,7 +15,7 @@
    */
   public class ReplicatedAopLRUPolicyTest extends TestCase
   {
  -   TreeCache cache_, cache1_, cache2_;
  +   TreeCache cache_, cache2_;
      int wakeupIntervalMillis_ = 0;
   
      public ReplicatedAopLRUPolicyTest(String s)
  @@ -27,8 +27,8 @@
      {
         super.setUp();
         cache_ = new TreeCache();
  -      cache_.getConfiguration().setUseRegionBasedMarshalling(true);
         initCaches(cache_);
  +      cache_.getConfiguration().setUseRegionBasedMarshalling(true);
   //      cache1_ = new TreeCache();
   //      initCaches(cache1_);
         cache_.startService();
  @@ -40,10 +40,10 @@
         cache2_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache2_.startService();
   
  -      wakeupIntervalMillis_ = cache_.getEvictionThreadWakeupIntervalSeconds() *1000;
  -      log("wakeupInterval is " +wakeupIntervalMillis_);
  -      if(wakeupIntervalMillis_ <=0)
  -         fail("testEviction(): eviction thread wake up interval is illegal " +wakeupIntervalMillis_);
  +      wakeupIntervalMillis_ = cache_.getEvictionThreadWakeupIntervalSeconds() * 1000;
  +      log("wakeupInterval is " + wakeupIntervalMillis_);
  +      if (wakeupIntervalMillis_ <= 0)
  +         fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
      }
   
      void initCaches(TreeCache cache) throws Exception
  @@ -62,113 +62,149 @@
      /**
       * Test local eviction policy
       */
  -   public void testEviction() {
  +   public void testEviction()
  +   {
  +
  +      // assert that both caches are using region based marshalling
  +      assertTrue("Should be using region based marshalling", cache_.getConfiguration().isUseRegionBasedMarshalling());
  +      assertTrue("Should be using region based marshalling", cache2_.getConfiguration().isUseRegionBasedMarshalling());
  +
         String rootStr = "/org/jboss/test/data/";
  -      for(int i=0; i < 10; i++) {
  -         String str = rootStr +i;
  +      for (int i = 0; i < 10; i++)
  +      {
  +         String str = rootStr + i;
            Fqn fqn = Fqn.fromString(str);
  -         try {
  +         try
  +         {
               cache_.put(fqn, str, str);
  -         } catch (Exception e) {
  -            fail("Failed to insert data" +e);
  +         }
  +         catch (Exception e)
  +         {
  +            fail("Failed to insert data" + e);
               e.printStackTrace();
            }
         }
   
         TestingUtil.sleepThread(wakeupIntervalMillis_ + 1000);
  -      try {
  -         String val = (String)cache_.get(rootStr +"3", rootStr+"3");
  +      try
  +      {
  +         String val = (String) cache_.get(rootStr + "3", rootStr + "3");
            assertNull("DataNode should be evicted already ", val);
  -         val = (String)cache2_.get(rootStr +"3", rootStr+"3");
  +         val = (String) cache2_.get(rootStr + "3", rootStr + "3");
            assertNotNull("DataNode should not be evicted here ", val);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
  -         fail("Failed to evict" +e);
  +         fail("Failed to evict" + e);
         }
      }
   
  -   public void testEvictionReplication() {
  +   public void testEvictionReplication()
  +   {
         String rootStr = "/org/jboss/test/data/";
  -      for(int i=0; i < 10; i++) {
  -         String str = rootStr +i;
  +      for (int i = 0; i < 10; i++)
  +      {
  +         String str = rootStr + i;
            Fqn fqn = Fqn.fromString(str);
  -         try {
  +         try
  +         {
               cache_.put(fqn, str, str);
  -         } catch (Exception e) {
  -            fail("Failed to insert data" +e);
  +         }
  +         catch (Exception e)
  +         {
  +            fail("Failed to insert data" + e);
               e.printStackTrace();
            }
         }
   
  -      TestingUtil.sleepThread(wakeupIntervalMillis_ -1000);
  -      String str = rootStr +"7";
  +      TestingUtil.sleepThread(wakeupIntervalMillis_ - 1000);
  +      String str = rootStr + "7";
         Fqn fqn = Fqn.fromString(str);
  -      try {
  +      try
  +      {
            cache_.get(fqn, str);
  -      } catch (Exception e) {
  -         fail("Failed to get data. Exception: " +e);
  +      }
  +      catch (Exception e)
  +      {
  +         fail("Failed to get data. Exception: " + e);
         }
         TestingUtil.sleepThread(wakeupIntervalMillis_);
   
  -      try {
  -         String val = (String)cache_.get(rootStr +"3", rootStr+"3");
  +      try
  +      {
  +         String val = (String) cache_.get(rootStr + "3", rootStr + "3");
            assertNull("DataNode should be empty ", val);
  -         val = (String)cache2_.get(rootStr +"7", rootStr+"7");
  +         val = (String) cache2_.get(rootStr + "7", rootStr + "7");
            assertNotNull("DataNode should not be null", val);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
  -         fail("Failed to evict" +e);
  +         fail("Failed to evict" + e);
         }
      }
   
  -   public void testPojoEviction() {
  +   public void testPojoEviction()
  +   {
         String rootStr = "/org/jboss/test/data/";
         AOPInstance aop = new AOPInstance();
  -      try {
  -         for(int i=0; i < 4; i++) {
  -            String stri = rootStr +i;
  +      try
  +      {
  +         for (int i = 0; i < 4; i++)
  +         {
  +            String stri = rootStr + i;
               Fqn fqni = Fqn.fromString(stri);
               cache_.put(fqni, stri, stri);
               cache_.put(fqni, AOPInstance.KEY, aop);   // signals that this is an aop node.
               cache_.put(fqni, InternalDelegate.CLASS_INTERNAL, String.class);   // signals that this is an aop node.
  -            for(int j=0; j < 3; j++) {
  -               String strj = stri +"/" +j;
  +            for (int j = 0; j < 3; j++)
  +            {
  +               String strj = stri + "/" + j;
                  Fqn fqnj = Fqn.fromString(strj);
                  cache_.put(fqnj, strj, strj);
               }
            }
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
  -         fail("Failed to insert data" +e);
  +         fail("Failed to insert data" + e);
         }
   
  -      int period = (wakeupIntervalMillis_ +1);
  -      log("period is " +period);
  +      int period = (wakeupIntervalMillis_ + 1);
  +      log("period is " + period);
         TestingUtil.sleepThread(period);  // it really depends on the eviction thread time.
   
  -      try {
  +      try
  +      {
            String str = rootStr + "0";
  -         String val = (String)cache2_.get(Fqn.fromString(str), str);
  +         String val = (String) cache2_.get(Fqn.fromString(str), str);
            assertNotNull("DataNode should not be empty ", val);
            str = rootStr + "3";
  -         val = (String)cache2_.get(Fqn.fromString(str), str);
  +         val = (String) cache2_.get(Fqn.fromString(str), str);
            assertNotNull("DataNode should not be empty if maxElements is 4 ", val);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
  -         fail("Failed to evict" +e);
  +         fail("Failed to evict" + e);
         }
   
  -      period = (wakeupIntervalMillis_ +1000);
  -      log("period is " +period);
  +      period = (wakeupIntervalMillis_ + 1000);
  +      log("period is " + period);
         TestingUtil.sleepThread(period);  // it really depends on the eviction thread time.
   
  -      try {
  +      try
  +      {
            String str = rootStr + "0";
  -         String val = (String)cache_.get(Fqn.fromString(str), str);
  +         String val = (String) cache_.get(Fqn.fromString(str), str);
            assertNull("DataNode should be empty ", val);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
  -         fail("Failed to evict" +e);
  +         fail("Failed to evict" + e);
         }
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list