Package org.jboss.test.cluster.ejb3.clusteredservice

Examples of org.jboss.test.cluster.ejb3.clusteredservice.ServiceBean


   }

   public void testPassivation() throws Exception
   {
      BeanSet beanSet = getBeanSet();
      ShoppingCart cart = beanSet.cart;
      NestedXPCMonitor monitor = beanSet.monitor;
     
      Customer customer;
     
      long id = cart.createCustomer();     
      customer = monitor.find(id);
      Assert.assertEquals("Stateless has proper initial name",
                          "William", customer.getName());
      customer = cart.find(id);
      Assert.assertEquals("ShoppingCart has proper initial name",
                          "William", customer.getName());
     
      cart.update();
      customer = monitor.find(id);
      Assert.assertEquals("Stateless has proper updated name",
                           "Bill", customer.getName());
      customer = cart.find(id);
      Assert.assertEquals("ShoppingCart has proper updated name",
                          "Bill", customer.getName());
     
      cart.update2();
      customer = monitor.find(id);
      Assert.assertEquals("Stateless has proper update2() name",
                          "Billy", customer.getName());
      customer = cart.find(id);
      Assert.assertEquals("ShoppingCart has proper update2() name",
                          "Billy", customer.getName());
     
      cart.update3();
      customer = monitor.find(id);
      Assert.assertEquals("Stateless has proper update3() name",
                          "Bill Jr.", customer.getName());
      customer = cart.find(id);
      Assert.assertEquals("ShoppingCart has proper update3() name",
                          "Bill Jr.", customer.getName());
     
      // Tell the contained bean to get the customer
      cart.setContainedCustomer();
     
      // Clear the passivation counts
      cart.reset();
     
      sleep(getSleepTime()); // passivation  
     
      Assert.assertEquals("Contained bean was passivated", 1, monitor.getLocalNestedPassivations());
     
      Assert.assertTrue("Parent and local contained share customer", cart.checkContainedCustomer());
     
      Assert.assertTrue("Contained bean was activated", monitor.getLocalNestedActivations() > 0)
     
      cart.findAndUpdateStateless();
      cart.updateContained();
     
      customer = monitor.find(id);
      Assert.assertEquals("contained modified", customer.getName());
      customer = cart.find(id);
      Assert.assertEquals("contained modified", customer.getName());
         
      removeBean(monitor);
      removeBean(cart);
   }
View Full Code Here


      // we can keep creating SFSBs until we get one we want
      NestedXPCMonitor monitor = (NestedXPCMonitor) getInitialContext().lookup("NestedXPCMonitorBean/remote");
      VMID statelessVM = monitor.getVMID();
      addRemovable(monitor);

      ShoppingCart cart = null;     
      boolean vmMatch = false;
      for (int i = 0; i < 10 && !vmMatch; i++)
      {
         cart = (ShoppingCart) getInitialContext().lookup("testShoppingCart/remote");
        
         vmMatch = statelessVM.equals(cart.getVMID());
         addRemovable(cart);
         if (!vmMatch)
            removeBean(cart);
      }
     
      Assert.assertTrue("Monitor and SFSB in same VM", vmMatch);
     
      // Reset the parent to initialize all the beans
      cart.reset();
     
      // Monitor the parent
      monitor.monitor(cart);
     
      // Reset the parent to clean things up
      cart.reset();
     
      BeanSet result = new BeanSet();
      result.cart = cart;
      result.monitor = monitor;
     
View Full Code Here

  
   private void failoverTest(boolean passivate, boolean passivateAgain, boolean repeated)
   throws Exception
   {
      BeanSet beanSet = runner.getBeanSet();
      ShoppingCart parent = beanSet.cart;
      NestedXPCMonitor monitor = beanSet.monitor;
     
      // Confirm the nested beans are there
      String deepId = monitor.getDeepNestedId();
      Assert.assertNotNull("Got a deepId", deepId);
      Assert.assertFalse("Got a non-ERROR deepId", "ERROR".equals(deepId));
      String localDeepId = monitor.getLocalDeepNestedId();
      Assert.assertNotNull("Got a localDeepId", localDeepId);
      Assert.assertFalse("Got a non-ERROR localDeepId", "ERROR".equals(localDeepId));
     
      VMID origId = parent.getVMID();
      Assert.assertNotNull("Got a VMID", origId);
     
      long id = parent.createCustomer()
      Customer customer = parent.find(id);
      Assert.assertNotNull("Customer created and found on parent", customer);
     
      parent.setContainedCustomer();
      Assert.assertTrue("Parent and contained share customer", parent.checkContainedCustomer());
     
      Assert.assertTrue("Parent and remote nested do not share ref",
                        monitor.compareTopToNested(id));
      Assert.assertTrue("Parent and local nested do share ref",
                         monitor.compareTopToLocalNested(id));
      Assert.assertTrue("Remote nested and local nested do not share a ref",
                        monitor.compareNestedToLocalNested(id));
      Assert.assertTrue("Remote nested and deepNested share a ref",
                        monitor.compareNestedToDeepNested(id));
      Assert.assertTrue("Local nested and localDeepNested share a ref",
                        monitor.compareLocalNestedToLocalDeepNested(id));
     
      VMID newId = parent.getVMID();
      Assert.assertTrue("VMID remained the same", origId.equals(newId));
     
      if (passivate)
      {
         runner.sleep();
      }
     
      parent.setUpFailover("once");
     
      newId = parent.getVMID();
      assertNotNull("Got a new VMID", newId);
      assertFalse("Failover has occurred", origId.equals(newId));
     
      InitialContext[] ctxs = new InitialContext[2];
      ctxs[0] = getInitialContext(1);
      ctxs[1] = getInitialContext(0);
      monitor = runner.getXPCMonitor(ctxs, newId);     
     
      monitor.monitor(parent);
     
      Assert.assertTrue("Parent and remote nested do not share ref",
                        monitor.compareTopToNested(id));
      Assert.assertTrue("Parent and local nested do share ref",
                         monitor.compareTopToLocalNested(id));
      Assert.assertTrue("Remote nested and local nested do not share a ref",
                        monitor.compareNestedToLocalNested(id));
      Assert.assertTrue("Remote nested and deepNested share a ref",
                        monitor.compareNestedToDeepNested(id));
      Assert.assertTrue("Local nested and localDeepNested share a ref",
                        monitor.compareLocalNestedToLocalDeepNested(id));
     
      if (repeated)
      {
         if (passivateAgain)
         {
            runner.sleep();
         }
         origId = newId;
        
         parent.setUpFailover("once");
        
         newId = parent.getVMID();
         assertNotNull("Got a new VMID", newId);
         assertFalse("Failover has occurred", origId.equals(newId));
        
         // Swap the contexts so we try node0 first
         InitialContext ctx = ctxs[1];
View Full Code Here

   @Override
   protected void setUp() throws Exception
   {
      super.setUp();
     
      runner = new NestedBeanTestRunner(getInitialContext(0), getLog());
      runner.setUp();
      // Use a sleep time equal to 2 thread runs + a 100 ms fudge
      runner.setSleepTime(10100L);
      // For clustered beans, an invocation is a passivation
      runner.setPassivationPerInvocation(1);
View Full Code Here

   @Override
   protected void setUp() throws Exception
   {
      super.setUp();
     
      runner = new NestedBeanTestRunner(getInitialContext(0), getLog());
      runner.setUp();
      // Use a sleep time equal to 2 thread runs + a 100 ms fudge
      runner.setSleepTime(10100L);
      // For clustered beans, an invocation is a passivation
      runner.setPassivationPerInvocation(1);
View Full Code Here

   throws Exception
   {
      getLog().debug("Test Nested Stateful Bean Counter Failover with Remote");
      getLog().debug("======================================================");
     
      NestedBeanSet beanSet = runner.getNestedBeanSet();
      ParentStatefulRemote stateful = beanSet.parent;
      VMID node1 = stateful.getVMID();
      assertNotNull("State node: ", node1);
      getLog ().debug ("Node 1 ID: " +node1);
View Full Code Here

   throws Exception
   {
      getLog().debug("Test Nested Stateful Bean Counter Failover");
      getLog().debug("==========================================");
     
      NestedBeanSet beanSet = runner.getNestedBeanSet();
      ParentStatefulRemote stateful = beanSet.parent;
      VMID node1 = stateful.getVMID();
      assertNotNull("State node: ", node1);
      getLog ().debug ("Node 1 ID: " +node1);
View Full Code Here

     
      NestedStateful nested = (NestedStateful) parent.getNested();
      parentInv++;
      runner.addRemovable(nested);
     
      NestedBeanSet beanSet = runner.getNestedBeanSet();
     
      int attempts = 0;
      while (beanSet.parent.getVMID().equals(beanSet.nested.getVMID()))
      {
         if (++attempts == 20)
View Full Code Here

   @Override
   protected void setUp() throws Exception
   {
      super.setUp();
     
      runner = new XPCTestRunner(getInitialContext(0), getLog());
      runner.setUp();
      // Use a sleep time equal to 2 thread runs + a 100 ms fudge
      runner.setSleepTime(10100L);
   }
View Full Code Here

   }
  
   private void failoverTest(boolean passivate, boolean passivateAgain, boolean repeated)
   throws Exception
   {
      BeanSet beanSet = runner.getBeanSet();
      ShoppingCart parent = beanSet.cart;
      NestedXPCMonitor monitor = beanSet.monitor;
     
      // Confirm the nested beans are there
      String deepId = monitor.getDeepNestedId();
View Full Code Here

TOP

Related Classes of org.jboss.test.cluster.ejb3.clusteredservice.ServiceBean

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.