[jboss-cvs] jboss-ejb3/src/test/org/jboss/ejb3/test/cache/unit ...

Ben Wang bwang at jboss.com
Tue Jul 25 12:47:19 EDT 2006


  User: bwang   
  Date: 06/07/25 12:47:19

  Modified:    src/test/org/jboss/ejb3/test/cache/unit 
                        StatefulUnitTestCase.java
  Log:
  Ported fixes from 4.0
  
  Revision  Changes    Path
  1.10      +39 -18    jboss-ejb3/src/test/org/jboss/ejb3/test/cache/unit/StatefulUnitTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: StatefulUnitTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-ejb3/src/test/org/jboss/ejb3/test/cache/unit/StatefulUnitTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- StatefulUnitTestCase.java	16 May 2006 15:03:00 -0000	1.9
  +++ StatefulUnitTestCase.java	25 Jul 2006 16:47:19 -0000	1.10
  @@ -23,10 +23,8 @@
   
   import javax.management.MBeanServerConnection;
   import javax.management.ObjectName;
  -
   import org.jboss.ejb3.test.cache.SimpleStatefulRemote;
   import org.jboss.ejb3.test.cache.StatefulRemote;
  -import org.jboss.logging.Logger;
   import org.jboss.test.JBossTestCase;
   import junit.framework.Test;
   
  @@ -34,20 +32,50 @@
    * Sample client for the jboss container.
    *
    * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
  - * @version $Id: StatefulUnitTestCase.java,v 1.9 2006/05/16 15:03:00 bwang Exp $
  + * @version $Id: StatefulUnitTestCase.java,v 1.10 2006/07/25 16:47:19 bwang Exp $
    */
   
   public class StatefulUnitTestCase
   extends JBossTestCase
   {
  -   private static final Logger log = Logger.getLogger(StatefulUnitTestCase.class);
  +   org.apache.log4j.Category log = getLog();
   
      static boolean deployed = false;
      static int test = 0;
   
      public StatefulUnitTestCase(String name)
      {
  +
         super(name);
  +
  +   }
  +
  +   public void testStateful() throws Exception
  +   {
  +      StatefulRemote remote = (StatefulRemote) getInitialContext().lookup("StatefulBean/remote");
  +      remote.reset();
  +      remote.setState("hello");
  +      Thread.sleep(11000);
  +      assertEquals("hello", remote.getState());
  +      assertTrue(remote.getPostActivate());
  +      assertTrue(remote.getPrePassivate());
  +      remote.done(); // remove this
  +   }
  +
  +   public void testStatefulLongRunning() throws Exception
  +   {
  +      StatefulRemote remote = (StatefulRemote) getInitialContext().lookup("StatefulBean/remote");
  +      remote.reset();
  +      remote.setState("hello");
  +      remote.longRunning();
  +      // It is in use so not yet passivated
  +      assertFalse(remote.getPrePassivate());
  +      Thread.sleep(11000);
  +      // Now it will be.
  +      assertEquals("hello", remote.getState());
  +      assertTrue(remote.getPostActivate());
  +      assertTrue(remote.getPrePassivate());
  +      remote.done(); // remove this
      }
   
      public void testSimpleStatefulLongRunning() throws Exception
  @@ -57,10 +85,8 @@
         remote.setState("hello");
         remote.longRunning();
         assertEquals("hello", remote.getState());
  -      assertEquals(1, remote.getPostActivate());
  -      assertEquals(1, remote.getPrePassivate());
  -
  -      remote.remove();
  +      assertTrue(remote.getPostActivate());
  +      assertTrue(remote.getPrePassivate());
      }
   
      public void testSimpleStateful() throws Exception
  @@ -70,10 +96,8 @@
         remote.setState("hello");
         Thread.sleep(5000);
         assertEquals("hello", remote.getState());
  -      assertEquals(1, remote.getPostActivate());
  -      assertEquals(1, remote.getPrePassivate());
  -
  -      remote.remove();
  +      assertTrue(remote.getPostActivate());
  +      assertTrue(remote.getPrePassivate());
      }
   
      public void testSimpleLocal() throws Exception
  @@ -89,8 +113,7 @@
      {
         StatefulRemote remote = (StatefulRemote) getInitialContext().lookup("StatefulBean/remote");
         System.out.println("bench: " + remote.bench(1000));
  -      remote.remove();
  -
  +      remote.done(); // remove this
      }
   
      public void testBenchSimple() throws Exception
  @@ -98,13 +121,11 @@
         SimpleStatefulRemote remote = (SimpleStatefulRemote) getInitialContext().lookup("SimpleStatefulBean/remote");
         System.out.println("simple bench: " + remote.bench(1000));
   
  -      remote.remove();
  -
      }
   
      public static Test suite() throws Exception
      {
  -      return getDeploySetup(StatefulUnitTestCase.class, "cache-test.jar, cache-test.sar");
  +      return getDeploySetup(StatefulUnitTestCase.class, "testejb3-statefulcache-service.xml, cache-test.jar, cache-test.sar");
      }
   
   }
  
  
  



More information about the jboss-cvs-commits mailing list