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

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


     
      getLog().debug("Looking up NestedBeanMonitorBean...");
      NestedBeanMonitor monitor = (NestedBeanMonitor) ctx.lookup("NestedBeanMonitorBean/remote");
      VMID monitorVM = monitor.getVMID();
      runner.addRemovable(monitor);
      ParentStatefulRemote parent = null;     
      boolean vmMatch = true;
      for (int i = 0; i < 20 && vmMatch; i++)
      {
         env.put(NamingContext.PROVIDER_URL, namingURLS[i % 2]);        
         ctx = new InitialContext(env);
        
         getLog().debug("Looking up testParentStateful... Attempt " + (i + 1));
         parent = (ParentStatefulRemote) ctx.lookup("testParentStateful/remote");

         VMID parentVM = parent.getVMID();
         vmMatch = monitorVM.equals(parentVM);
         runner.addRemovable(parent);
         if (vmMatch)
         {
            runner.removeBean(parent);
         }
      }
     
      assertFalse("Monitor and SFSB in same VM", vmMatch);
     
      // Reset the parent to initialize all the beans
      parent.reset();
     
      // Monitor the parent
      monitor.monitor(parent);
     
      // Reset the parent to clean things up
      parent.reset();
      parentInv++;
      nestedInv++;
     
      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)
         {
            System.err.println("Unable to obtain nested bean running on separate VM from parent");
            log.warn("Unable to obtain nested bean running on separate VM from parent");
            return;
         }
         beanSet = runner.getNestedBeanSet();
      }

      // Exercise the beans, trigger replication
      assertEquals("Remote counter: ", 1, parent.increment());
      parentInv++;
      nestedInv++;
      assertEquals("Remote counter: ", 2, parent.increment());
      parentInv++;
      nestedInv++;
      assertEquals("Local counter: ", 1, parent.incrementLocal());
      parentInv++;
      assertEquals("Local counter: ", 2, parent.incrementLocal());
      parentInv++;
     
      // This call activates the nested bean without triggering the @PrePassivate
      // callback at the end of the call because of the way the bean
      // implements Optimized
View Full Code Here


   {
      getLog().debug("Running testBasic()");
      getLog().debug("==================================");
     
      NestedBeanSet beanSet = getNestedBeanSet();
      ParentStatefulRemote stateful = beanSet.parent;
     
      Assert.assertEquals("Remote counter: ", 1, stateful.increment());
      Assert.assertEquals("Remote counter: ", 2, stateful.increment());
      Assert.assertEquals("Local counter: ", 1, stateful.incrementLocal());
      Assert.assertEquals("Local counter: ", 2, stateful.incrementLocal());
     
      removeBean(stateful);
     
      getLog().debug("ok");
   }
View Full Code Here

   {
      getLog().debug("Running testDependentLifecycle()");
      getLog().debug("==================================");
     
      NestedBeanSet beanSet = getNestedBeanSet();
      ParentStatefulRemote parent = beanSet.parent;
      NestedStateful nested = beanSet.nested;
      NestedBeanMonitor monitor = beanSet.monitor;
     
      Assert.assertEquals("Remote counter (via parent): ", 1, parent.increment())
     
      String deepId = monitor.getDeepNestedId();
      Assert.assertNotNull("Got a deepId", deepId);
      Assert.assertFalse("Got a non-ERROR deepId", "ERROR".equals(deepId));
      String localDeepId = monitor.getLocalDeepNestedId();
View Full Code Here

      getLog().debug("Running testStatefulPassivation()");
      getLog().debug("==================================");
     
      NestedBeanSet beanSet = getNestedBeanSet();
      NestedBeanMonitor monitor = beanSet.monitor;
      ParentStatefulRemote parent = beanSet.parent;
      NestedStateful nested = beanSet.nested;
     
      int parentInv = beanSet.parentInvocations; // 2
      int nestedInv = beanSet.nestedInvocations; // 1
View Full Code Here

      addRemovable(monitor);
     
      int parentInv = 0;
      int nestedInv = 0;
     
      ParentStatefulRemote parent = null;     
      boolean vmMatch = false;
      for (int i = 0; i < 20 && !vmMatch; i++)
      {
         getLog().debug("Looking up testParentStateful... Attempt " + (i + 1));
         parent = (ParentStatefulRemote) initialContext.lookup("testParentStateful/remote");
        
         vmMatch = monitorVM.equals(parent.getVMID());
         addRemovable(parent);
         if (!vmMatch)
         {
            removeBean(parent);
         }
      }
     
      Assert.assertTrue("Monitor and SFSB in same VM", vmMatch);
     
      // Reset the parent to initialize all the beans
      parent.reset();
     
      // Monitor the parent
      monitor.monitor(parent);
     
      // Reset the parent to clean things up
      parent.reset();
      parentInv++;
      nestedInv++;
     
      NestedStateful nested = (NestedStateful) parent.getNested();
      parentInv++;
      addRemovable(nested);
     
      NestedBeanSet result = new NestedBeanSet();
      result.monitor = monitor;
View Full Code Here

     
      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());
     
View Full Code Here

   {
      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());
     
      removeBean(cart);
      removeBean(monitor);
   }
View Full Code Here

      String localDeepId = monitor.getLocalDeepNestedId();
      Assert.assertNotNull("Got a localDeepId", localDeepId);
      Assert.assertFalse("Got a non-ERROR localDeepId", "ERROR".equals(localDeepId));
     
      long id = parent.createCustomer()
      Customer customer = parent.find(id);
      Assert.assertNotNull("Customer created and found on parent", customer);
     
      parent.setContainedCustomer();
      Assert.assertTrue("Parent and local contained share customer", parent.checkContainedCustomer());
     
View Full Code Here

      String localDeepId = monitor.getLocalDeepNestedId();
      Assert.assertNotNull("Got a localDeepId", localDeepId);
      Assert.assertFalse("Got a non-ERROR localDeepId", "ERROR".equals(localDeepId));
     
      long id = parent.createCustomer()
      Customer customer = parent.find(id);
      Assert.assertNotNull("Customer created and found on parent", customer);
     
      Assert.assertTrue("Parent and remote nested do not share ref",
                        monitor.compareTopToNested(id));
      Assert.assertTrue("Parent and local nested do share ref",
View Full Code Here

   {
      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

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.