Package org.jboss.test.cluster.ejb3.stateful

Examples of org.jboss.test.cluster.ejb3.stateful.StatefulHome


     
      Properties env = new Properties();
      env.setProperty(Context.PROVIDER_URL, jndiURLs[0]);
      env.setProperty("jnp.disableDiscovery", "true");
      InitialContext ctx = new InitialContext(env);
      VMTester tester = (VMTester) ctx.lookup(TESTER_JNDI_NAME);
     
      VMID local = tester.getVMID();
      assertNotNull("Got the local VMID", local);
     
      Properties env1 = new Properties();
      env1.setProperty(Context.PROVIDER_URL, jndiURLs[1]);
      env1.setProperty("jnp.disableDiscovery", "true");
      ctx = new InitialContext(env1);
      VMTester remote = (VMTester) ctx.lookup(jndiName);
     
      // This call instantiates the SFSB if needed
      VMID remoteID = remote.getVMID();
      assertNotNull("Got the remote VMID", remoteID);
     
      // Pass the proxy back to the server and invoke getVMID() on it
      VMID passThroughID = tester.getVMIDFromRemote(remote);
      assertNotNull("Got the remote VMID", passThroughID);
View Full Code Here


                               "clusteredsession-ds.xml, clusteredsession-xpc-scoped.jar");

      suite.addTest(t1);

      // Create an initializer for the test suite
      DBSetup wrapper = new DBSetup(suite);
      return wrapper;    
   }
View Full Code Here

                               "clusteredsession-ds.xml, clusteredsession-xpc.jar");

      suite.addTest(t1);

      // Create an initializer for the test suite
      DBSetup wrapper = new DBSetup(suite);
      return wrapper;    
   }
View Full Code Here

      stateless.testInjection();
     
      ServiceRemote service = (ServiceRemote) getInitialContext().lookup("ServiceBean/remote");
      service.testInjection();
     
      ClusteredStateful stateful = (ClusteredStateful)getInitialContext().lookup("ClusteredStateful");
      assertNotNull(stateful);
      stateful.setState("state");
      assertEquals("state", stateful.getState());
      stateful.testSerializedState("state");
      assertEquals(null, stateful.getInterceptorState());
      stateful.setInterceptorState("hello world");
      assertFalse(stateful.testSessionContext());
      Thread.sleep(10 * 1000);
      assertTrue(stateful.wasPassivated());
     
      assertEquals("state", stateful.getState());
      assertEquals("hello world", stateful.getInterceptorState());

      Stateful another = (Stateful)getInitialContext().lookup("Stateful");
      assertEquals(null, another.getInterceptorState());
      another.setInterceptorState("foo");
      assertEquals("foo", another.getInterceptorState());
      assertEquals("hello world", stateful.getInterceptorState());
     
      assertFalse(stateful.testSessionContext());
     
      stateful.testResources();
     
      stateless.testInjection();
     
      service.testInjection();
   }
View Full Code Here

      test.testRollback2();
   }
  
   public void testConcurrentAccess() throws Exception
   {
      ConcurrentStateful stateful = (ConcurrentStateful) new InitialContext().lookup("ConcurrentStatefulBean/remote");
      stateful.getState();
     
      StatefulInvoker[] invokers = new StatefulInvoker[2];
      for (int i = 0; i < 2 ; ++i)
      {
         invokers[i] = new StatefulInvoker(stateful);
View Full Code Here

      assertTrue(wasConcurrentException);
   }
  
   public void testOverrideConcurrentAccess() throws Exception
   {
      ConcurrentStateful stateful = (ConcurrentStateful) new InitialContext().lookup("OverrideConcurrentStateful");
      stateful.getState();
     
      StatefulInvoker[] invokers = new StatefulInvoker[2];
      for (int i = 0; i < 2 ; ++i)
      {
         invokers[i] = new StatefulInvoker(stateful);
View Full Code Here

   }
  
   public void testExtendedPersistencePassivation() throws Exception
   {
      EntityFacade stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
      Entity entity = null;
      entity = stateful.createEntity("Kalin");
     
      //passivate
      Thread.sleep(10 * 1000);
     
      MBeanServerConnection server = getServer();
      ObjectName objectName = new ObjectName("jboss.jca:service=CachedConnectionManager");
      int inUseConnections = (Integer)server.getAttribute(objectName, "InUseConnections");
      System.out.println("inUseConnections \n" + inUseConnections);
      assertEquals(0, inUseConnections);
     
      //activate
      entity = stateful.loadEntity(entity.getId());
     
      inUseConnections = (Integer)server.getAttribute(objectName, "InUseConnections");
      System.out.println("inUseConnections \n" + inUseConnections);
      if (inUseConnections != 0)
         printStats(server);
      assertEquals(0, inUseConnections);
     
      entity = stateful.createEntity("Kalin" + entity.getId());
     
      inUseConnections = (Integer)server.getAttribute(objectName, "InUseConnections");
      System.out.println("inUseConnections \n" + inUseConnections);
     
      if (inUseConnections != 0)
View Full Code Here

      stateful.testStateful();
   }
  
   public void testExtendedPersistencePassivation() throws Exception
   {
      EntityFacade stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
      Entity entity = null;
      entity = stateful.createEntity("Kalin");
     
      //passivate
      Thread.sleep(10 * 1000);
     
      MBeanServerConnection server = getServer();
      ObjectName objectName = new ObjectName("jboss.jca:service=CachedConnectionManager");
      int inUseConnections = (Integer)server.getAttribute(objectName, "InUseConnections");
      System.out.println("inUseConnections \n" + inUseConnections);
      assertEquals(0, inUseConnections);
     
      //activate
      entity = stateful.loadEntity(entity.getId());
     
      inUseConnections = (Integer)server.getAttribute(objectName, "InUseConnections");
      System.out.println("inUseConnections \n" + inUseConnections);
      if (inUseConnections != 0)
         printStats(server);
      assertEquals(0, inUseConnections);
     
      entity = stateful.createEntity("Kalin" + entity.getId());
     
      inUseConnections = (Integer)server.getAttribute(objectName, "InUseConnections");
      System.out.println("inUseConnections \n" + inUseConnections);
     
      if (inUseConnections != 0)
View Full Code Here

      assertTrue(wasConcurrentException);
   }
  
   public void testDestroyException() throws Exception
   {
      EntityFacade stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
      assertNotNull(stateful);
      stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.RUNTIME);
      stateful.createEntity("Kalin");
     
      try
      {
         stateful.remove();
         fail("should catch RuntimeException");
      }
      catch (RuntimeException e)
      {
         System.out.println("*** caught " + e.getMessage());
      }
     
      try
      {
         stateful.createEntity("Nogo");
         fail("expected NoSuchEJBException");
      }
      catch(NoSuchEJBException e)
      {
         // ok
      }
     
      stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
      assertNotNull(stateful);
      stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.CHECKED);
      stateful.createEntity("Napa");
     
      try
      {
         stateful.remove();
         fail("should catch RuntimeException");
      }
      catch (CheckedApplicationException e)
      {
         System.out.println("*** caught " + e.getMessage());
      }
     
      stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.APPLICATION);
     
      stateful.createEntity("Cabernet");
     
      try
      {
         stateful.removeWithTx();
         fail("should catch RuntimeException");
      }
      catch (AnnotatedAppException e)
      {
         System.out.println("*** caught " + e.getMessage());
      }
     
      stateful.createEntity("Bailey");
     
      stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
      assertNotNull(stateful);
      stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.NONE);
     
   }
View Full Code Here

     
   }
     
   public void testDestroyExceptionWithTx() throws Exception
   {
      EntityFacade stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
      stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.RUNTIME);
      assertNotNull(stateful);
      stateful.createEntity("Cabernet");
     
      try
      {
         stateful.removeWithTx();
         fail("should catch RuntimeException");
      }
      catch (RuntimeException e)
      {
         System.out.println("*** caught " + e.getMessage());
      }
     
      try
      {
         stateful.createEntity("Nogo");
         fail("expected NoSuchEJBException");
      }
      catch(NoSuchEJBException e)
      {
         // ok
      }    
     
      stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
      stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.NONE);
   }
View Full Code Here

TOP

Related Classes of org.jboss.test.cluster.ejb3.stateful.StatefulHome

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.