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

Ben Wang bwang at jboss.com
Mon Jul 24 12:53:49 EDT 2006


  User: bwang   
  Date: 06/07/24 12:53:49

  Added:       src/test/org/jboss/ejb3/test/cache/unit  Tag: Branch_4_0
                        NestedBeanUnitTestCase.java
  Log:
  Added test cases for simple cache.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +108 -0    jboss-ejb3/src/test/org/jboss/ejb3/test/cache/unit/Attic/NestedBeanUnitTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NestedBeanUnitTestCase.java
  ===================================================================
  RCS file: NestedBeanUnitTestCase.java
  diff -N NestedBeanUnitTestCase.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ NestedBeanUnitTestCase.java	24 Jul 2006 16:53:49 -0000	1.1.2.1
  @@ -0,0 +1,108 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
  +
  +package org.jboss.ejb3.test.cache.unit;
  +
  +import org.jboss.test.JBossTestCase;
  +import org.jboss.ejb3.test.cache.nested.ParentStatefulRemote;
  +
  +import javax.naming.Context;
  +import javax.naming.InitialContext;
  +import java.util.Date;
  +import java.util.Properties;
  +
  +import junit.framework.Test;
  +
  +/**
  + * Test nested SFSB for load-balancing and failover behaviour
  + *
  + * @author  Ben.Wang at jboss.org
  + * @version $Revision: 1.1.2.1 $
  + */
  +public class NestedBeanUnitTestCase extends JBossTestCase
  +{
  +   static boolean deployed = false;
  +   public static int test = 0;
  +   static Date startDate = new Date();
  +
  +   protected final String namingFactory =
  +   System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
  +
  +   protected final String providerURL =
  +   System.getProperty(Context.PROVIDER_URL);
  +
  +   public NestedBeanUnitTestCase (String name)
  +   {
  +      super(name);
  +   }
  +
  +   public static Test suite() throws Exception
  +   {
  +      return getDeploySetup(NestedBeanUnitTestCase.class, "cache-test.jar");
  +   }
  +
  +   public void testBasic()
  +   throws Exception
  +   {
  +      getLog().debug(NestedBeanUnitTestCase.test +"- "
  +              +"Trying the context...");
  +
  +      getLog().debug("Test Nested Stateful Bean");
  +      getLog().debug("==================================");
  +      getLog().debug(++NestedBeanUnitTestCase.test +"- "
  +              +"Looking up testBasic...");
  +      InitialContext ctx = getInitialContext();
  +      ParentStatefulRemote stateful = (ParentStatefulRemote) ctx.lookup("testParentStateful/remote");
  +
  +      stateful.setName("The Code");
  +      _sleep(300);
  +
  +      assertEquals("Counter: ", 1, stateful.increment());
  +      assertEquals("Counter: ", 2, stateful.increment());
  +
  +      stateful.remove();
  +      getLog().debug("ok");
  +   }
  +
  +   public void testPassivation()
  +   throws Exception
  +   {
  +      // Connect to the server0 JNDI
  +      InitialContext ctx = getInitialContext();
  +
  +      getLog().debug("Test Nested Stateful Bean");
  +      getLog().debug("==================================");
  +      ParentStatefulRemote stateful = (ParentStatefulRemote) ctx.lookup("testParentStateful/remote");
  +
  +      stateful.setName("The Code");
  +      _sleep(300);
  +
  +      assertEquals("Counter: ", 1, stateful.increment());
  +      assertEquals("Counter: ", 2, stateful.increment());
  +      _sleep(11000);
  +      assertEquals("Counter: ", 3, stateful.increment());
  +      assertEquals(1, stateful.getPrePassivate());
  +      assertEquals(1, stateful.getPostActivate());
  +      assertEquals(1, stateful.getNestedPrePassivate());
  +      assertEquals(1, stateful.getNestedPostActivate());
  +
  +//      _sleep(16000);
  +//      stateful.remove();
  +      getLog().debug("ok: done");
  +      // passivate for the second time.
  +      _sleep(12000);
  +   }
  +
  +   protected void _sleep(long time)
  +   {
  +      try {
  +         Thread.sleep(time);
  +      } catch (InterruptedException e) {
  +         e.printStackTrace();
  +      }
  +   }
  +}
  
  
  



More information about the jboss-cvs-commits mailing list