FileDocCategorySizeDatePackage
StatefulUnitTestCase.javaAPI DocJBoss 4.2.14529Fri Jul 13 20:52:58 BST 2007org.jboss.ejb3.test.cache.unit

StatefulUnitTestCase

public class StatefulUnitTestCase extends org.jboss.test.JBossTestCase
Sample client for the jboss container.
author
Bill Burke
version
$Id: StatefulUnitTestCase.java 60233 2007-02-03 10:13:23Z wolfc $

Fields Summary
Logger
log
static boolean
deployed
static int
test
Constructors Summary
public StatefulUnitTestCase(String name)


     
   

      super(name);

   
Methods Summary
public static junit.framework.Testsuite()

      return getDeploySetup(StatefulUnitTestCase.class, "testejb3-statefulcache-service.xml, cache-test.jar, cache-test.sar");
   
public voidtestBench()

      StatefulRemote remote = (StatefulRemote) getInitialContext().lookup("StatefulBean/remote");
      System.out.println("bench: " + remote.bench(1000));
      remote.done(); // remove this
   
public voidtestBenchSimple()

      SimpleStatefulRemote remote = (SimpleStatefulRemote) getInitialContext().lookup("SimpleStatefulBean/remote");
      System.out.println("simple bench: " + remote.bench(1000));

   
public voidtestSimpleLocal()

	   MBeanServerConnection server = getServer();
      ObjectName testerName = new ObjectName("jboss.ejb3:service=Tester,test=cache");
      Object[] params = {};
      String[] sig = {};
      server.invoke(testerName, "testSimpleLocal", params, sig);
   
public voidtestSimpleStateful()

      SimpleStatefulRemote remote = (SimpleStatefulRemote) getInitialContext().lookup("SimpleStatefulBean/remote");
      remote.reset();
      remote.setState("hello");
      Thread.sleep(5000);
      assertEquals("hello", remote.getState());
      assertTrue(remote.getPostActivate());
      assertTrue(remote.getPrePassivate());
   
public voidtestSimpleStatefulLongRunning()

      SimpleStatefulRemote remote = (SimpleStatefulRemote) getInitialContext().lookup("SimpleStatefulBean/remote");
      remote.reset();
      remote.setState("hello");
      remote.longRunning();
      assertEquals("hello", remote.getState());
      assertTrue(remote.getPostActivate());
      assertTrue(remote.getPrePassivate());
   
public voidtestStateful()

      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 voidtestStatefulLongRunning()

      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