Examples of StatefulSession


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

      // Create a new session object
      Context ctx = new InitialContext();
      StatefulSessionHome sessionHome =
         ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean = sessionHome.create("testEJBHomeInterface");   

      // Get the EJBMetaData
      javax.ejb.EJBMetaData md = sessionHome.getEJBMetaData();

      getLog().debug("Verify EJBMetaData from home interface");
      assertTrue(md != null);

      // Get the EJBMetaData constructs
      getLog().debug("Get Home interface class");

      java.lang.Class<?> homeInterface = md.getHomeInterfaceClass();

      getLog().debug("home Interface : " + homeInterface.getName());
      assertTrue(homeInterface.getName().equals("org.jboss.test.cts.interfaces.StatefulSessionHome"));
      getLog().debug("Get Remote Interface class");

      java.lang.Class<?> remoteInterface = md.getRemoteInterfaceClass();

      getLog().debug("remote Interface: " + remoteInterface.getName());
      assertTrue(remoteInterface.getName().equals("org.jboss.test.cts.interfaces.StatefulSession"));
      getLog().debug("Verify isSession..");
      assertTrue(md.isSession());

      // EJB 1.1 only
      getLog().debug("Verify is not Stateless session...");
      assertTrue(!md.isStatelessSession());

      try
      {
         sessionBean.remove();
      }
      catch (Exception ex)
      {
          fail("could not remove stateful session bean" + ex);
      }
View Full Code Here

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

      throws Exception
   {
      getLog().debug("+++ testRemoveSessionObject()");
      Context ctx  = new InitialContext();
      StatefulSessionHome home = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession bean = home.create("testRemoveSessionObject");   
      getLog().debug("OK, bean="+bean);
      getLog().debug("Call remove using a primary key");
      try
      {
         home.remove(new AccountPK("pk"));
View Full Code Here

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

   {
      getLog().debug("+++ testCompareSerializeGetPK()");

      Context ctx  = new InitialContext();
      StatefulSessionHome home = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession bean = home.create("testCompareSerializeGetPK");   

      // Get the bean handle
      Handle hn = bean.getHandle();

      assertTrue(hn != null);

      // "Copy" the bean
      StatefulSession theOtherBean =
         ( StatefulSession ) javax.rmi.PortableRemoteObject.narrow(
            hn.getEJBObject(), StatefulSession.class);

      assertTrue(theOtherBean != null);
      assertTrue(bean.isIdentical(theOtherBean));
View Full Code Here

Examples of org.jboss.test.ejb.passivationcl.stateful.StatefulSession

   public void testMain() throws Exception
   {
      Object ref = getInitialContext().lookup("StatefulSession");
      StatefulSessionHome home = (StatefulSessionHome) PortableRemoteObject.narrow(ref, StatefulSessionHome.class);
      StatefulSession stateful = home.create();
      stateful.test();

      int i = 5;
      while(!stateful.isPassivated())
      {
         if(i == 0)
            fail("Gave up waiting for passivation.");
         try
         {
            Thread.sleep(1500);
         }
         catch(InterruptedException e)
         {
            //
         }
         --i;
      }

      stateful.remove();
   }
View Full Code Here

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

      Object obj = jndiContext.lookup("spec.StatefulSession");
      obj = PortableRemoteObject.narrow(obj, StatefulSessionHome.class);
      StatefulSessionHome home = (StatefulSessionHome) obj;
      log.debug("Found StatefulSessionHome");
      // The create should be allowed to call getCallerPrincipal
      StatefulSession bean = home.create("testStatefulCreateCaller");
      // Need to invoke a method to ensure an ejbCreate call
      bean.echo("testStatefulCreateCaller");
      log.debug("Bean.echo(), ok");

      logout();
   }
View Full Code Here

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

      this.handle = handle;
   }
  
   public String execute() throws Exception
   {
      StatefulSession session = (StatefulSession) handle.getEJBObject();
      return execute(session);
   }
View Full Code Here

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

      StatefulSessionHome  statefulSessionHome =
      (StatefulSessionHome) ctx.lookup("nextgen.StatefulSession");
      assertTrue("statefulSessionHome!= null", statefulSessionHome!= null);
      getLog().debug("ok");
      getLog().debug(++test+"- "+"Calling create on StatefulSessionHome with name Marc...");
      StatefulSession statefulSession =
      statefulSessionHome.create("Marc");
      assertTrue("statefulSession != null", statefulSession != null);
      getLog().debug("ok");
      getLog().debug(++test+"- "+"Calling getEJBHome() on StatefulSession...");
      assertTrue("statefulSession.getEJBHome() != null", statefulSession.getEJBHome() != null);
      getLog().debug("ok");
      getLog().debug(++test+"- "+"Calling Business Method A on StatefulSession... ");
      getLog().debug(statefulSession.callBusinessMethodA());
      getLog().debug(++test+"- "+"Calling Business Method A (state) on StatefulSession... ");
      getLog().debug(statefulSession.callBusinessMethodA());
      getLog().debug(++test+"- "+"Calling Business Method B (EJBObject) on StatefulSession... ");
      getLog().debug(statefulSession.callBusinessMethodB());

      getLog().debug(++test+"- "+"Calling Business Method B(String) on StatefulSession... ");
      getLog().debug(statefulSession.callBusinessMethodB("of wisdom"));


      getLog().debug("***Testing the various local Object class calls");
      getLog().debug(++test+"- "+"toString ... ");
      getLog().debug(statefulSession.toString());
      getLog().debug(++test+"- "+"hashCode ... " +
                     statefulSession.hashCode());

      getLog().debug(++test+"- "+"equals (same object) ... " +
                     statefulSession.equals(statefulSession));

      getLog().debug(++test+"- "+"equals (another object) (false under same home)... " +
                     statefulSession.equals(statefulSessionHome.create("marc4")));

      getLog().debug("***Testing the various local EJBObject class calls");

      getLog().debug(++test+"- "+"Get Handle ... ");
      Handle statefulHandle = statefulSession.getHandle();
      assertTrue("statefulHandle != null", statefulHandle != null);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"Serialize handle and deserialize....");
      MarshalledObject mo2 = new MarshalledObject(statefulHandle);
      Handle statefulHandle2 = (Handle) mo2.get();
      StatefulSession statefulSession2 = (StatefulSession) statefulHandle2.getEJBObject();
      assertTrue("statefulSession2 != null", statefulSession2 != null);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"Calling businessMethodB on it..." +
                     statefulSession2.callBusinessMethodB());

      getLog().debug(++test+"- "+"They should be identical..." +
                     statefulSession.isIdentical(statefulSession2));

      getLog().debug(++test+"- "+"Calling StatefulSession.remove()...");
      statefulSession.remove();
      getLog().debug("ok");
      getLog().debug(++test+"- "+"Calling StatefulHome.remove(Handle) (this should fail)...");
      try
      {
         statefulSessionHome.remove(statefulSession2.getHandle());
         fail("statefulSessionHome.remove did not fail");
      }
      catch (Exception e)
      {
         getLog().debug("not found OK");
      }
      getLog().debug(++test+"- "+"Creating a 3rd bean and calling it...");
      StatefulSession ss3 = statefulSessionHome.create("marc3");
      getLog().debug(ss3.callBusinessMethodA());
      getLog().debug(++test+"- "+"Calling StatefulSession.remove(Handle) on a third bean...");
      Handle statefulHandle3 = ss3.getHandle();
      statefulSessionHome.remove(statefulHandle3);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"I should not be able to remove it directly...");
      try {
         ss3.remove();
         fail("ss3.remove() did not fail");
      } catch (Exception e) {
         getLog().debug("OK");
      }

      getLog().debug(++test+"- "+"Creating a 4th bean using create<METHOD> and calling it...");
      StatefulSession ss4 = statefulSessionHome.createMETHOD("marc4", "address");
      getLog().debug(ss4.callBusinessMethodA());
      getLog().debug(++test+"- "+"Calling StatefulSession.remove(Handle) on a fourth bean...");
      Handle statefulHandle4 = ss4.getHandle();
      statefulSessionHome.remove(statefulHandle4);
   }
View Full Code Here

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

      Context ctx  = getInitialContext();
      Object ref = ctx.lookup("txiiop/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
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.