Package org.jboss.test.cluster.ejb3.clusteredsession.ejbthree921

Examples of org.jboss.test.cluster.ejb3.clusteredsession.ejbthree921.MyStateful


   public void test1() throws Throwable
   {
      Serializable id = container.getSessionFactory().createSession(new Class[] { }, new Object[] { });
     
      Method method = MyStateful.class.getMethod("getBusinessObject");
      MyStateful bean = (MyStateful) container.invoke(id, MyStateful.class, method, null);
     
      MyStatefulBean.barrier.await(5000, TimeUnit.MILLISECONDS);
     
      assertEquals(0, MyStatefulBean.activations);
      assertEquals(1, MyStatefulBean.passivations);
     
      MyStateful bean2 = bean.getBusinessObject();
     
      assertEquals(1, MyStatefulBean.activations);
     
      assertEquals(bean, bean2);
   }
View Full Code Here


   public void test1() throws Throwable
   {
      Serializable id = container.getSessionFactory().createSession(null, null);
     
      Method method = MyStateful.class.getMethod("getBusinessObject");
      MyStateful bean = (MyStateful) container.invoke(id, MyStateful.class, method, null);
     
      MyStatefulBean.barrier.await(5000, TimeUnit.MILLISECONDS);
     
      assertEquals(0, MyStatefulBean.activations);
      assertEquals(1, MyStatefulBean.passivations);
     
      MyStateful bean2 = bean.getBusinessObject();
     
      assertEquals(1, MyStatefulBean.activations);
     
      assertEquals(bean, bean2);
   }
View Full Code Here

      containers.add(deploySessionEjb(MyStateful21Bean.class));
   }
  
   private MyStateful runMyStatefulTest() throws NamingException
   {
      MyStateful session = (MyStateful) getInitialContext().lookup("MyStatefulBean/remote");
      session.setName("Test");
      String actual = session.sayHello();
      assertEquals("Hi Test", actual);
      try
      {
         session.remove();
      }
      catch(RuntimeException e)
      {
         if(e.getCause().getMessage().equals("pre destroy called multiple times"))
            fail("pre destroy called multiple times");
View Full Code Here

   }
  
   @Test
   public void test1() throws Exception
   {
      MyStateful session = runMyStatefulTest();
      try
      {
         session.remove();
         fail("Should have thrown NoSuchEJBException");
      }
      catch(NoSuchEJBException e)
      {
         // okay
View Full Code Here

   }
  
   @Test
   public void testWithInTransaction() throws Exception
   {
      MyStateful session;
      TransactionManager tm = lookup("java:/TransactionManager", TransactionManager.class);
      tm.begin();
      try
      {
         session = runMyStatefulTest();
      }
      finally
      {
         tm.rollback();
      }
      try
      {
         session.remove();
         fail("Should have thrown NoSuchEJBException");
      }
      catch(NoSuchEJBException e)
      {
         // okay
View Full Code Here

     
      InitialContext ctx = new InitialContext();
      System.out.println("ctx = " + ctx);
      //System.out.println("  " + container.getInitialContext().list("MyStatelessBean").next());
      MyStateful bean = (MyStateful) ctx.lookup("MyStatefulBean/remote");
     
      bean.setName("Me");
      String actual = bean.sayHi();
      assertEquals("Hi Me", actual);
     
      getBootstrap().getKernel().getController().uninstall(containerName);
      Ejb3Registry.unregister(container);
   }
View Full Code Here

     
      InitialContext ctx = new InitialContext();
      System.out.println("ctx = " + ctx);
      //System.out.println("  " + container.getInitialContext().list("MyStatelessBean").next());
      MyStateful bean = (MyStateful) ctx.lookup("MyStatefulBean/remote");
     
      bean.setName("Me");
      String actual = bean.sayHi();
      assertEquals("Hi Me", actual);
     
      getBootstrap().getKernel().getController().uninstall(containerName);
      Ejb3Registry.unregister(container);
   }
View Full Code Here

         throws ServletException, IOException
   {
      try
      {
         log.info("EJBServlet.processRequest invoked");
         ServiceRemote test = (ServiceRemote) getInitialContext().lookup("ServiceBean/remote");
         log.info("looked up remote bean ServiceBean/remote, about to invoke remoteMethod() on bean");
         test.remoteMethod();
         log.info("invoked remoteMethod() on bean");
  /*       MBeanServer server = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
         ObjectName testerName = new ObjectName("default:service=service");
         Object[] params = {};
         String[] sig = {};
View Full Code Here

      getLog().debug("Test Stateless Bean loadbalancing");
      getLog().debug("==================================");
      getLog().debug(++StatelessUnitTestCase.test +"- "
              +"Looking up clusteredStateless/remote...");
      ClusteredStatelessRemote stateless = (ClusteredStatelessRemote) ctx.lookup("clusteredStateless/remote");
     
      confirmTargetCount(2, true);
     
      NodeAnswer node1 = stateless.getNodeState();
      getLog ().debug ("Node 1 ID: " +node1);

      confirmTargetCount(2, false);
     
      Map<VMID, Integer> callCount = new HashMap<VMID, Integer>();
     
      int allowedErr = 0;
      allowedErr = validateBalancing(stateless, callCount, 4, 2, 0);
     
      ctx = getInitialContext(1);
      stateless = (ClusteredStatelessRemote) ctx.lookup("clusteredStateless/remote");
      confirmTargetCount(2, true);
      NodeAnswer node2 = stateless.getNodeState();
      getLog ().debug ("Node 2 ID : " +node2);
      confirmTargetCount(2, true);
     
//      assertFalse("Second call went to different node " + node2.nodeId + " vs " + node1.nodeId,
//            node1.nodeId.equals(node2.nodeId));
View Full Code Here

  
      getLog().debug("Test Stateless Bean loadbalancing after topology change");
      getLog().debug("==================================");
      getLog().debug(++StatelessUnitTestCase.test +"- "
              +"Looking up clusteredStateless/remote...");
      ClusteredStatelessRemote stateless = (ClusteredStatelessRemote) ctx.lookup("clusteredStateless/remote");
      confirmTargetCount(2, true);
      NodeAnswer node1 = stateless.getNodeState();
      getLog ().debug ("Node 1 ID: " +node1);
      confirmTargetCount(2, true);
      NodeAnswer node2 = stateless.getNodeState();
      getLog ().debug ("Node 2 ID : " +node2);
        
      assertFalse(node1.nodeId.equals(node2.nodeId));
      confirmTargetCount(2, false);
     
      MBeanServerConnection[] adaptors = getAdaptors();
     
      deployed0 = false;
      undeploy(adaptors[0], DEPLOYMENT);
     
      NodeAnswer call3 = stateless.getNodeState();
      getLog ().debug ("Call 3 ID : " +call3);
      confirmTargetCount(1, true);
     
      assertTrue("Call 3 hit existing node", node1.nodeId.equals(call3.nodeId) || node2.nodeId.equals(call3.nodeId));
     
      NodeAnswer call4 = stateless.getNodeState();
      getLog ().debug ("Call 4 ID : " +call4);
     
      assertEquals("Call 3 and Call 4 hit the same node", call3.nodeId, call4.nodeId);
     
      deploy(adaptors[0], DEPLOYMENT);
      deployed0 = true;
     
      // Call once to get the new topology. The next call after this
      // might go to the same node if the topology change means the node
      // that handled this call moves in the target list to the next position
      NodeAnswer call5 = stateless.getNodeState();
      getLog ().debug ("Call 5 ID : " +call5);
     
      Map<VMID, Integer> callCount = new HashMap<VMID, Integer>();
      validateBalancing(stateless, callCount, 4, 2, 0);
     
      deployed1 = false;
      undeploy(adaptors[1], DEPLOYMENT);
     
      NodeAnswer call6 = stateless.getNodeState();
      getLog ().debug ("Call 6 ID : " +call6);
      confirmTargetCount(1, true);
     
      assertTrue("Call 6 hit existing node", callCount.containsKey(call6.nodeId));
     
      NodeAnswer call7 = stateless.getNodeState();
      getLog ().debug ("Call 7 ID : " +call7);
     
      assertEquals("Call 6 and Call 7 hit the same node", call6.nodeId, call7.nodeId);
     
      deploy(adaptors[1], DEPLOYMENT);
      deployed1 = true;
     
      // Call once to get the new topology. The next call after this
      // might go to the same node if the topology change means the node
      // that handled this call moves in the target list to the next position
      NodeAnswer call8 = stateless.getNodeState();
      getLog ().debug ("Call 8 ID : " +call8);
     
      callCount = new HashMap<VMID, Integer>();
      validateBalancing(stateless, callCount, 4, 2, 0);
   }
View Full Code Here

TOP

Related Classes of org.jboss.test.cluster.ejb3.clusteredsession.ejbthree921.MyStateful

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.