FileDocCategorySizeDatePackage
Tester.javaAPI DocJBoss 4.2.14058Fri Jul 13 20:52:58 BST 2007org.jboss.ejb3.test.cache

Tester

public class Tester extends org.jboss.system.ServiceMBeanSupport implements TesterMBean
Comment
author
Bill Burke
version
$Revision: 60233 $

Fields Summary
Constructors Summary
Methods Summary
public voidtest()

      ObjectName cacheON = new ObjectName("jboss.cache:service=EJB3TreeCache");
      TreeCacheMBean mbean = (TreeCacheMBean) MBeanProxy.get(TreeCacheMBean.class, cacheON, server);
      TreeCache cache = (TreeCache) mbean.getInstance();
//      PassivationEvictionPolicy policy = (PassivationEvictionPolicy) cache.getEvictionPolicy();
//      policy.createRegion("/mySFSB", 100, 1L);

      cache.put("/mySFSB/1234", "hello", "world");
      System.out.println("After PUT");
      Thread.sleep(5000);

      System.out.println("WAKE UP!");
      File fp = new File(System.getProperty(ServerConfig.SERVER_TEMP_DIR) + "/stateful/mySFSB." + FileCacheLoader.DIR_SUFFIX + "/1234." + FileCacheLoader.DIR_SUFFIX);
      System.out.println("exists in DB: " + fp.exists());
      if (!fp.exists()) throw new RuntimeException("No passivation happened.");
      System.out.println(cache.get("/mySFSB/1234", "hello"));
      System.out.println("exists in DB: " + fp.exists());
      if (fp.exists()) throw new RuntimeException("Should have been removed on activation.");
      if (cache.exists("/mySFSB/1234"))
      {
         cache.remove("/mySFSB/1234");
//         synchronized (policy)
//         {
//            policy.removeRegion("/mySFSB");
//         }
         cache.remove("/mySFSB");
      }
   
public voidtestSimpleLocal()

      SimpleStatefulLocal local = (SimpleStatefulLocal) new InitialContext().lookup("SimpleStatefulBean/local");
      local.reset();
      local.setState("hello");
      local.longRunning();
      if (!"hello".equals(local.getState())) throw new RuntimeException("failed state");
      if (!local.getPostActivate()) throw new RuntimeException("failed to postActivate");
      if (!local.getPrePassivate()) throw new RuntimeException("failed to prePassivate");

   
public voidtestSimpleRemote()

      SimpleStatefulRemote remote = (SimpleStatefulRemote) new InitialContext().lookup("SimpleStatefulBean/remote");
      remote.reset();
      remote.setState("hello");
      remote.longRunning();
      if (!"hello".equals(remote.getState())) throw new RuntimeException("failed state");
      if (!remote.getPostActivate()) throw new RuntimeException("failed to postActivate");
      if (!remote.getPrePassivate()) throw new RuntimeException("failed to prePassivate");