Package org.jboss.test.cluster.ejb2.basic.bean

Examples of org.jboss.test.cluster.ejb2.basic.bean.SessionToEntityBean


      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);
     
      // Reconfigure the cluster so the existing targets are invalid
      // BES -- don't bother; we test that functionality in testRetryInterceptor
      // just confirm that reestablishing the targets works
View Full Code Here


      // 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);

      // Now we switch to the other node, simulating a failure on node 1
      System.setProperty ("JBossCluster-DoFail", "once");
      NodeAnswer node2 = statefulSession.getNodeState ();
      log.debug (node2);
      assertEquals("Value is identical on replicated node1", "Bupple-Dupple", node1.answer);
      assertEquals("Value is identical on replicated node2", "Bupple-Dupple", node2.answer);

      // we change our name to see if it replicates to node 1
      statefulSession.setName ("Changed");

      // now we travel back on node 1
      System.setProperty ("JBossCluster-DoFail", "once");
      node1 = statefulSession.getNodeState ();
      log.debug(node1);

      assertEquals("Value is identical on replicated node1", "Changed", node1.answer);
      node2 = statefulSession.getNodeState ();
      log.debug(node2);
      assertEquals("Value is identical on replicated node2", "Changed", node2.answer);

      statefulSession.remove();

      int totalCount = PooledInvokerProxy.getTotalPoolCount();
      // N cluster nodes + 1 for unclustered
      int expectedCount = urls.length + 1;
      assertEquals("TotalPoolCount", expectedCount, totalCount);
View Full Code Here

      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);
     
      // Now we switch to the other node, simulating a failure on node 1
      //
      System.setProperty ("JBossCluster-DoFail", "once");
      NodeAnswer node2 = statefulSession.getNodeState ();     
      getLog ().debug (node2);
     
      assertTrue ("Failover has occured", !node1.nodeId.equals (node2.nodeId));
     
      assertTrue ("Value is identical on replicated node",
                  "Bupple-Dupple".equals (node1.answer) &&
                  node1.answer.equals (node2.answer) );

      // Stop and restart the ClusterPartition on node1
      restartPartition(adaptors[0]);
     
      // Let the cluster stabilize
      sleep(2000);
     
      // we change our name to see if it replicates to node 1
      //
      statefulSession.setName ("Changed");
     
      // now we travel back to node 1
      System.setProperty ("JBossCluster-DoFail", "once");
      node1 = statefulSession.getNodeState ();
      getLog ().debug (node1);
     
      assertTrue ("Failover has occured", !node1.nodeId.equals (node2.nodeId));
     
      assertTrue ("Value is identical on replicated node", "Changed".equals (node1.answer) );     
     
      statefulSession.remove();
      getLog().debug("ok");
   }
View Full Code Here

      getLog().debug(++test+"- "+"Looking up the home nextgen.StatelessSession...");
      StatelessSessionHome  statelessSessionHome =
      (StatelessSessionHome) ctx.lookup("nextgen.StatelessSession");
      if (statelessSessionHome!= null ) getLog().debug("ok");
      getLog().debug(++test+"- "+"Calling create on StatelessSessionHome...");
      StatelessSession statelessSession =
      (StatelessSession)statelessSessionHome.create();
      assertTrue("statelessSessionHome.create() != null", statelessSession != null);
      getLog().debug("ok");
     
      getLog().debug(++test+"- "+"Calling getEJBHome() on StatelessSession...");
      assertTrue("statelessSession.getEJBHome() != null", statelessSession.getEJBHome() != null);
      getLog().debug("ok");
     
      getLog().debug(++test+"- "+"Reseting the number of calls made on beans (making 2 calls)... ");
      for (int i=0; i<6; i++)
      {
         getLog().debug(++test+"- "+" Reseting number... ");
         statelessSession.resetNumberOfCalls ();        
      }
     
      getLog().debug(++test+"- "+"Now making 20 calls on this remote... ");
      for (int i=0; i<20; i++)
      {
         getLog().debug(++test+"- "+" Calling remote... ");
         statelessSession.makeCountedCall ();        
      }
     
      getLog().debug(++test+"- "+"Getting the number of calls that have been performed on each bean... ");
      long node1 = statelessSession.getCallCount();
      getLog().debug(++test+"- "+"One node has received: " + node1);
     
      long node2 = statelessSession.getCallCount();
      getLog().debug(++test+"- "+"The other node has received: " + node2);
     
      if (node1 == node2 &&
          node1 == 10)
      {
         getLog().debug(++test+"- "+"Test is ok.");
      }
      else
      {
         getLog().debug(++test+"- "+"Something wrong has happened! Calls seems not to have been load-balanced.");
         fail ("Calls have not been correctly load-balanced on the SLSB remote interface.");
      }
     
      statelessSession.remove();
      getLog().debug("ok");
   }           
View Full Code Here

      getLog().debug(++test+"- "+"Looking up the home nextgen.StatelessSession...");
      StatelessSessionHome  statelessSessionHome =
      (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession");
      if (statelessSessionHome!= null ) getLog().debug("ok");
         getLog().debug(++test+"- "+"Calling create on StatelessSessionHome...");
      StatelessSession statelessSession =
      (StatelessSession)statelessSessionHome.create();
      assertTrue("statelessSessionHome.create() != null", statelessSession != null);
      getLog().debug("ok");
     
      getLog().debug(++test+"- "+"Calling getEJBHome() on StatelessSession...");
      assertTrue("statelessSession.getEJBHome() != null", statelessSession.getEJBHome() != null);
      getLog().debug("ok");
     
      getLog().debug(++test+"- "+"Reseting the number of calls made on beans (making 2 calls)... ");
      for (int i=0; i<6; i++)
      {
         getLog().debug(++test+"- "+" Reseting number... ");
         statelessSession.resetNumberOfCalls ();        
      }
     
      getLog().debug(++test+"- "+"Now making 20 calls on this remote... ");
      for (int i=0; i<20; i++)
      {
         getLog().debug(++test+"- "+" Calling remote... ");
         statelessSession.makeCountedCall ();        
      }
     
      getLog().debug(++test+"- "+"Getting the number of calls that have been performed on each bean... ");
      long node1 = statelessSession.getCallCount();
      getLog().debug(++test+"- "+"One node has received: " + node1);
     
      long node2 = statelessSession.getCallCount();
      getLog().debug(++test+"- "+"The other node has received: " + node2);
     
      if (node1 == node2 &&
          node1 == 10)
      {
         getLog().debug(++test+"- "+"Test is ok.");
      }
      else
      {
         getLog().debug(++test+"- "+"Something wrong has happened! Calls seems not to have been load-balanced.");
         fail ("Calls have not been correctly load-balanced on the SLSB remote interface.");
      }
     
      statelessSession.remove();
      getLog().debug("ok");
   }
View Full Code Here

         getLog().debug("lookup " + i + " ok");
        
         String last = null;
         for (int j = 0; j < 10; j++)
         {
            StatelessSession slsb = home.create();
            assertTrue("slsb != null", slsb != null);
            getLog().debug("create " + j + " ok");
           
            for (int k = 0; k < 3; k++)
            {
               String cur = slsb.getBindAddress();
               if (cur == null)
               {
                  getLog().debug("jboss.bind.address property not set; aborting");
                  return;
               }
View Full Code Here

      getLog().debug(++test+"- "+"Looking up the home nextgen.StatelessSession...");
      StatelessSessionHome  statelessSessionHome =
      (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession");
      if (statelessSessionHome!= null ) getLog().debug("ok");
         getLog().debug(++test+"- "+"Calling create on StatelessSessionHome...");
      StatelessSession statelessSession = (StatelessSession)statelessSessionHome.create();
      assertTrue("statelessSessionHome.create() != null", statelessSession != null);
      getLog().debug("ok");

      getLog().debug(++test+"- "+"reset number of calls");
      statelessSession.resetNumberOfCalls();
      statelessSession.resetNumberOfCalls();

      // This should make two calls on the same node
      getLog().debug(++test+"- "+"callBusinessMethodB");
      String jndiURL = urls[0] + "/nextgen_StatelessSession";
      statelessSession.callBusinessMethodB(jndiURL);
     
      getLog().debug(++test+"- "+"Getting the number of calls that have been performed on each bean... ");
      long node1 = statelessSession.getCallCount();
      getLog().debug(++test+"- "+"One node has received: " + node1);
     
      long node2 = statelessSession.getCallCount();
      getLog().debug(++test+"- "+"The other node has received: " + node2);
     
      if ((node1 == 2 && node2 == 0) || (node1 == 0 && node2 == 2))
      {
         getLog().debug(++test+"- "+"Test is ok.");
View Full Code Here

         System.out.println("begin testColocation");
         InitialContext ctx = new InitialContext();
         if( jndiURL == null )
            jndiURL = "jnp://" + System.getProperty("jboss.bind.address", "localhost") + ":1100/nextgen_StatelessSession";
         StatelessSessionHome home = (StatelessSessionHome) ctx.lookup(jndiURL);
         StatelessSession session = home.create();
         session.callBusinessMethodA();
         System.out.println("end testColocation");
      }
      catch (Exception ex)
      {
         ex.printStackTrace();
View Full Code Here

      getLog().debug("Looking up the home nextgen.StatelessSession" + getJndiSuffix()+"...");
      StatelessSessionHome  slsbHome =
      (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession" + getJndiSuffix());
      if (slsbHome!= null ) getLog().debug("ok");
      getLog().debug("Calling create on StatelessSessionHome" + getJndiSuffix()+"...");
      StatelessSession slsb = slsbHome.create();

      getLog().debug("StatelessSession: Now making 1 call on server0 ");
      assertEquals("StatelessSession: Server0 has no calls", 0, slsb.getCallCount());
     
      getLog().debug("Looking up home for nextgen_EntityPK" + getJndiSuffix()+"...");
      EntityPKHome pkHome = (EntityPKHome) ctx.lookup("nextgen_EntityPK" + getJndiSuffix());
      assertTrue("pkHome != null", pkHome != null);
      getLog().debug("ok");
View Full Code Here

      getLog().debug("Looking up the home nextgen.StatelessSession" + getJndiSuffix()+"...");
      StatelessSessionHome  home =
            (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession" + getJndiSuffix());
      if (home!= null ) getLog().debug("ok");
      getLog().debug("Calling create on StatelessSessionHome" + getJndiSuffix()+"...");
      StatelessSession slsb = home.create();

      getLog().debug("StatelessSession: Now making 1 call on server0 ");
      assertEquals("StatelessSession: Server0 has no calls", 0, slsb.getCallCount());
     
      // Undeploy the ear
      MBeanServerConnection[] adaptors = getAdaptors();
      undeploy(adaptors[0], "test-retry.ear");
      setDeployed0(false);
View Full Code Here

TOP

Related Classes of org.jboss.test.cluster.ejb2.basic.bean.SessionToEntityBean

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.