Examples of Stateful


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

      // Establish how many beans are already active
      int prevCount = (Integer)server.getAttribute(testerName, "CreateCount");
      System.out.println("prevCount = " + prevCount);
      assertTrue("can't have negative creation count", prevCount >= 0);
     
      Stateful stateful = (Stateful)getInitialContext().lookup(jndiBinding);
      assertNotNull(stateful);
      stateful.setState("state");
     
      int createCount = (Integer)server.getAttribute(testerName, "CreateCount");
      assertEquals(1, createCount - prevCount);
     
      // Ensure cache is incremented
      int newCacheSize = (Integer)server.getAttribute(testerName, "CacheSize");
      assertEquals(startCacheSize+1, newCacheSize);
     
      int totalSize = (Integer)server.getAttribute(testerName, "TotalSize");
      assertEquals(startTotalSize+1, totalSize);
     
      assertEquals("state", stateful.getState());
      stateful.testSerializedState("state");
      stateful.clearPassivated();
      assertEquals(null, stateful.getInterceptorState());
      stateful.setInterceptorState("hello world");
      assertFalse(stateful.testSessionContext());
      Thread.sleep(10 * 1000);
     
      int cacheSize = (Integer)server.getAttribute(testerName, "CacheSize");
      assertEquals(0, cacheSize);
     
      int passivatedCount = (Integer)server.getAttribute(testerName, "PassivatedCount");
      assertEquals(1, passivatedCount - prevCount);
      assertTrue(stateful.wasPassivated());
     
      totalSize = (Integer)server.getAttribute(testerName, "TotalSize");
      assertEquals(cacheSize + passivatedCount, totalSize);
     
      assertEquals("state", stateful.getState());
      assertEquals("hello world", stateful.getInterceptorState());
     
      passivatedCount = (Integer)server.getAttribute(testerName, "PassivatedCount");
      assertEquals(0, passivatedCount - prevCount);

      Stateful another = (Stateful)getInitialContext().lookup(jndiBinding);
      assertEquals(null, another.getInterceptorState());
      another.setInterceptorState("foo");
      assertEquals("foo", another.getInterceptorState());
      assertEquals("hello world", stateful.getInterceptorState());
     
      assertFalse(stateful.testSessionContext());
     
      stateful.testResources();
     
      createCount = (Integer)server.getAttribute(testerName, "CreateCount");
      assertEquals(2, createCount - prevCount);
     
      // the injected beans are passivated at this point in time
     
      cacheSize = (Integer)server.getAttribute(testerName, "CacheSize");
      assertEquals(2, cacheSize);
     
      // keep in mind, we're not removing already injected beans
     
      int removeCount = (Integer)server.getAttribute(testerName, "RemoveCount");
      assertEquals(0, removeCount);
     
      another.removeMe();
      cacheSize = (Integer)server.getAttribute(testerName, "CacheSize");
      assertEquals(1, cacheSize);
     
      removeCount = (Integer)server.getAttribute(testerName, "RemoveCount");
      assertEquals(1, removeCount);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.