Package org.jboss.test.testbean.interfaces

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


         "org.jnp.interfaces.NamingContextFactory");
      env1.setProperty(Context.PROVIDER_URL, urls[0]);
      InitialContext ctx = new InitialContext(env1);

      int beanCount = 500;
      StatefulSessionHome home =
         (StatefulSessionHome) ctx.lookup("nextgen_ExpiredStatefulSession");
      long start = System.currentTimeMillis();
      log.info("Start bean creation");
      StatefulSession[] beans = new StatefulSession[beanCount];
      long[] accessStamp = new long[beanCount];
      for(int n = 0; n < beans.length; n ++)
      {
         beans[n] = (StatefulSession) home.create("testStatefulPassivationExpiration#"+n);
         accessStamp[n] = System.currentTimeMillis();
      }
      long end = System.currentTimeMillis();
      log.info("End bean creation, elapsed="+(end - start));

      int N = 5000;
      long min = 99999, max = 0, maxInactive = 0;
      for(int n = 0; n < N; n ++)
      {
         int id = n % beans.length;
         StatefulSession bean = beans[id];
         if (bean == null)
            continue// bean timed out and removed
         String name = "testStatefulPassiviationExpiration#"+id;
         long callStart = System.currentTimeMillis();
         long inactive = callStart - accessStamp[id];
         try
         {
            bean.setName(name);
            NodeAnswer node = bean.getNodeState();
            long now = System.currentTimeMillis();           
            long elapsed = now - callStart;
            accessStamp[id] = now;
            assertTrue("NodeAnswer == "+name, node.answer.equals(name));
            min = Math.min(min, elapsed);
            max = Math.max(max, elapsed);
            maxInactive = Math.max(maxInactive, inactive);
            log.debug(n+", elapsed="+elapsed+", inactive="+inactive);
         }
         catch (java.rmi.NoSuchObjectException nso)
         {
            log.debug(n+" Caught NoSuchObjectException on bean " + id + " -- inactive time = " + inactive);
            // Remove the bean as it will never succeed again
            beans[id] = null;
         }
      }
      log.info(N+" calls complete, max="+max+", min="+min+", maxInactive="+maxInactive);

      Thread.sleep(15000);
      start = System.currentTimeMillis();
      for(int n = 0; n < beans.length; n ++)
      {
         beans[n] = (StatefulSession) home.create("testStatefulPassivationExpiration#"+n);
         accessStamp[n] = System.currentTimeMillis();
      }
      end = System.currentTimeMillis();
      log.info("End second round bean creation, elapsed="+(end - start));
      for(int n = 0; n < N; n ++)
View Full Code Here


      Context ctx = new InitialContext(env);
      getLog().debug("OK");
     
      getLog().debug("");
      getLog().debug("Looking up the home nextgen.StatefulSession...");
      StatefulSessionHome  statefulSessionHome =
      (StatefulSessionHome) ctx.lookup("nextgen_StatefulSession");
      if (statefulSessionHome!= null ) getLog().debug("ok");
         getLog().debug("Calling create on StatefulSessionHome...");
      StatefulSession statefulSession =
         (StatefulSession)statefulSessionHome.create("Bupple-Dupple");
      assertTrue("statefulSessionHome.create() != null", statefulSession != null);
      getLog().debug("ok");
     
      NodeAnswer node1 = statefulSession.getNodeState ();
      getLog ().debug (node1);
View Full Code Here

      this.anObject = anObject;
     
      try {
         Context ctx = new InitialContext();
        
         StatefulSessionHome sfHome = (StatefulSessionHome)ctx.lookup("java:comp/env/ejb/stateful");
         statefulSession = sfHome.create();
        
         StatelessSessionHome slHome = (StatelessSessionHome)ctx.lookup("java:comp/env/ejb/stateless");
         statelessSession = slHome.create();
        
         EnterpriseEntityHome eeHome = (EnterpriseEntityHome)ctx.lookup("java:comp/env/ejb/entity");
View Full Code Here

      getLog().debug("");
      getLog().debug("Test Stateful Bean Failover");
      getLog().debug("==================================");
      getLog().debug("");
      getLog().debug(++test+"- "+"Looking up the home nextgen.StatefulSession...");
      StatefulSessionHome  statefulSessionHome =
      (StatefulSessionHome) ctx.lookup("nextgen.StatefulSession");
      if (statefulSessionHome!= null ) getLog().debug("ok");
         getLog().debug(++test+"- "+"Calling create on StatefulSessionHome...");
      StatefulSession statefulSession =
      (StatefulSession)statefulSessionHome.create("Bupple-Dupple");
      assertTrue("statefulSessionHome.create() != null", statefulSession != null);
      getLog().debug("ok");
     
      NodeAnswer node1 = statefulSession.getNodeState ();
      getLog ().debug (node1);
View Full Code Here

      InitialContext ctx = new InitialContext(env1);
     
      getLog().debug("Test Stateful Bean Failover");
      getLog().debug("==================================");
      getLog().debug(++test+"- "+"Looking up the home nextgen.StatefulSession...");
      StatefulSessionHome  statefulSessionHome =
      (StatefulSessionHome) ctx.lookup("nextgen_StatefulSession");
      if (statefulSessionHome!= null ) getLog().debug("ok");
         getLog().debug(++test+"- "+"Calling create on StatefulSessionHome...");
      StatefulSession statefulSession =
      (StatefulSession)statefulSessionHome.create("Bupple-Dupple");
      assertTrue("statefulSessionHome.create() != null", statefulSession != null);
      getLog().debug("ok");
     
      NodeAnswer node1 = statefulSession.getNodeState ();
      getLog ().debug (node1);
View Full Code Here

         "org.jnp.interfaces.NamingContextFactory");
      env1.setProperty(Context.PROVIDER_URL, urls[0]);
      InitialContext ctx = new InitialContext(env1);

      int beanCount = 500;
      StatefulSessionHome home =
         (StatefulSessionHome) ctx.lookup("nextgen_ExpiredStatefulSession");
      long start = System.currentTimeMillis();
      log.info("Start bean creation");
      StatefulSession[] beans = new StatefulSession[beanCount];
      long[] accessStamp = new long[beanCount];
      for(int n = 0; n < beans.length; n ++)
      {
         beans[n] = (StatefulSession) home.create("testStatefulPassivationExpiration#"+n);
         accessStamp[n] = System.currentTimeMillis();
      }
      long end = System.currentTimeMillis();
      log.info("End bean creation, elapsed="+(end - start));

      int N = 5000;
      long min = 99999, max = 0, maxInactive = 0;
      for(int n = 0; n < N; n ++)
      {
         int id = n % beans.length;
         StatefulSession bean = beans[id];
         if (bean == null)
            continue// bean timed out and removed
         String name = "testStatefulPassiviationExpiration#"+id;
         long callStart = System.currentTimeMillis();
         long inactive = callStart - accessStamp[id];
         try
         {
            bean.setName(name);
            NodeAnswer node = bean.getNodeState();
            long now = System.currentTimeMillis();           
            long elapsed = now - callStart;
            accessStamp[id] = now;
            assertTrue("NodeAnswer == "+name, node.answer.equals(name));
            min = Math.min(min, elapsed);
            max = Math.max(max, elapsed);
            maxInactive = Math.max(maxInactive, inactive);
            log.debug(n+", elapsed="+elapsed+", inactive="+inactive);
         }
         catch (java.rmi.NoSuchObjectException nso)
         {
            log.debug(n+" Caught NoSuchObjectException on bean " + id + " -- inactive time = " + inactive);
            // Remove the bean as it will never succeed again
            beans[id] = null;
         }
      }
      log.info(N+" calls complete, max="+max+", min="+min+", maxInactive="+maxInactive);

      Thread.sleep(15000);
      start = System.currentTimeMillis();
      for(int n = 0; n < beans.length; n ++)
      {
         beans[n] = (StatefulSession) home.create("testStatefulPassivationExpiration#"+n);
         accessStamp[n] = System.currentTimeMillis();
      }
      end = System.currentTimeMillis();
      log.info("End second round bean creation, elapsed="+(end - start));
      for(int n = 0; n < N; n ++)
View Full Code Here

      Properties env = getNamingProperties("org.jboss.naming.NamingContextFactory",
                                           false);
      InitialContext ctx = new InitialContext(env);
     
      getLog().debug("Looking up the home nextgen.StatefulSession" + getJndiSuffix()+"...");
      StatefulSessionHome  sfsbHome =
         (StatefulSessionHome) ctx.lookup("nextgen_StatefulSession" + getJndiSuffix());
      if (sfsbHome!= null ) getLog().debug("ok");
         getLog().debug("Calling create on StatefulSessionHome" + getJndiSuffix()+"...");
      StatefulSession sfsb = (StatefulSession)sfsbHome.create("Bupple-Dupple");
      assertTrue("statefulSessionHome.create() != null", sfsb != null);
      getLog().debug("ok");
     
      NodeAnswer node1 = sfsb.getNodeState ();
      getLog ().debug (node1);
View Full Code Here

   protected void sfsbTest(Context ctx, Properties env) throws Exception
   {
      configureCluster();
     
      getLog().debug("Looking up the home nextgen.StatefulSession" + getJndiSuffix()+"...");
      StatefulSessionHome  statefulSessionHome =
         (StatefulSessionHome) ctx.lookup("nextgen_StatefulSession" + getJndiSuffix());
      if (statefulSessionHome!= null ) getLog().debug("ok");
         getLog().debug("Calling create on StatefulSessionHome" + getJndiSuffix()+"...");
      StatefulSession statefulSession =
         (StatefulSession)statefulSessionHome.create("Bupple-Dupple");
      assertTrue("statefulSessionHome.create() != null", statefulSession != null);
      getLog().debug("ok");
     
      NodeAnswer node1 = statefulSession.getNodeState ();
      getLog ().debug (node1);
View Full Code Here

         "org.jnp.interfaces.NamingContextFactory");
      env1.setProperty(Context.PROVIDER_URL, urls[0]);
      InitialContext ctx = new InitialContext(env1);

      log.debug("Looking up the home pooledha_StatefulSession..."+urls[0]);
      StatefulSessionHome homeHA =
         (StatefulSessionHome) ctx.lookup("pooledha_StatefulSession");
      log.debug("Looking up the home pooled_StatelessSession..."+urls[0]);
      StatelessSessionHome home =
         (StatelessSessionHome) ctx.lookup("pooled_StatelessSession");

      // Simple connection count stress test
      PooledInvokerProxy.clearStats();
      PooledInvokerProxy.clearPools();
      for(int n = 0; n < 100; n ++)
      {
         StatefulSession tmp = (StatefulSession) homeHA.create();
         tmp.remove();
         tmp = (StatefulSession) homeHA.create();
         StatelessSession tmp2 = home.create();
         tmp.getNodeState();
         tmp2.getCallCount();
         tmp.getNodeState();
         tmp2.getCallCount();
         tmp.remove();
         int totalCount = PooledInvokerProxy.getTotalPoolCount();
         // N cluster nodes + 1 for unclustered
         int expectedCount = urls.length + 1;
         assertEquals("TotalPoolCount", expectedCount, totalCount);
         long usedPooled = PooledInvokerProxy.getUsedPooled();
         // iter * Ncalls - expectedCount (for the initial conn creation)
         int expectedUsedPooled = (n+1) * 9 - expectedCount;
         assertEquals("UsedPooled", expectedUsedPooled, usedPooled);
      }
      long inUseCount = PooledInvokerProxy.getInUseCount();
      assertEquals("InUseCount", 0, inUseCount);

      log.debug("Test Stateful Bean Failover");
      log.debug("Looking up the home nextgen.StatefulSession...");
      log.debug("Calling create on StatefulSessionHome...");
      StatefulSession statefulSession =
      (StatefulSession)homeHA.create("Bupple-Dupple");
      assertTrue("statefulSessionHome.create() != null", statefulSession != null);

      NodeAnswer node1 = statefulSession.getNodeState ();
      getLog ().debug (node1);

View Full Code Here

      getLog().debug("");
      getLog().debug("Test Stateful Bean");
      getLog().debug("==================");
      getLog().debug("");
      getLog().debug(++test+"- "+"Looking up the home nextgen.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

TOP

Related Classes of org.jboss.test.testbean.interfaces.StatefulSessionHome

Copyright © 2018 www.massapicom. 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.