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

Brian Stansberry brian.stansberry at jboss.com
Wed Oct 25 18:35:09 EDT 2006


  User: bstansberry
  Date: 06/10/25 18:35:09

  Added:       tests/functional/org/jboss/cache/passivation  Tag:
                        Branch_JBossCache_1_4_0
                        ConcurrentPassivationTest.java
  Log:
  Test for problems with passivation of nodes during concurrent read
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +94 -0     JBossCache/tests/functional/org/jboss/cache/passivation/Attic/ConcurrentPassivationTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConcurrentPassivationTest.java
  ===================================================================
  RCS file: ConcurrentPassivationTest.java
  diff -N ConcurrentPassivationTest.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ ConcurrentPassivationTest.java	25 Oct 2006 22:35:09 -0000	1.1.2.1
  @@ -0,0 +1,94 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
  +
  +package org.jboss.cache.passivation;
  +
  +import junit.framework.Test;
  +import junit.framework.TestCase;
  +import junit.framework.TestSuite;
  +
  +import org.jboss.cache.Fqn;
  +import org.jboss.cache.PropertyConfigurator;
  +import org.jboss.cache.TreeCache;
  +
  +/**
  + * Tests cache behavior in the presence of concurrent passivation.
  + * 
  + * @author Brian Stansberry
  + * @version $Revision: 1.1.2.1 $
  + */
  +public class ConcurrentPassivationTest extends TestCase
  +{
  +   private TreeCache cache_;
  +   private int wakeupIntervalMillis_ = 0;
  +
  +   public ConcurrentPassivationTest(String s)
  +   {
  +      super(s);
  +   }
  +
  +   public void setUp() throws Exception
  +   {
  +      super.setUp();
  +      initCaches();
  +      wakeupIntervalMillis_ = cache_.getEvictionThreadWakeupIntervalSeconds() * 1000;
  +      if (wakeupIntervalMillis_ < 0)
  +         fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
  +
  +   }
  +
  +   void initCaches() throws Exception
  +   {
  +      cache_ = new TreeCache();
  +      PropertyConfigurator config = new PropertyConfigurator();
  +      config.configure(cache_, "META-INF/local-passivation-service.xml"); // read in generic local xml
  +      cache_.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  +      cache_.startService();
  +   }
  +
  +   public void tearDown() throws Exception
  +   {
  +      super.tearDown();
  +      cache_.stopService();
  +   }
  +   
  +   public void testConcurrentPassivation() throws Exception
  +   {
  +      Fqn base = Fqn.fromString("/org/jboss/test/data/concurrent/passivation");
  +      
  +      // Create a bunch of nodes; more than the /org/jboss/test/data
  +      // region's maxNodes so we know eviction will kick in
  +      for (int i = 0; i < 35000; i++)
  +      {         
  +         cache_.put(new Fqn(base, new Integer(i / 100)), new Integer(i), "value");
  +      }
  +      
  +      // Loop for long enough to have 5 runs of the eviction thread
  +      long loopDone = System.currentTimeMillis() + (5 * wakeupIntervalMillis_);
  +      while (System.currentTimeMillis() < loopDone)
  +      {
  +         // If any get returns null, that's a failure
  +         for (int i = 0; i < 35000; i++)
  +         {
  +            Fqn fqn = new Fqn(base, new Integer(i / 100));
  +            Integer key = new Integer(i);
  +            assertNotNull("found value under Fqn " + fqn + " and key " + key,
  +                           cache_.get(fqn, key));
  +         }
  +      }
  +   }
  +
  +   public static Test suite()
  +   {
  +      return new TestSuite(org.jboss.cache.passivation.ConcurrentPassivationTest.class);
  +   }
  +
  +   public static void main(String[] args)
  +   {
  +      junit.textui.TestRunner.run(org.jboss.cache.passivation.ConcurrentPassivationTest.suite());
  +   }
  +}
  
  
  



More information about the jboss-cvs-commits mailing list