Examples of StatefulSession


Examples of org.jboss.test.cts.interfaces.StatefulSession

      // Create a new session object
      Context ctx  = new InitialContext();
      Object ref = ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSessionHome home = ( StatefulSessionHome ) PortableRemoteObject.narrow(ref,
         StatefulSessionHome.class);
      StatefulSession bean = home.create("testUserTx");   

      bean.setCounter(100);
      getLog().debug("Try to instantiate a UserTransaction");
      UserTransaction userTx = (UserTransaction)ctx.lookup("UserTransaction");
      userTx.begin();
         bean.incCounter();
         bean.incCounter();
      userTx.commit();
      int counter = bean.getCounter();
      assertTrue("counter == 102", counter == 102);

      bean.setCounter(100);
      userTx.begin();
         bean.incCounter();
         bean.incCounter();
      userTx.rollback();
      counter = bean.getCounter();
      assertTrue("counter == 100", counter == 100);

      bean.remove();
   }
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

      // Create a new session object
      Context ctx  = new InitialContext();
      Object ref = ctx.lookup("ejbcts/BMTStatefulSessionBean");
      StatefulSessionHome home = (StatefulSessionHome) PortableRemoteObject.narrow(ref,
         StatefulSessionHome.class);
      StatefulSession bean = home.create("testBadUserTx");    

      clearJndiTxTracking();
      try
      {
         bean.testBadUserTx();
         fail("Should throw an exception");
      }
      catch (Throwable expected)
      {
         log.debug("Got exception", expected);
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

  public void testLongWait() throws Exception
  {
      Context ctx = getInitialContext();
      getLog().debug("+++ testLongWait");
      StatefulSessionHome sessionHome = ( StatefulSessionHome ) ctx.lookup("ejbcts/LongWaitStatefulSessionBean");
      StatefulSession sessionBean = sessionHome.create("testLongWait");   

      getLog().debug("Sleeping...");
      sessionBean.sleep(5000);
      sessionBean.ping();
      getLog().debug("+++ testLongWait passed");
  }
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

  public void testLocalInterfacePassivation() throws Exception
  {
      Context ctx = new InitialContext();
      getLog().debug("+++ testLocalInterfacePassivation");
      StatefulSessionHome sessionHome = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean = sessionHome.create("testLocalInterfacePassivation");   

    getLog().debug("Creating local home");
      AccountPK pk = new AccountPK("123456789");
      sessionBean.createLocalEntity(pk, "jduke");

      getLog().debug("Creating a second session bean, forcing the first one to be passivated?");
      // The pool size has been set to 1 in the container
      // config, so creating another ASession here should
      // cause the first one to be passivated.
      StatefulSession anotherSession = sessionHome.create("testLocalInterfacePassivation2");
      getLog().debug("OK, anotherSession="+anotherSession);

      getLog().debug("Checking for complete passivation/activation");
      Thread.sleep(1000);
      assertTrue(sessionBean.getWasPassivated() == true);
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

  public void testSessionRefPassivation() throws Exception
  {
      Context ctx = new InitialContext();
      getLog().debug("+++ testSessionRefPassivation");
      StatefulSessionHome sessionHome = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean = sessionHome.create("testSessionRefPassivation");   

    getLog().debug("Creating session ref");
      sessionBean.createSessionRef();

      getLog().debug("Creating a second session bean, forcing the first one to be passivated?");
      // The pool size has been set to 1 in the container
      // config, so creating another ASession here should
      // cause the first one to be passivated.
      StatefulSession anotherSession = sessionHome.create("testSessionRefPassivation2");
      getLog().debug("OK, anotherSession="+anotherSession);

      getLog().debug("Checking for complete passivation/activation");
      Thread.sleep(1000);
      assertTrue(sessionBean.getWasPassivated() == true);
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

  public void testSessionHandlePassivation() throws Exception
  {
      Context ctx = new InitialContext();
      getLog().debug("+++ testSessionHandlePassivation");
      StatefulSessionHome sessionHome = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean = sessionHome.create("testSessionHandlePassivation");   

    getLog().debug("Creating session handle");
      sessionBean.createSessionHandle();

      getLog().debug("Creating a second session bean, forcing the first one to be passivated?");
      // The pool size has been set to 1 in the container
      // config, so creating another ASession here should
      // cause the first one to be passivated.
      StatefulSession anotherSession = sessionHome.create("testSessionHandlePassivation2");
      getLog().debug("OKm anotherSession="+anotherSession);

      getLog().debug("Checking for complete passivation/activation");
      Thread.sleep(1000);
      assertTrue(sessionBean.getWasPassivated() == true);
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

  public void testInVMSessionHandlePassivation() throws Exception
  {
      Context ctx = new InitialContext();
      getLog().debug("+++ testInVMSessionHandlePassivation");
      StatefulSessionHome sessionHome = (StatefulSessionHome) ctx.lookup("ejbcts/FacadeStatefulSessionBean");
      StatefulSession sessionBean = sessionHome.create("testInVMSessionHandlePassivation");   

    getLog().debug("Creating stateful session handle");
      sessionBean.createStatefulSessionHandle("testInVMSessionHandlePassivation2");
      sessionBean.useStatefulSessionHandle();
   }
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

   public void testPassivationBySize() throws Exception
   {
      Context ctx = new InitialContext();
      getLog().debug("+++ testPassivationBySize");
      StatefulSessionHome sessionHome = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean1 = sessionHome.create("testPassivationBySize");   
      sessionBean1.method1("hello");

      // Create a second bean to force passivation
      StatefulSession sessionBean2 = sessionHome.create("testPassivationBySize2");
      sessionBean2.method1("hello");

      // Validate that sessionBean1 was passivated and activated
      Thread.sleep(1000);
      boolean passivated = sessionBean1.getWasPassivated();
      assertTrue("sessionBean1 WasPassivated", passivated);
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

   public void testPassivationByTime() throws Exception
   {
      Context ctx = new InitialContext();
      getLog().debug("+++ testPassivationByTime");
      StatefulSessionHome sessionHome = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean1 = sessionHome.create("testPassivationByTime");   
      sessionBean1.method1("hello");

      getLog().debug("Retrieving handle for object");
      Handle handle = sessionBean1.getHandle();

      getLog().debug("Waiting 41 seconds for passivation...");
      Thread.sleep(41*1000);

      // Validate that sessionBean1 was passivated and activated
      boolean passivated = sessionBean1.getWasPassivated();
      assertTrue("sessionBean1 WasPassivated", passivated);
      boolean activated = sessionBean1.getWasActivated();
      assertTrue("sessionBean1 WasActivated", activated);

      getLog().debug("Waiting 90 seconds for removal due to age...");
      Thread.sleep(90*1000);

      try
      {
         handle.getEJBObject();
         fail("Was able to get the remote interface for a removed session");
      }
      catch (RemoteException expected)
      {
         getLog().debug("Handle access failed as expected", expected);
      }

      try
      {
         passivated = sessionBean1.getWasPassivated();
         fail("Was able to invoke getWasPassivated after bean should have been removed");
      }
      catch(Exception e)
      {
         getLog().debug("Bean access failed as expected", e);
View Full Code Here

Examples of org.jboss.test.cts.interfaces.StatefulSession

   {
      getLog().debug("+++ testBasicSession()");
      Context ctx = new InitialContext();
      StatefulSessionHome sessionHome =
         ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean = sessionHome.create("testBasicSession-create");   
      String result = sessionBean.method1("CTS-Test");
      // Test response
      assertTrue(result.equals("CTS-Test"));

      try
      {
         sessionBean.remove();
      }
      catch (Exception ex)
      {
          fail("could not remove stateless session bean" + ex);
      }

      sessionBean = sessionHome.createAlt("testBasicSession-create");
      String altName = sessionBean.getTestName();
      assertTrue("testName == testBasicSession-createAlt",
         altName.equals("testBasicSession-createAlt"));

      result = sessionBean.method1("CTS-Test");
      // Test response
      assertTrue(result.equals("CTS-Test"));

      try
      {
         sessionBean.remove();
      }
      catch (Exception ex)
      {
          fail("could not remove stateless session bean" + ex);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.