[jboss-cvs] JBossAS SVN: r108509 - in branches/infinispan-int/testsuite/src: main/org/jboss/ejb3/test/common and 20 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 11 11:27:07 EDT 2010


Author: smarlow at redhat.com
Date: 2010-10-11 11:27:05 -0400 (Mon, 11 Oct 2010)
New Revision: 108509

Added:
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/common/
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/common/unit/
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/common/unit/DBSetup.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/AnnotatedAppException.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/CheckedApplicationException.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStateful.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStateful.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Entity.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacade.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacadeBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ExtendedState.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/MyInterceptor.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ProxyFactoryInterface.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteBindingInterceptor.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteTx.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTest.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTestBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceRemote.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStateful.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/State.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful21.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulClusteredTimeoutBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulHome.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulInvoker.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulLocal.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncLocal.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeout.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeoutBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTx.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTxBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateless.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatelessBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Tester.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TesterBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheRemovalStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/Removable.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/BogusPolicy.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessRemote.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessSessionBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/IgnoreReplicationStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NodeAnswer.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NonAnnotationStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OptimizedStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideAnnotationStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulRemote.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulRemote.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTester.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterBase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatelessBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/ClusteredDeepNestedStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredLocalNestedStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredParentStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredRemoteNestedStatefulBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredDeepNestedContainedBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredLocalContainedBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredRemoteContainedBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredShoppingCartBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/BeanUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ExtendedPersistenceUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ForeignPartitionLocalInterceptorUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/InvokeLocalTestBase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/NestedBeanUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/PassivationUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ProxyTargetsUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/RedeployUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ScopedExtendedPersistenceUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/SimpleIsLocalInterceptorUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatefulProxyFactoryLoadBalancingTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatelessUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/util/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/util/ExplicitFailoverInterceptor.java
   branches/infinispan-int/testsuite/src/resources/cluster/ejb3/
   branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/
   branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/islocal/
Log:
copy ejb3 cluster unit tests into as-6, first pass at clustered session beans

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/common/unit/DBSetup.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/common/unit/DBSetup.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/common/unit/DBSetup.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.common.unit;
+
+import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+/** A TestSetup that starts hypersonic before the testcase with a tcp
+ * listening port at 1701.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revison:$
+ */
+public class DBSetup extends TestSetup
+{
+   private static final String HYPERSONIC_DIR = "output/hypersonic";
+   private static final String DB_NAME = "clusteredentity-db";
+   private final boolean deleteInTearDown;
+   
+   public DBSetup(Test test)
+   {
+      this(test, true);
+   }
+   
+   public DBSetup(Test test, boolean deleteInTearDown)
+   {
+      super(test);
+      this.deleteInTearDown = deleteInTearDown;
+   }
+
+   protected void setUp() throws Exception
+   {
+         File hypersoniDir = new File(HYPERSONIC_DIR);
+         if (!hypersoniDir.exists())
+         {
+            hypersoniDir.mkdirs();
+         }
+
+         if (!hypersoniDir.isDirectory())
+         {
+            throw new IOException("Failed to create directory: " + hypersoniDir);
+         }
+      
+         File dbPath = new File(hypersoniDir, DB_NAME);
+
+         // Start DB in new thread, or else it will block us
+         DBThread serverThread = new DBThread(dbPath);
+         serverThread.start();
+         
+         int elapsed = 0;
+         while (!serverThread.isStarted() && elapsed < 15000)
+         {
+            try 
+            {
+               Thread.sleep(100);
+               elapsed += 100;
+            }
+            catch (InterruptedException ie)
+            {
+               System.out.println("Interrupted while waiting for Hypersonic");
+            }
+         }
+         
+         if (!serverThread.isStarted())
+            System.out.println("Hypersonic failed to start in a timely fashion");
+   }
+
+   protected void tearDown() throws Exception
+   {
+      Class.forName("org.hsqldb.jdbcDriver");
+      String dbURL = "jdbc:hsqldb:hsql://" + System.getProperty("jbosstest.server.host", "localhost") + ":1701";
+      Connection conn = DriverManager.getConnection(dbURL, "sa", "");
+      Statement statement = conn.createStatement();      
+      statement.executeQuery("SHUTDOWN COMPACT");
+      
+      if (deleteInTearDown)
+      {
+         File hypersonicDir = new File(HYPERSONIC_DIR);
+         if (hypersonicDir.exists() && hypersonicDir.isDirectory())
+         {
+            FileFilter filter = new FileFilter() {
+               public boolean accept(File file) 
+               {
+                  return file.getName().indexOf(DB_NAME) >= 0;
+               }
+            };
+            
+            File[] dbFiles = hypersonicDir.listFiles(filter);
+            for (File file : dbFiles)
+            {
+               file.delete();
+            }
+         }
+      }
+      
+   }
+
+   public static void main(String[] args) throws Exception
+   {
+      DBSetup setup = new DBSetup(null);
+      setup.setUp();
+      Thread.sleep(120*1000);
+      setup.tearDown();
+   }
+   
+   class DBThread extends Thread
+   {
+      boolean started;
+      File dbPath;
+      
+      DBThread(File dbPath)
+      {
+         super("hypersonic");
+         this.dbPath = dbPath;
+      }
+      
+      boolean isStarted()
+      {
+         return started;
+      }
+      
+      public void run()
+      {
+         try
+         {
+            // Create startup arguments
+            // BES 2007/09/25 We use -silent true to avoid 
+            // http://sourceforge.net/tracker/index.php?func=detail&aid=1673747&group_id=23316&atid=378131
+            String[] args = {
+                  "-database",
+                  dbPath.toString(),
+                  "-port",
+                  String.valueOf(1701),
+                  "-silent",
+                  "true",
+                  "-trace",
+                  "false",
+                  "-no_system_exit",
+                  "true",
+             };
+            System.out.println("Starting hsqldb");
+            // HACK Do this by reflection for now until we determine how 
+            // we want to handle this in EJB3
+            Class clazz = Thread.currentThread().getContextClassLoader().loadClass("org.hsqldb.Server");
+            Method main = clazz.getDeclaredMethod("main", new Class[] { String[].class });
+            main.invoke(null, new Object[] { args });
+//            org.hsqldb.Server.main(args);
+            System.out.println("Done");
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+         }
+         finally
+         {
+            started = true;
+         }
+      }
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/common/unit/DBSetup.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/AnnotatedAppException.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/AnnotatedAppException.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/AnnotatedAppException.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.ApplicationException;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at ApplicationException
+public class AnnotatedAppException extends RuntimeException
+{
+   public AnnotatedAppException()
+   {
+      super();
+   }
+
+   public AnnotatedAppException(String s)
+   {
+      super(s);
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/AnnotatedAppException.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/CheckedApplicationException.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/CheckedApplicationException.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/CheckedApplicationException.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class CheckedApplicationException extends RuntimeException
+{
+   public CheckedApplicationException()
+   {
+      super();
+   }
+
+   public CheckedApplicationException(String s)
+   {
+      super(s);
+   }
+}
\ No newline at end of file


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/CheckedApplicationException.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStateful.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStateful.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStateful.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,45 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface ClusteredStateful extends ConcurrentStateful
+{
+   boolean interceptorAccessed();
+
+   boolean testSessionContext();
+   
+   boolean wasPassivated();
+   String getInterceptorState();
+   void setInterceptorState(String param);
+   
+   void testThrownException() throws Exception;
+   
+   void testExceptionCause() throws Exception;
+   void testSerializedState(String state);
+   
+   void removeBean();
+   
+   void testResources() throws Exception;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStateful.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,208 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+import org.jboss.logging.Logger;
+import org.jboss.serial.io.JBossObjectInputStream;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful(name="ClusteredStatefulBean")
+ at Remote(org.jboss.ejb3.test.stateful.ClusteredStateful.class)
+ at Local(org.jboss.ejb3.test.stateful.StatefulLocal.class)
+ at RemoteBinding(jndiBinding = "ClusteredStateful",
+               interceptorStack="RemoteBindingStatefulSessionClientInterceptors",
+               factory = RemoteBindingDefaults.PROXY_FACTORY_STATEFUL_REMOTE)
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1, name="jboss.cache:service=EJB3SFSBClusteredCache")
+ at SecurityDomain("test")
+ at Resources({@Resource(name="jdbc/ds", mappedName="java:/DefaultDS")})
+ at Clustered
+public class ClusteredStatefulBean implements ClusteredStateful
+{
+   private static final Logger log = Logger.getLogger(ClusteredStatefulBean.class);
+   
+   @Resource
+   private SessionContext sessionContext;
+   
+//   @Resource(mappedName="java:/DefaultDS")
+//   private transient javax.sql.DataSource datasource;
+   
+//   @Resource(mappedName="java:/ConnectionFactory")
+//   public transient javax.jms.QueueConnectionFactory connectionFactory; 
+
+   private String state;
+   private int stuff;
+   private boolean wasPassivated = false;
+
+   @Interceptors(MyInterceptor.class)
+   public String getInterceptorState()
+   {
+      throw new RuntimeException("NOT REACHABLE");
+   }
+
+   @Interceptors(MyInterceptor.class)
+   public void setInterceptorState(String param)
+   {
+      throw new RuntimeException("NOT REACHABLE");
+   }
+   
+   public boolean testSessionContext()
+   {
+      return sessionContext.isCallerInRole("role");
+   }
+   
+   public void testResources() throws Exception
+   {
+//      datasource.toString();
+//      connectionFactory.toString();
+      
+      javax.sql.DataSource ds = (javax.sql.DataSource)new InitialContext().lookup(Container.ENC_CTX_NAME + "/env/jdbc/ds");
+      ds.toString();
+   }
+
+   public String getState() throws Exception
+   {
+      Thread.sleep(1000);
+      return state;
+   }
+
+   public void setState(String state) throws Exception
+   {
+      Thread.sleep(1000);
+      this.state = state;
+   }
+
+   public boolean interceptorAccessed()
+   {
+      return RemoteBindingInterceptor.accessed;
+   }
+
+   public void testThrownException() throws Exception
+   {
+      throw new Exception();
+   }
+
+   public void testExceptionCause() throws Exception
+   {
+      Object o = null;
+      o.toString();
+   }
+
+   @PrePassivate
+   public void passivate()
+   {
+      log.info("************ passivating " + this);  
+      wasPassivated = true;
+   }
+   
+   @PostActivate
+   public void activate()
+   {
+      log.info("************ activating");
+   }
+
+   public void testSerializedState(String state)
+   {
+      this.state = state;
+
+      ClusteredStatefulBean bean = null;
+      try
+      {
+         ObjectOutputStream out;
+
+         ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+         out = new JBossObjectOutputStream(baos, false);
+         out.writeObject(this);
+         out.flush();
+
+         ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+
+         JBossObjectInputStream is = new JBossObjectInputStream(bais);
+         bean = (ClusteredStatefulBean)is.readObject();
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+
+      if (!state.equals(bean.state)) throw new RuntimeException("failed to serialize: " + bean.state);
+   }
+
+   public boolean wasPassivated()
+   {
+	  log.info("************ wasPassivated " + wasPassivated + " " + this);  
+      return wasPassivated;
+   }
+
+   @Init
+   public void ejbCreate(Integer state)
+   {
+      this.state=state.toString();
+   }
+
+   @Init
+   public void ejbCreate(State state)
+   {
+      this.state=state.getState();
+   }
+
+   @Init
+   public void ejbCreate(String state)
+   {
+      this.state=state;
+   }
+   
+   public void removeBean()
+   {
+      
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStateful.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStateful.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStateful.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public interface ConcurrentStateful
+{
+   String getState() throws Exception;
+
+   void setState(String state) throws Exception;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStateful.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.SerializedConcurrentAccess;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+ at Stateful
+ at Remote(ConcurrentStateful.class)
+ at SerializedConcurrentAccess
+public class ConcurrentStatefulBean implements ConcurrentStateful
+{
+   private static final Logger log = Logger.getLogger(ConcurrentStatefulBean.class);
+
+   private String state;
+
+   public String getState() throws Exception
+   {
+      Thread.sleep(1000);
+      return state;
+   }
+
+   public void setState(String state) throws Exception
+   {
+      this.state = state;
+      Thread.sleep(1000);
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ConcurrentStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Entity.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Entity.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Entity.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,60 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at javax.persistence.Entity
+ at Table(name = "ENTITY")
+public class Entity implements java.io.Serializable
+{
+   private Long id;
+   private String name;
+  
+
+   @Id
+   @GeneratedValue(strategy= GenerationType.IDENTITY)
+   public Long getId()
+   {
+      return id;
+   }
+
+   public void setId(Long id)
+   {
+      this.id = id;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Entity.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacade.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacade.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacade.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,43 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface EntityFacade
+{
+   public static enum REMOVE_EXCEPTION_TYPE
+   {
+      NONE, CHECKED, APPLICATION, RUNTIME,
+   }
+   
+   Entity createEntity(String name);
+   
+   Entity loadEntity(Long id);
+   
+   void remove();
+   
+   void removeWithTx();
+   
+   void setThrowRemoveException(REMOVE_EXCEPTION_TYPE throwDestroyException);
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacade.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacadeBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacadeBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacadeBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,123 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.logging.Logger;
+
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(EntityFacade.class)
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+ at TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+public class EntityFacadeBean implements EntityFacade
+{
+   private @PersistenceContext(type = PersistenceContextType.EXTENDED)
+   EntityManager manager;
+   
+   private static final Logger log = Logger.getLogger(EntityFacadeBean.class);
+  
+   private static REMOVE_EXCEPTION_TYPE throwRemoveException = REMOVE_EXCEPTION_TYPE.NONE;
+   
+   public Entity createEntity(String name) {
+      log.info("********* createEntity " + name);
+      Entity entity = new Entity();
+      entity.setName(name);
+	   manager.persist(entity);
+	   return entity;
+   }
+   
+   public void setThrowRemoveException(REMOVE_EXCEPTION_TYPE throwRemoveException)
+   {
+      this.throwRemoveException = throwRemoveException;
+   }
+   
+   public Entity loadEntity(Long id) {
+      log.info("********* loadEntity " + id);
+      Entity entity =  manager.find(Entity.class, id);
+	   return entity;
+   }
+   
+   @PrePassivate
+   public void passivate()
+   {
+      log.info("************ passivating");  
+   }
+   
+   @PostActivate
+   public void activate()
+   {
+      log.info("************ activating");
+   }
+   
+   @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+   @Remove(retainIfException=true)
+   public void remove() throws CheckedApplicationException
+   {
+      log.info("************ removing no tx");
+      
+      if (throwRemoveException == REMOVE_EXCEPTION_TYPE.APPLICATION)
+         throw new AnnotatedAppException("From @Remove");
+      
+      if (throwRemoveException == REMOVE_EXCEPTION_TYPE.CHECKED)
+         throw new CheckedApplicationException("From @Remove");
+      
+      if (throwRemoveException == REMOVE_EXCEPTION_TYPE.RUNTIME)
+         throw new RuntimeException("From @Remove");
+   }
+   
+   @Remove(retainIfException=true)
+   public void removeWithTx()
+   {
+      log.info("************ removing with tx");
+      
+      if (throwRemoveException == REMOVE_EXCEPTION_TYPE.APPLICATION)
+         throw new AnnotatedAppException("From @Remove");
+      
+      if (throwRemoveException == REMOVE_EXCEPTION_TYPE.CHECKED)
+         throw new CheckedApplicationException("From @Remove");
+      
+      if (throwRemoveException == REMOVE_EXCEPTION_TYPE.RUNTIME)
+         throw new RuntimeException("From @Remove");
+   }
+   
+   @PreDestroy
+   public void destroy()
+   {
+      log.info("************ destroying "); 
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/EntityFacadeBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ExtendedState.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ExtendedState.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ExtendedState.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public class ExtendedState extends State
+{
+   public ExtendedState(String state)
+   {
+      super("Extended_" + state);
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ExtendedState.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/MyInterceptor.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/MyInterceptor.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/MyInterceptor.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class MyInterceptor
+{
+   Object field;
+
+   @AroundInvoke
+   public Object invoke(InvocationContext ctx) throws Exception
+   {
+      if (ctx.getMethod().getName().startsWith("set"))
+      {
+         field = ctx.getParameters()[0];
+         return null;
+      }
+      return field;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/MyInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ProxyFactoryInterface.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ProxyFactoryInterface.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ProxyFactoryInterface.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public interface ProxyFactoryInterface
+{
+   String method();
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ProxyFactoryInterface.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteBindingInterceptor.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteBindingInterceptor.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteBindingInterceptor.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public class RemoteBindingInterceptor implements Interceptor, java.io.Serializable
+{
+   private static final Logger log = Logger.getLogger(RemoteBindingInterceptor.class);
+   
+   public static boolean accessed = false;
+   
+   public RemoteBindingInterceptor()
+   {
+   }
+
+   public String getName()
+   {
+      return "RemoteBindingInterceptor";
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      try 
+      {
+         return invocation.invokeNext();
+      } 
+      finally
+      {
+         accessed = true;
+      }
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteBindingInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteTx.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteTx.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteTx.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,34 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface RemoteTx<T>
+{
+   T testMandatoryTx(T t);
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoteTx.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTest.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTest.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTest.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.Remove;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public interface RemoveTest
+{
+   @Remove
+   void callRollbackOnly();
+
+   @Remove
+   void removeit();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTestBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTestBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTestBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.Stateful;
+import javax.ejb.Remove;
+import javax.ejb.SessionContext;
+import javax.annotation.Resource;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+ at Stateful
+public class RemoveTestBean implements RemoveTest
+{
+   @Resource SessionContext ctx;
+
+   @Remove
+   public void callRollbackOnly()
+   {
+      ctx.setRollbackOnly();
+   }
+
+   @Remove
+   public void removeit()
+   {
+      ctx.setRollbackOnly();
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/RemoveTestBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,53 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.ejb3.annotation.Service;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Service
+ at Remote(ServiceRemote.class)
+ at SecurityDomain("other")
+public class ServiceBean implements ServiceRemote
+{
+	private static final Logger log = Logger.getLogger(ServiceBean.class);
+	
+	@EJB(beanName="StatefulBean")
+	private Stateful stateful;
+	
+	@EJB
+	private ClusteredStateful clusteredStateful;
+	   
+	public void testInjection() throws Exception
+	{
+		stateful.getState();
+		
+		clusteredStateful.getState();
+	}
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceRemote.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceRemote.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceRemote.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,30 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface ServiceRemote
+{
+   void testInjection() throws Exception;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/ServiceRemote.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStateful.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStateful.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStateful.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,12 @@
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.Remote;
+
+ at Remote
+public interface SmallCacheStateful
+{
+   public void setId(int id);
+
+   public int doit(int id);
+
+}
\ No newline at end of file


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStateful.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+
+/**
+ * Test small maxSize for cache
+ *
+ * @author <a href="mailto:bill at jboss.com">Bill Burke</a>
+ * @version $Revision$
+ */
+ at Stateful
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+public class SmallCacheStatefulBean implements SmallCacheStateful
+{
+   private int count;
+   private int id;
+   
+   
+   public void setId(int id)
+   {
+      this.id = id;
+   }
+
+
+   public int doit(int passedId) 
+   {
+      if (passedId != id) throw new RuntimeException();
+      try
+      {
+         Thread.sleep(3000);
+      }
+      catch (InterruptedException e)
+      {
+         
+      }
+      return count++;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/SmallCacheStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/State.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/State.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/State.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public class State implements java.io.Serializable
+{
+   protected String state;
+
+   public State(String state)
+   {
+      this.state = state;
+   }
+   
+   public String getState()
+   {
+      return state;
+   }
+
+   public void setState(String state)
+   {
+      this.state = state;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/State.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public interface Stateful extends ConcurrentStateful
+{
+   boolean interceptorAccessed();
+
+   boolean testSessionContext();
+   
+   public boolean wasPassivated();
+   public void clearPassivated();
+   public String getInterceptorState();
+   public void setInterceptorState(String param);
+   
+   public void testThrownException() throws Exception;
+   
+   public void testExceptionCause() throws Exception;
+   public void testSerializedState(String state);
+   
+   public void removeMe();
+   public int beansRemoved();
+   
+   void testResources() throws Exception;
+   
+   void lookupStateful() throws Exception;
+   void testStateful() throws Exception;
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful21.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful21.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful21.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.EJBObject;
+
+/**
+ * A remote interface for a stateful bean.
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public interface Stateful21 extends Stateful, EJBObject
+{
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateful21.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,236 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+import org.jboss.logging.Logger;
+import org.jboss.serial.io.JBossObjectInputStream;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+ at Stateful(name="StatefulBean")
+ at Remote({org.jboss.ejb3.test.stateful.Stateful.class})
+ at Local(org.jboss.ejb3.test.stateful.StatefulLocal.class)
+ at RemoteBinding(jndiBinding = "Stateful",
+               interceptorStack="RemoteBindingStatefulSessionClientInterceptors",
+               factory = RemoteBindingDefaults.PROXY_FACTORY_STATEFUL_REMOTE)
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 5)
+ at SecurityDomain("test")
+ at Resources({@Resource(name="jdbc/ds", mappedName="java:/DefaultDS")})
+public class StatefulBean implements org.jboss.ejb3.test.stateful.Stateful
+{
+   private static final Logger log = Logger.getLogger(StatefulBean.class);
+   
+   private static int beansRemoved = 0;
+   
+   @Resource
+   private SessionContext sessionContext;
+   
+   @Resource(mappedName="java:/DefaultDS")
+   private transient javax.sql.DataSource datasource;
+   
+   @Resource(mappedName="java:/ConnectionFactory")
+   public transient javax.jms.QueueConnectionFactory connectionFactory; 
+   
+   private StatefulLocal localStateful;
+
+   private String state;
+   private boolean wasPassivated = false;
+   
+   public void lookupStateful() throws Exception
+   {
+      localStateful = (StatefulLocal)new InitialContext().lookup("StatefulBean/local");
+      log.info("lookup localStateful " + localStateful);
+   }
+   
+   public void testStateful() throws Exception
+   {
+      log.info("get state of localStateful " + localStateful);
+      localStateful.getState();
+   }
+
+   @Interceptors(MyInterceptor.class)
+   public String getInterceptorState()
+   {
+      throw new RuntimeException("NOT REACHABLE");
+   }
+
+   @Interceptors(MyInterceptor.class)
+   public void setInterceptorState(String param)
+   {
+      throw new RuntimeException("NOT REACHABLE");
+   }
+   
+   public boolean testSessionContext()
+   {
+      return sessionContext.isCallerInRole("role");
+   }
+   
+   public void testResources() throws Exception
+   {
+      if(datasource == null)
+         throw new IllegalStateException("transient property datasource was not injected");
+      if(connectionFactory == null)
+         throw new IllegalStateException("transient property connectionFactory was not injected");
+      
+      javax.sql.DataSource ds = (javax.sql.DataSource)new InitialContext().lookup(Container.ENC_CTX_NAME + "/env/jdbc/ds");
+      ds.toString();
+   }
+
+   public String getState() throws Exception
+   {
+      Thread.sleep(1000);
+      return state;
+   }
+
+   public void setState(String state) throws Exception
+   {
+      Thread.sleep(1000);
+      this.state = state;
+   }
+
+   public boolean interceptorAccessed()
+   {
+      return RemoteBindingInterceptor.accessed;
+   }
+
+   public void testThrownException() throws Exception
+   {
+      throw new Exception();
+   }
+
+   public void testExceptionCause() throws Exception
+   {
+      Object o = null;
+      o.toString();
+   }
+
+   @PrePassivate
+   public void passivate()
+   {
+      log.info("************ passivating");  
+      wasPassivated = true;
+   }
+   
+   @PostActivate
+   public void activate()
+   {
+      log.info("************ activating");
+   }
+
+   public void testSerializedState(String state)
+   {
+      this.state = state;
+
+      StatefulBean bean = null;
+      try
+      {
+         ObjectOutputStream out;
+
+         ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+         out = new JBossObjectOutputStream(baos, false);
+         out.writeObject(this);
+         out.flush();
+
+         ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+
+         JBossObjectInputStream is = new JBossObjectInputStream(bais);
+         bean = (StatefulBean)is.readObject();
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+
+      if (!state.equals(bean.state)) throw new RuntimeException("failed to serialize: " + bean.state);
+   }
+
+   public boolean wasPassivated()
+   {
+      return wasPassivated;
+   }
+
+   public void clearPassivated()
+   {
+      wasPassivated = false;
+   }
+   
+   @Init
+   public void ejbCreate(Integer state)
+   {
+      this.state=state.toString();
+   }
+
+   @Init
+   public void ejbCreate(State state)
+   {
+      this.state=state.getState();
+   }
+
+   @Init
+   public void ejbCreate(String state)
+   {
+      this.state=state;
+   }
+   
+   public int beansRemoved()
+   {
+      return beansRemoved;
+   }
+   
+   // @Remove from xml
+   public void removeMe()
+   {
+      ++beansRemoved;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulClusteredTimeoutBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulClusteredTimeoutBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulClusteredTimeoutBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(StatefulTimeout.class)
+ at CacheConfig(removalTimeoutSeconds = 1)
+ at Clustered
+public class StatefulClusteredTimeoutBean implements StatefulTimeout
+{
+   private static final Logger log = Logger.getLogger(StatefulClusteredTimeoutBean.class);
+   
+   public void test() 
+   {
+   }
+   
+   @Remove
+   public void remove()
+   {
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulClusteredTimeoutBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulHome.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulHome.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulHome.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.EJBHome;
+
+/**
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulHome extends EJBHome {
+    
+  public Stateful21 create() throws java.rmi.RemoteException, javax.ejb.CreateException;
+  
+  public Stateful21 create(State state) throws java.rmi.RemoteException, javax.ejb.CreateException;
+} 
+


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulHome.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulInvoker.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulInvoker.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulInvoker.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public class StatefulInvoker extends Thread
+{
+   private static final Logger log = Logger.getLogger(StatefulInvoker.class);
+   
+   Exception exception = null;
+   
+   ConcurrentStateful stateful;
+   
+   public StatefulInvoker(ConcurrentStateful stateful)
+   {
+      this.stateful = stateful;
+   }
+   
+   public Exception getException()
+   {
+      return exception;
+   }
+   
+   public void run()
+   {
+      try
+      {
+         stateful.setState("state");
+         stateful.getState();
+      }
+      catch(Exception e)
+      {
+         exception = e;
+      }
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulInvoker.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulLocal.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulLocal.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulLocal.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public interface StatefulLocal
+{
+   String getState();
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulLocal.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import org.jboss.aop.Advisor;
+import org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionRemoteProxyFactory;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public class StatefulRemoteProxyFactory extends StatefulSessionRemoteProxyFactory
+{
+   @SuppressWarnings("unused")
+   private static final Logger log = Logger.getLogger(StatefulRemoteProxyFactory.class);
+
+   public StatefulRemoteProxyFactory(final String name, final String containerName, final String containerGuid,
+         final JBossSessionBeanMetaData metadata, final ClassLoader classloader, final String url,
+         final Advisor advisor, final String interceptorStackName)
+   {
+      super(name, containerName, containerGuid, metadata, classloader, url, advisor, interceptorStackName);
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionSynchronization;
+import javax.ejb.Stateful;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+ at Stateful
+public class StatefulSyncBean implements SessionSynchronization, StatefulSyncLocal, java.io.Serializable
+{
+   private String state;
+   private String rollbackState;
+   private boolean beforeCalled;
+
+   public boolean isBeforeCalled()
+   {
+      return beforeCalled;
+   }
+
+   public void setBeforeCalled(boolean beforeCalled)
+   {
+      this.beforeCalled = beforeCalled;
+   }
+
+   public String getState()
+   {
+      return state;
+   }
+
+   public void setState(String state)
+   {
+      this.state = state;
+   }
+
+
+   public void afterBegin() throws EJBException, RemoteException
+   {
+      rollbackState = state;
+   }
+
+   public void beforeCompletion() throws EJBException, RemoteException
+   {
+      beforeCalled = true;
+   }
+
+   public void afterCompletion(boolean committed) throws EJBException, RemoteException
+   {
+      if (!committed) state = rollbackState;  
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncLocal.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncLocal.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncLocal.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public interface StatefulSyncLocal
+{
+   boolean isBeforeCalled();
+
+   void setBeforeCalled(boolean beforeCalled);
+
+   String getState();
+
+   void setState(String state);
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulSyncLocal.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeout.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeout.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeout.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulTimeout
+{
+   void test();
+   
+   void remove();
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeout.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeoutBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeoutBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeoutBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(StatefulTimeout.class)
+ at CacheConfig(removalTimeoutSeconds = 1)
+public class StatefulTimeoutBean implements StatefulTimeout
+{
+   private static final Logger log = Logger.getLogger(StatefulTimeoutBean.class);
+   
+   public void test() 
+   {
+   }
+   
+   @Remove
+   public void remove()
+   {
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTimeoutBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTx.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTx.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTx.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+public interface StatefulTx extends RemoteTx<State>
+{
+   boolean isGlobalTransacted() throws javax.transaction.SystemException;
+   
+   boolean isLocalTransacted() throws javax.transaction.SystemException;
+   
+   boolean testNewTx() throws javax.transaction.SystemException;
+   
+   void testTxRollback();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTx.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTxBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTxBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTxBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.annotation.JndiInject;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision$
+ */
+ at Stateful
+ at Remote(StatefulTx.class)
+ at TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) 
+ at SecurityDomain("test")
+public class StatefulTxBean implements StatefulTx
+{
+  private static final Logger log = Logger.getLogger(StatefulTxBean.class);
+   
+   @JndiInject(jndiName="java:/TransactionManager") private TransactionManager tm;
+    
+   @RolesAllowed("allowed")
+   public boolean isGlobalTransacted() throws javax.transaction.SystemException
+   {
+      return (tm.getTransaction() != null);
+   }
+   
+   @TransactionAttribute(TransactionAttributeType.REQUIRED)
+   @RolesAllowed("allowed")
+   public boolean isLocalTransacted() throws javax.transaction.SystemException
+   {
+      return (tm.getTransaction() != null);
+   }
+   
+   @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+   @RolesAllowed("allowed")
+   public boolean testNewTx() throws javax.transaction.SystemException
+   {
+      return (tm.getTransaction() != null);
+   }
+   
+   @TransactionAttribute(TransactionAttributeType.REQUIRED)
+   @RolesAllowed("allowed")
+   public void testTxRollback()
+   {
+      throw new RuntimeException("test rollback");
+   }
+   
+   @TransactionAttribute(value = TransactionAttributeType.MANDATORY)
+   @RolesAllowed("allowed")
+   public State testMandatoryTx(State o)
+   {
+      return o;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatefulTxBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateless.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateless.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateless.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,30 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface Stateless
+{
+   void testInjection() throws Exception;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Stateless.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatelessBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatelessBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatelessBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,55 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless(name="StatelessBean")
+ at RemoteBinding(jndiBinding = "Stateless")
+ at Remote(org.jboss.ejb3.test.stateful.Stateless.class)
+ at SecurityDomain("test")
+public class StatelessBean implements org.jboss.ejb3.test.stateful.Stateless
+{
+	private static final Logger log = Logger.getLogger(StatelessBean.class);
+   
+	@EJB(beanName="StatefulBean")
+	private Stateful stateful;
+	
+	@EJB
+	private ClusteredStateful clusteredStateful;
+	   
+	public void testInjection() throws Exception
+	{
+		stateful.getState();
+	   
+		clusteredStateful.getState();
+	}
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/StatelessBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Tester.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Tester.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Tester.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public interface Tester
+{
+   void testSessionSynchronization() throws Exception;
+
+   void testRollback1() throws Exception;
+
+   void testRollback2() throws Exception;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/Tester.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TesterBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TesterBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TesterBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.naming.InitialContext;
+import javax.transaction.UserTransaction;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+ at Stateless()
+ at TransactionManagement(TransactionManagementType.BEAN)
+ at Remote(Tester.class)
+public class TesterBean implements Tester
+{
+   @Resource private UserTransaction ut;
+
+   public void testSessionSynchronization() throws Exception
+   {
+      StatefulSyncLocal sfsb = (StatefulSyncLocal)new InitialContext().lookup("StatefulSyncBean/local");
+      sfsb.setState("hello");
+      sfsb.setBeforeCalled(false);
+
+      ut.begin();
+      sfsb.setState("world");
+      ut.rollback();
+
+      if (!sfsb.getState().equals("hello")) throw new RuntimeException("rollback didn't work");
+      if (!sfsb.isBeforeCalled()) throw new RuntimeException("BEFORE WAS NOT CALLED");
+
+      // test new proxy
+
+      sfsb = (StatefulSyncLocal)new InitialContext().lookup("StatefulSyncBean/local");
+      if (sfsb.getState() != null) throw new RuntimeException("State should be null: " + sfsb.getState());
+   }
+
+   public void testRollback1() throws Exception
+   {
+      RemoveTest test = (RemoveTest)new InitialContext().lookup("RemoveTestBean/local");
+      ut.begin();
+      test.callRollbackOnly();
+      ut.rollback();
+   }
+   public void testRollback2() throws Exception
+   {
+      RemoveTest test = (RemoveTest)new InitialContext().lookup("RemoveTestBean/local");
+      ut.begin();
+      ut.setRollbackOnly();
+      test.removeit();
+      ut.rollback();
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TesterBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheRemovalStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheRemovalStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheRemovalStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.Cache;
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+
+/**
+ * Same as TreeCacheStatefulBean, but configures a removalTimeoutSeconds to
+ * validate metrics when a removal thread is used.
+ * 
+ * @author Brian Stansberry
+ */
+ at Stateful(name = "TreeCacheRemovalStatefulBean")
+ at Remote(org.jboss.ejb3.test.stateful.Stateful.class)
+ at Local(org.jboss.ejb3.test.stateful.StatefulLocal.class)
+ at RemoteBinding(jndiBinding = "TreeCacheRemovalStateful", interceptorStack = "RemoteBindingStatefulSessionClientInterceptors", factory = RemoteBindingDefaults.PROXY_FACTORY_STATEFUL_REMOTE)
+ at CacheConfig(name = "jboss.cache:service=EJB3SFSBClusteredCache", maxSize = 1000, idleTimeoutSeconds = 1, removalTimeoutSeconds = 20)
+ at SecurityDomain("test")
+ at Resources(
+{@Resource(name = "jdbc/ds", mappedName = "java:/DefaultDS")})
+ at Cache("StatefulTreeCache")
+public class TreeCacheRemovalStatefulBean extends TreeCacheStatefulBase
+{
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheRemovalStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,216 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import javax.annotation.Resource;
+import javax.ejb.Init;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remove;
+import javax.ejb.SessionContext;
+import javax.interceptor.Interceptors;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.Container;
+import org.jboss.logging.Logger;
+import org.jboss.serial.io.JBossObjectInputStream;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class TreeCacheStatefulBase implements org.jboss.ejb3.test.stateful.Stateful
+{
+   private static final Logger log = Logger.getLogger(TreeCacheStatefulBase.class);
+   
+   private static int beansRemoved = 0;
+
+   @Resource
+   private SessionContext sessionContext;
+
+   @Resource(mappedName = "java:/DefaultDS")
+   private transient javax.sql.DataSource datasource;
+
+   @Resource(mappedName = "java:/ConnectionFactory")
+   public transient javax.jms.QueueConnectionFactory connectionFactory;
+
+   private String state;
+
+   @Interceptors(MyInterceptor.class)
+   public String getInterceptorState()
+   {
+      throw new RuntimeException("NOT REACHABLE");
+   }
+
+   @Interceptors(MyInterceptor.class)
+   public void setInterceptorState(String param)
+   {
+      throw new RuntimeException("NOT REACHABLE");
+   }
+
+   public boolean testSessionContext()
+   {
+      return sessionContext.isCallerInRole("role");
+   }
+
+   public void testResources() throws Exception
+   {
+      datasource.toString();
+      connectionFactory.toString();
+
+      javax.sql.DataSource ds = (javax.sql.DataSource) new InitialContext().lookup(Container.ENC_CTX_NAME
+            + "/env/jdbc/ds");
+      ds.toString();
+   }
+
+   public String getState() throws Exception
+   {
+      Thread.sleep(1000);
+      return state;
+   }
+
+   public void setState(String state) throws Exception
+   {
+      Thread.sleep(1000);
+      this.state = state;
+   }
+
+   public boolean interceptorAccessed()
+   {
+      return RemoteBindingInterceptor.accessed;
+   }
+
+   public void testThrownException() throws Exception
+   {
+      throw new Exception();
+   }
+
+   public void testExceptionCause() throws Exception
+   {
+      Object o = null;
+      o.toString();
+   }
+
+   @PrePassivate
+   public void passivate()
+   {
+      log.info("************ passivating");
+      wasPassivated = true;
+   }
+
+   @PostActivate
+   public void activate()
+   {
+      log.info("************ activating");
+   }
+
+   private static boolean wasPassivated = false;
+
+   public void testSerializedState(String state)
+   {
+      this.state = state;
+
+      TreeCacheStatefulBase bean = null;
+      try
+      {
+         ObjectOutputStream out;
+
+         ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+         out = new JBossObjectOutputStream(baos, false);
+         out.writeObject(this);
+         out.flush();
+
+         ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+
+         JBossObjectInputStream is = new JBossObjectInputStream(bais);
+         bean = (TreeCacheStatefulBase) is.readObject();
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+
+      if (!state.equals(bean.state))
+         throw new RuntimeException("failed to serialize: " + bean.state);
+   }
+
+   public boolean wasPassivated()
+   {
+      return wasPassivated;
+   }
+
+   public void clearPassivated()
+   {
+      wasPassivated = false;
+   }
+
+   @Init
+   public void ejbCreate(Integer state)
+   {
+      this.state = state.toString();
+   }
+
+   @Init
+   public void ejbCreate(State state)
+   {
+      this.state = state.getState();
+   }
+
+   @Init
+   public void ejbCreate(String state)
+   {
+      this.state = state;
+   }
+
+   @Remove
+   public void removeMe()
+   {
+      ++beansRemoved;
+   }
+   
+   public int beansRemoved()
+   {
+      return beansRemoved;
+   }
+
+   public void lookupStateful() throws Exception
+   {
+      // FIXME: NYI
+      throw new RuntimeException("NYI");
+   }
+
+   public void testStateful() throws Exception
+   {
+      // FIXME: NYI
+      throw new RuntimeException("NYI");
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.annotation.Cache;
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+import org.jboss.logging.Logger;
+import org.jboss.serial.io.JBossObjectInputStream;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful(name = "TreeCacheStatefulBean")
+ at Remote(org.jboss.ejb3.test.stateful.Stateful.class)
+ at Local(org.jboss.ejb3.test.stateful.StatefulLocal.class)
+ at RemoteBinding(jndiBinding = "TreeCacheStateful", interceptorStack = "RemoteBindingStatefulSessionClientInterceptors", factory = RemoteBindingDefaults.PROXY_FACTORY_STATEFUL_REMOTE)
+ at CacheConfig(name = "jboss.cache:service=EJB3SFSBClusteredCache", maxSize = 1000, idleTimeoutSeconds = 1)
+ at SecurityDomain("test")
+ at Resources(
+{@Resource(name = "jdbc/ds", mappedName = "java:/DefaultDS")})
+ at Cache("StatefulTreeCache")
+public class TreeCacheStatefulBean extends TreeCacheStatefulBase
+{
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/TreeCacheStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.rmi.dgc.VMID;
+
+public interface BeanMonitor extends Removable
+{
+   VMID getVMID();
+   
+   void monitor(TopLevel topLevel);
+
+   String getDeepNestedId();
+
+   String getLocalDeepNestedId();
+
+   int getParentPassivations();
+
+   int getNestedPassivations();
+
+   int getLocalNestedPassivations();
+
+   int getDeepNestedPassivations();
+
+   int getLocalDeepNestedPassivations();
+
+   int getParentActivations();
+
+   int getNestedActivations();
+
+   int getLocalNestedActivations();
+
+   int getDeepNestedActivations();
+
+   int getLocalDeepNestedActivations();
+
+   boolean removeParent();
+
+   boolean removeNested();
+
+   boolean removeLocalNested();
+
+   boolean removeDeepNested();
+
+   boolean removeLocalDeepNested();
+
+}
\ No newline at end of file


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,305 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A BeanMonitorBean.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class BeanMonitorBean implements BeanMonitor
+{
+   protected Logger log = Logger.getLogger(getClass());
+   
+   protected TopLevel parent;
+   protected MidLevel nested;
+   protected MidLevel localNested;
+   protected DeepNestedStateful deepNested;
+   protected DeepNestedStateful localDeepNested;
+   
+   public VMID getVMID()
+   {
+      return VMTracker.VMID;
+   }
+
+   public void monitor(TopLevel topLevel)
+   {
+      this.parent = topLevel;
+      log.debug("parent is " + parent);
+      this.nested = parent.getNested();
+      log.debug("nested is " + nested);
+      this.localNested = parent.getLocalNested();
+      log.debug("localNested is " + localNested);
+      this.deepNested = nested.getDeepNestedStateful();
+      log.debug("deepNested is " + deepNested);
+      this.localDeepNested = localNested.getDeepNestedStateful();
+      log.debug("localDeepNested is " + localDeepNested);
+   }
+
+   public String getDeepNestedId()
+   {
+      try
+      {
+         return deepNested.getInternalId();
+      }
+      catch (Exception e)
+      {
+         log.warn("getDeepNestedId() " + e.getLocalizedMessage(), e);
+         return "ERROR";
+      }
+   }
+
+   public String getLocalDeepNestedId()
+   {
+      try
+      {
+         return localDeepNested.getInternalId();
+      }
+      catch (Exception e)
+      {
+         log.warn("getLocalDeepNestedId() " + e.getLocalizedMessage(), e);
+         return "ERROR";
+      }
+   }
+
+   public int getParentPassivations()
+   {
+      try
+      {
+         return parent.getPrePassivate();
+      }
+      catch (Exception e)
+      {
+         log.warn("getParentPassivations() " + e.getLocalizedMessage(), e);
+         return -1;
+      }
+   }
+
+   public int getNestedPassivations()
+   {
+      try
+      {
+         return nested.getPrePassivate();
+      }
+      catch (Exception e)
+      {
+         log.warn("getNestedPassivations() " + e.getLocalizedMessage(), e);
+         return -1;
+      }
+   }
+
+   public int getLocalNestedPassivations()
+   {
+      try
+      {
+         return localNested.getPrePassivate();
+      }
+      catch (Exception e)
+      {
+         log.warn("getLocalNestedPassivations() " + e.getLocalizedMessage(), e);
+         return -1;
+      }
+   }
+
+   public int getDeepNestedPassivations()
+   {
+      try
+      {
+         return deepNested.getPrePassivate();
+      }
+      catch (Exception e)
+      {
+         log.warn("getDeepNestedPassivations() " + e.getLocalizedMessage(), e);
+         return -1;
+      }
+   }
+
+   public int getLocalDeepNestedPassivations()
+   {
+      try
+      {
+         return localDeepNested.getPrePassivate();
+      }
+      catch (Exception e)
+      {
+         log.warn("getLocalDeepNestedPassivations() " + e.getLocalizedMessage(), e);
+         return -1;
+      }
+   }
+
+   public int getParentActivations()
+   {
+      try
+      {
+         return parent.getPostActivate();
+      }
+      catch (Exception e)
+      {
+         log.warn("getParentActivations() " + e.getLocalizedMessage(), e);
+         return -1;
+      }
+   }
+
+   public int getNestedActivations()
+   {
+      try
+      {
+         return nested.getPostActivate();
+      }
+      catch (Exception e)
+      {
+         log.debug("getNestedActivations() " + e.getLocalizedMessage());
+         return -1;
+      }
+   }
+
+   public int getLocalNestedActivations()
+   {
+      try
+      {
+         return localNested.getPostActivate();
+      }
+      catch (Exception e)
+      {
+         log.warn("getLocalNestedActivations() " + e.getLocalizedMessage(), e);
+         return -1;
+      }
+   }
+
+   public int getDeepNestedActivations()
+   {
+      try
+      {
+         return deepNested.getPostActivate();
+      }
+      catch (Exception e)
+      {
+         log.warn("getDeepNestedActivations() " + e.getLocalizedMessage(), e);
+         return -1;
+      }
+   }
+
+   public int getLocalDeepNestedActivations()
+   {
+      try
+      {
+         return localDeepNested.getPostActivate();
+      }
+      catch (Exception e)
+      {
+         log.debug("getLocalDeepNestedActivations() " + e.getLocalizedMessage());
+         return -1;
+      }
+   }
+
+   public boolean removeParent()
+   {
+      try
+      {
+         parent.remove();
+         return true;
+      }
+      catch (Exception e)
+      {
+         log.warn("removeParent() " + e.getLocalizedMessage(), e);
+         return false;
+      }
+   }
+
+   public boolean removeNested()
+   {
+      try
+      {
+         nested.remove();
+         return true;
+      }
+      catch (Exception e)
+      {
+         log.debug("removeNested() " + e.getLocalizedMessage());
+         return false;
+      }
+   }
+
+   public boolean removeLocalNested()
+   {
+      try
+      {
+         localNested.remove();
+         return true;
+      }
+      catch (Exception e)
+      {
+         log.warn("removeLocalNested() " + e.getLocalizedMessage(), e);
+         return false;
+      }
+   }
+
+   public boolean removeDeepNested()
+   {
+      try
+      {
+         deepNested.remove();
+         return true;
+      }
+      catch (Exception e)
+      {
+         log.debug("removeDeepNested() " + e.getLocalizedMessage());
+         return false;
+      }
+   }
+
+   public boolean removeLocalDeepNested()
+   {
+      try
+      {
+         localDeepNested.remove();
+         return true;
+      }
+      catch (Exception e)
+      {
+         log.warn("removeLocalDeepNested() " + e.getLocalizedMessage(), e);
+         return false;
+      }
+   }
+
+   @Remove
+   public void remove()
+   {
+      log.debug("Being removed");
+      removeParent();
+      removeNested();
+      removeLocalNested();
+      removeDeepNested();
+      removeLocalDeepNested();
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/BeanMonitorBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * A nested SFSB that operates at the 3rd level of a tree of beans.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface DeepNestedStateful extends PassivationActivationWatcher
+{
+   String getInternalId();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStateful.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import javax.ejb.Remove;
+
+import org.jboss.util.id.GUID;
+
+/**
+ * A DeepNestedStatefulBean.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class DeepNestedStatefulBean
+   extends PassivationActivationWatcherBean
+   implements DeepNestedStateful
+{ 
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private String internalId = new GUID().toString();
+   
+   public String getInternalId()
+   {
+      return internalId;
+   }
+
+   @Remove
+   public void remove()
+   {      
+      log.debug(internalId + " is being removed");
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/DeepNestedStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * A MidLevel.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface MidLevel extends PassivationActivationWatcher
+{
+   DeepNestedStateful getDeepNestedStateful();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/MidLevel.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * Interface for a bean that tracks the number invocations of @PrePassivate
+ * and @PostActivate.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface PassivationActivationWatcher extends Removable
+{
+   int getPostActivate();
+
+   int getPrePassivate();
+
+   void reset();
+}
\ No newline at end of file


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcher.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.io.Serializable;
+
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Superclass for SFSBs that monitor calls to @PrePassivate and @PostActivate.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public abstract class PassivationActivationWatcherBean
+      implements Serializable, PassivationActivationWatcher
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   protected Logger log = Logger.getLogger(getClass());
+   private int postActivateCalled = 0;
+   private int prePassivateCalled = 0;
+
+   public PassivationActivationWatcherBean()
+   {
+      super();
+   }
+
+   @PostActivate
+   public void postActivate()
+   {
+      postActivateCalled++;
+      int sysHC = System.identityHashCode(this);
+      log.debug(sysHC + ": Activated -- activate count = " + postActivateCalled );
+   }
+
+   @PrePassivate
+   public void prePassivate()
+   {
+      prePassivateCalled++;
+      int sysHC = System.identityHashCode(this);
+      log.debug(sysHC + ": Passivated -- passivate count = " + prePassivateCalled );
+   }
+
+   public int getPostActivate()
+   {
+      int sysHC = System.identityHashCode(this);
+      log.debug(sysHC + ": getPostActivate() -- activate count = " + 
+                postActivateCalled );
+      return postActivateCalled;
+   }
+
+   public int getPrePassivate()
+   {
+      int sysHC = System.identityHashCode(this);
+      log.debug(sysHC + ": getPrePassivate() -- passivate count = " + 
+                prePassivateCalled );
+      return prePassivateCalled;
+   }
+   
+   public void reset()
+   {
+      int sysHC = System.identityHashCode(this);
+      log.debug(sysHC + "Being reset");
+      prePassivateCalled = 0;
+      postActivateCalled = 0;
+   }
+
+}
\ No newline at end of file


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/PassivationActivationWatcherBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/Removable.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/Removable.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/Removable.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * An SFSB with a remove method.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface Removable
+{
+   void remove();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/Removable.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+/**
+ * A TopLevel.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface TopLevel extends PassivationActivationWatcher
+{
+   MidLevel getNested();
+   
+   MidLevel getLocalNested();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/TopLevel.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.rmi.dgc.VMID;
+
+/**
+ * Provides SLSB access to a static VMID field.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface VMTracker
+{
+   public static final VMID VMID = new VMID();
+   
+   VMID getVMID();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTracker.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * Provides SLSB access to a static VMID (allowing identification of a JVM.)
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Stateless
+ at Remote(VMTracker.class)
+public class VMTrackerBean implements VMTracker
+{
+   public VMID getVMID()
+   {
+      return VMID;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/VMTrackerBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import org.jboss.ejb3.test.stateful.nested.base.BeanMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.Removable;
+
+
+/**
+ * SFSB that can monitor a ParentStatefulRemote and its affiliated beans.
+ * Basically an in-VM client that has refs to all the SFSBs in the bean
+ * structure.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface NestedBeanMonitor extends BeanMonitor
+{
+   int incrementParent();
+   int incrementNested();
+   int incrementLocalNested();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+import org.jboss.ejb3.test.stateful.nested.base.BeanMonitorBean;
+import org.jboss.ejb3.test.stateful.nested.base.TopLevel;
+
+/**
+ * A NestedBeanMonitorBean.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Stateful
+ at Remote(NestedBeanMonitor.class)
+ at TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+public class NestedBeanMonitorBean
+   extends BeanMonitorBean
+   implements NestedBeanMonitor
+{
+   public void monitor(TopLevel topLevel)
+   {
+      // Just do a cast to confirm the type
+      super.monitor((ParentStatefulRemote) topLevel);
+   }
+
+   public int incrementParent()
+   {
+      try
+      {
+         return ((ParentStatefulRemote) parent).increment();
+      }
+      catch (Exception e)
+      {
+         log.debug("incrementParent() " + e.getLocalizedMessage());
+         return -1;
+      }
+   }
+
+   public int incrementNested()
+   {
+      try
+      {
+         return ((NestedStateful) nested).increment();
+      }
+      catch (Exception e)
+      {
+         log.debug("incrementNested() " + e.getLocalizedMessage());
+         return -1;
+      }
+   }
+
+   public int incrementLocalNested()
+   {
+      try
+      {
+         return ((NestedStateful) localNested).increment();
+      }
+      catch (Exception e)
+      {
+         log.debug("incrementLocalNested() " + e.getLocalizedMessage());
+         return -1;
+      }
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedBeanMonitorBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import java.rmi.dgc.VMID;
+
+import org.jboss.ejb3.test.stateful.nested.base.MidLevel;
+
+
+/**
+ * Comment
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ */
+public interface NestedStateful extends MidLevel
+{
+   VMID getVMID();
+   int increment();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStateful.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
+
+/**
+ * Base class for a nested SFSB. Declares no class annotations,
+ * giving subclasses configuration freedom.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * 
+ * @version $Revision$
+ */
+public abstract class NestedStatefulBean extends PassivationActivationWatcherBean 
+   implements NestedStateful
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   private int counter = 0;
+   
+   @EJB(name="testDeepNestedStateful")
+   private DeepNestedStateful deepNestedStateful;
+   
+   public void reset()
+   {
+      super.reset();
+      counter = 0;
+      deepNestedStateful.reset();
+   }
+
+   public int increment()
+   {
+      counter++;
+      log.debug("INCREMENT - counter: " + counter);
+      return counter;
+   }
+   
+   @Remove
+   public void remove() 
+   {
+      log.debug("Being removed");
+   }
+   
+
+   public DeepNestedStateful getDeepNestedStateful()
+   {
+      return deepNestedStateful;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/NestedStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import org.jboss.ejb3.cache.Optimized;
+
+/**
+ * NestedStatefulBean subclass that implements Optimized in such a way
+ * that getPrePassivate() and getPostActivate() calls are treated as
+ * non-modifications.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * 
+ * @version $Revision$
+ */
+public abstract class OptimizedNestedStatefulBean 
+   extends NestedStatefulBean
+   implements Optimized
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   private boolean modified = true;
+   
+   
+   public boolean isModified()
+   {
+      boolean answer = modified;
+      modified = true;
+      return answer;
+   }
+
+   @Override
+   public int getPostActivate()
+   {
+      // by default all calls except these passivate/activate checks
+      // are modifications, so set modified to false
+      modified = false;
+      return super.getPostActivate();
+   }
+
+   @Override
+   public int getPrePassivate()
+   {
+      // by default all calls except these passivate/activate checks
+      // are modifications, so set modified to false
+      modified = false;
+      return super.getPrePassivate();
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/OptimizedNestedStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import java.rmi.dgc.VMID;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+
+import org.jboss.ejb3.test.stateful.nested.base.MidLevel;
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+
+/**
+ * Parent SFSB that contains nested SFSBs. We don't
+ * annotate it with @Stateful or @CacheConfig so the
+ * subclasses used by the clustered and non-clustered tests
+ * can do that.
+ *
+ * NOTE: EJBTHREE-778 prevents us annotating this class 
+ * @Remote(ParentStatefulRemote.class), but we would if we could. Currently
+ * the subclasses need to do it.
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ */
+public class ParentStatefulBean 
+   extends PassivationActivationWatcherBean
+   implements ParentStatefulRemote
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   private int counter = 0;
+   private int localCounter = 0;
+   
+   @EJB(beanName="testNestedStateful")
+   private NestedStateful nested;
+
+   @EJB(beanName="testLocalNestedStateful")
+   private NestedStateful localNested;
+
+   public VMID getVMID()
+   {
+      return VMTracker.VMID;      
+   }
+   
+   public int increment()
+   {
+      counter = nested.increment();
+
+      log.debug("INCREMENT - counter: " + counter);
+      return counter;
+   }
+
+   public int incrementLocal()
+   {
+      localCounter = localNested.increment();
+
+      log.debug("INCREMENT - localCounter: " + localCounter);
+      return localCounter;
+   }
+
+   /**
+    * Sleep to test
+    * @throws Exception
+    */
+   public void longRunning() throws Exception
+   {
+      log.debug("+++ longRunning() enter ");
+      Thread.sleep(10000);
+      log.debug("+++ longRunning() leave ");
+   }
+   
+   public MidLevel getNested()
+   {
+      return nested;
+   }
+   
+   public MidLevel getLocalNested()
+   {
+      return localNested;
+   }
+   
+   public int getLocalNestedPostActivate()
+   {
+      return localNested.getPostActivate();
+   }
+
+   public int getLocalNestedPrePassivate()
+   {
+      return localNested.getPrePassivate();
+   }
+
+   public void reset()
+   {
+      super.reset();
+      counter = 0;
+      nested.reset();
+      localNested.reset();
+   }
+
+   @Remove
+   public void remove()
+   {
+      log.debug("Being removed");
+   }
+
+   public void setUpFailover(String failover) 
+   {
+      // To setup the failover property
+      log.debug("Setting up failover property: " +failover);
+      System.setProperty ("JBossCluster-DoFail", failover);
+   }
+
+   @PostConstruct
+   public void ejbCreate()
+   {
+   }
+
+   // Remote Interface implementation ----------------------------------------------
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.std;
+
+import java.rmi.dgc.VMID;
+
+import org.jboss.ejb3.test.stateful.nested.base.TopLevel;
+
+
+/**
+ * Parent sfsb interface
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface ParentStatefulRemote 
+   extends TopLevel
+{
+   VMID getVMID();
+   
+   int increment();
+
+   int incrementLocal();
+
+   void longRunning() throws Exception;
+   
+   int getLocalNestedPostActivate();
+
+   int getLocalNestedPrePassivate();
+
+   public void setUpFailover(String failover);
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/std/ParentStatefulRemote.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import org.jboss.ejb3.test.stateful.nested.base.MidLevel;
+
+
+/**
+ * Comment
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ */
+public interface Contained extends MidLevel
+{
+   Customer find(long id);
+
+   void setCustomer(long id);
+
+   Customer getCustomer();
+
+   void updateCustomer();
+
+   void setContainedCustomer();
+   
+   boolean checkContainedCustomer();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Contained.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,106 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import java.io.Serializable;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
+
+/**
+ * Comment
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ */
+public class ContainedBean
+   extends PassivationActivationWatcherBean
+   implements Contained, Serializable
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   @PersistenceContext(unitName="tempdb",type=PersistenceContextType.EXTENDED) 
+   private EntityManager em;
+
+   @EJB(beanName="testDeepNestedContained")
+   private DeepNestedContained deepNestedContained;
+   
+   private Customer customer;
+
+   public Customer find(long id)
+   {
+      Customer c = em.find(Customer.class, id);
+      log.trace("customer " + id + " = " + c);
+      return c;
+   }
+
+   public void setCustomer(long id)
+   {
+      customer = find(id);
+   }
+
+   public Customer getCustomer()
+   {
+      return customer;
+   }
+
+   public void updateCustomer()
+   {
+      customer.setName("contained modified");
+   }
+
+   public void setContainedCustomer()
+   {
+      deepNestedContained.setCustomer(customer.getId());
+   }
+
+   public boolean checkContainedCustomer()
+   {
+      return (deepNestedContained.getCustomer() == customer);
+   }
+
+   @Remove
+   public void remove()
+   {
+      
+   }
+
+   public DeepNestedStateful getDeepNestedStateful()
+   {
+      return deepNestedContained;
+   }
+
+   public void reset()
+   {
+      super.reset();
+      deepNestedContained.reset();
+   }
+   
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ContainedBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,90 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * Company customer
+ *
+ * @author Ben Wang
+ */
+ at Entity
+public class Customer implements java.io.Serializable
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   long id;
+   String name;
+
+   public
+   Customer()
+   {
+   }
+
+   @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
+   public
+   long getId()
+   {
+      return id;
+   }
+
+   public
+   String getName()
+   {
+      return name;
+   }
+
+   public
+   void setId(long long1)
+   {
+      id = long1;
+   }
+
+   public
+   void setName(String string)
+   {
+      name = string;
+   }
+   
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      
+      if (obj instanceof Customer)
+      {
+         Customer other = (Customer) obj;
+         String oName = other.name == null ? "" : other.name;
+         return (this.id == other.id)
+                  && (oName.equals(this.name));
+         
+      }
+      
+      return false;
+   }
+
+}
+


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/Customer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+
+/**
+ * A DeepNestedContained.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface DeepNestedContained extends DeepNestedStateful
+{
+   Customer find(long id);
+   void setCustomer(long id);
+   Customer getCustomer();
+   void updateCustomer();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContained.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStatefulBean;
+
+/**
+ * A DeepNestedContainedBean.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class DeepNestedContainedBean 
+   extends DeepNestedStatefulBean 
+   implements DeepNestedContained
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   @PersistenceContext(unitName="tempdb",type=PersistenceContextType.EXTENDED) 
+   private EntityManager em;
+
+   private Customer customer;
+
+   public Customer find(long id)
+   {
+      return em.find(Customer.class, id);
+   }
+
+   public void setCustomer(long id)
+   {
+      customer = find(id);
+   }
+
+   public Customer getCustomer()
+   {
+      return customer;
+   }
+
+   public void updateCustomer()
+   {
+      customer.setName("modified by " + getInternalId());
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/DeepNestedContainedBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,39 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+
+
+
+
+/**
+ * comment
+ *
+ * @author Ben Wang
+ */
+public interface NestedStatelessLocal extends VMTracker
+{
+   void update(Customer c);
+
+   void findAndUpdate(long id);
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessLocal.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,63 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.test.stateful.nested.base.VMTrackerBean;
+
+/**
+ * SLSB that is meant to be nested in a parent SFSB and share
+ * and ExtendedPersistenceContext with it.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ */
+ at Stateless
+ at Local(NestedStatelessLocal.class)
+public class NestedStatelessSessionBean 
+   extends VMTrackerBean
+   implements NestedStatelessLocal
+{
+   @PersistenceContext(unitName="tempdb") 
+   private EntityManager em;
+   
+   public void update(Customer c)
+   {
+      c.setName("Bill Jr.");
+   }
+
+   public void findAndUpdate(long id)
+   {
+      Customer cust = find(id);
+      cust.setName("stateless modified");
+   }
+
+   public Customer find(long id)
+   {
+      return em.find(Customer.class, id);
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedStatelessSessionBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import org.jboss.ejb3.test.stateful.nested.base.BeanMonitor;
+
+/**
+ * A NestedXPCBeanMonitor.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface NestedXPCMonitor extends BeanMonitor
+{
+   Customer find(long id);
+   
+   Customer findParent(long id);   
+   Customer findNested(long id);   
+   Customer findLocalNested(long id);   
+   Customer findDeepNested(long id);
+   Customer findLocalDeepNested(long id);
+   
+   boolean compareTopToNested(long id);
+   boolean compareTopToLocalNested(long id);
+   boolean compareNestedToLocalNested(long id);
+   boolean compareNestedToDeepNested(long id);
+   boolean compareLocalNestedToLocalDeepNested(long id);
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.ejb3.test.stateful.nested.base.BeanMonitorBean;
+
+/**
+ * A NestedXPCMonitorBean.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Stateful
+ at Remote(NestedXPCMonitor.class)
+ at TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+public class NestedXPCMonitorBean 
+   extends BeanMonitorBean 
+   implements NestedXPCMonitor
+{
+   @PersistenceContext(unitName="tempdb")
+   private EntityManager em;
+   
+   private Set<Long> ids = new HashSet<Long>();
+   
+   @TransactionAttribute(TransactionAttributeType.REQUIRED)
+   public Customer find(long id)
+   {
+      ids.add(new Long(id));
+      return em.find(Customer.class, id);
+   }
+
+   public boolean compareLocalNestedToLocalDeepNested(long id)
+   {
+      try
+      {
+         Contained midLevel = (Contained) localNested;
+         midLevel.setCustomer(id);
+         midLevel.setContainedCustomer();
+         return midLevel.checkContainedCustomer(); 
+      }
+      catch (Exception e)
+      {
+         log.debug("compareLocalNestedToDeepNested(): " + e.getLocalizedMessage());
+      }
+      return false;
+   }
+
+   public boolean compareNestedToDeepNested(long id)
+   {
+      try
+      {
+         Contained midLevel = (Contained) nested;
+         midLevel.setCustomer(id);
+         midLevel.setContainedCustomer();
+         return midLevel.checkContainedCustomer();         
+      }
+      catch (Exception e)
+      {
+         log.debug("compareNestedToDeepNested(): " + e.getLocalizedMessage());
+      }
+      return false;
+   }
+
+   public boolean compareTopToLocalNested(long id)
+   {
+      try
+      {
+         ShoppingCart cart = (ShoppingCart) parent;
+         cart.setCustomer(id);
+         cart.setContainedCustomer();
+         return cart.checkContainedCustomer();         
+      }
+      catch (Exception e)
+      {
+         log.debug("compareTopToLocalNested(): " + e.getLocalizedMessage());
+      }
+      return false;
+   }
+
+   public boolean compareTopToNested(long id)
+   {
+      try
+      {
+         Customer mid = findNested(id);
+         Customer top = findParent(id);
+         
+         return (mid != null && mid != top && mid.equals(top)) ;          
+      }
+      catch (Exception e)
+      {
+         log.debug("compareTopToNested(): " + e.getLocalizedMessage());
+      }
+      return false;
+   }
+
+   public boolean compareNestedToLocalNested(long id)
+   {
+      try
+      {
+         Customer remote = findNested(id);
+         Customer local  = findLocalNested(id);
+         
+         return (remote != null && remote.equals(local));         
+      }
+      catch (Exception e)
+      {
+         log.debug("compareTopToLocalNested(): " + e.getLocalizedMessage());
+      }
+      return false;
+   }
+
+   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+   public Customer findDeepNested(long id)
+   {
+      try
+      {
+         return ((DeepNestedContained) deepNested).find(id);
+      }
+      catch (Exception e)
+      {
+         log.debug("findDeepNested(): " + e.getLocalizedMessage());
+      }
+      return null;
+   }
+
+   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+   public Customer findLocalDeepNested(long id)
+   {
+      try
+      {
+         return ((DeepNestedContained) localDeepNested).find(id);
+      }
+      catch (Exception e)
+      {
+         log.debug("findLocalDeepNested(): " + e.getLocalizedMessage());
+      }
+      return null;
+   }
+
+   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+   public Customer findLocalNested(long id)
+   {
+      try
+      {
+         return ((Contained) localNested).find(id);
+      }
+      catch (Exception e)
+      {
+         log.debug("findLocalNested(): " + e.getLocalizedMessage());
+      }
+      return null;
+   }
+
+   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+   public Customer findNested(long id)
+   {
+      try
+      {
+         return ((Contained) nested).find(id);
+      }
+      catch (Exception e)
+      {
+         log.debug("findNested(): " + e.getLocalizedMessage());
+      }
+      return null;
+   }
+
+   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+   public Customer findParent(long id)
+   {
+      try
+      {
+         return ((ShoppingCart) parent).find(id);
+      }
+      catch (Exception e)
+      {
+         log.debug("findParent(): " + e.getLocalizedMessage());
+      }
+      return null;
+   }
+
+   @Override
+   @TransactionAttribute(TransactionAttributeType.REQUIRED)   
+   public void remove()
+   {
+      super.remove();
+      
+      for (Long id : ids)
+      {
+         try
+         {
+            Customer c = em.find(Customer.class, id.longValue());
+            if (c != null)
+               em.remove(c);
+         }
+         catch (Exception e) 
+         {
+            log.debug("remove(): Problem removing " + id, e);
+         }
+      }
+   }
+   
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/NestedXPCMonitorBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,64 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import java.rmi.dgc.VMID;
+
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcher;
+import org.jboss.ejb3.test.stateful.nested.base.TopLevel;
+
+
+/**
+ * Interface exposed by SFSB used in ExtendedPersistenceContext testing.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ */
+public interface ShoppingCart 
+   extends PassivationActivationWatcher, TopLevel
+{
+   VMID getVMID();
+   
+   long createCustomer();
+
+   void update();
+
+   Customer find(long id);
+
+   void update2();
+
+   void update3();
+
+   void never();
+   
+   void setCustomer(long id);
+   
+   void setContainedCustomer();
+
+   void updateContained();
+
+   void findAndUpdateStateless();
+
+   boolean checkContainedCustomer();
+   
+   void setUpFailover(String failover);
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCart.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,160 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful.nested.base.xpc;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.test.stateful.nested.base.MidLevel;
+import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+
+/**
+ * Base SFSB for use in ExtendedPersistenceContext testing.
+ *
+ * @author Ben Wang
+ */
+public class ShoppingCartBean
+   extends PassivationActivationWatcherBean
+   implements ShoppingCart
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   @PersistenceContext(unitName="tempdb",type=PersistenceContextType.EXTENDED) 
+   private EntityManager em;
+
+   private Customer customer;
+
+   @EJB(beanName="testShoppingCartContained") 
+   private Contained contained;
+
+   @EJB(beanName="testLocalShoppingCartContained") 
+   private Contained localContained;
+   
+   @EJB
+   private NestedStatelessLocal stateless;
+
+   public VMID getVMID()
+   {
+      return VMTracker.VMID;
+   }
+   
+   public MidLevel getLocalNested()
+   {
+      return localContained;
+   }
+
+   public MidLevel getNested()
+   {
+      return contained;
+   }
+
+   public long createCustomer()
+   {
+      customer = new Customer();
+      customer.setName("William");
+      em.persist(customer);
+      System.out.println("********* created *****");
+      return customer.getId();
+   }
+
+   public void setCustomer(long id)
+   {
+      customer = find(id);
+   }
+
+   public void setContainedCustomer()
+   {
+      localContained.setCustomer(customer.getId());
+   }
+
+   public boolean checkContainedCustomer()
+   {
+      return (localContained.getCustomer() == customer);
+   }
+
+   public void updateContained()
+   {
+      localContained.updateCustomer();
+   }
+
+   public void update()
+   {
+      System.out.println("********* update() *****");
+      customer.setName("Bill");
+   }
+   public void update2()
+   {
+      customer.setName("Billy");
+   }
+
+   public void update3()
+   {
+      stateless.update(customer);
+   }
+
+   public void findAndUpdateStateless()
+   {
+      stateless.findAndUpdate(customer.getId());
+      if (!customer.getName().equals("stateless modified")) 
+         throw new RuntimeException("stateless didn't get propagated pc");
+   }
+
+   public Customer find(long id)
+   {
+      return em.find(Customer.class, id);
+   }
+
+   @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+   public void never()
+   {
+      customer.setName("Bob");
+   }
+
+   public void reset()
+   {
+      super.reset();
+      contained.reset();
+      localContained.reset();
+   }
+
+
+   @Remove
+   public void remove() 
+   {      
+   }
+
+   public void setUpFailover(String failover) 
+   {
+      // To setup the failover property
+      log.debug("Setting up failover property: " +failover);
+      System.setProperty ("JBossCluster-DoFail", failover);
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/nested/base/xpc/ShoppingCartBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.unit;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ejb.NoSuchEJBException;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.test.stateful.nested.base.Removable;
+import org.jboss.logging.Logger;
+
+/**
+ * Base class for test runners that can share test functionality between
+ * JBossTestCase subclasses and JBossClusteredTestCase subclasses.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class BaseTestRunner
+{
+   protected InitialContext initialContext;
+   protected Set<Removable> removables = new HashSet<Removable>();
+   
+   private Logger log;
+   private long sleepTime = 11100L;
+   private int passivationPerInvocation = 0;
+   private int passivationPerSleep = 1;
+   
+   public BaseTestRunner(InitialContext context, Logger log)
+   {
+      this.initialContext = context;
+      this.log = log;
+   }
+
+   public void setUp() throws Exception
+   {      
+   }
+
+   public void tearDown() throws Exception
+   {
+      // Remove any EJBs so they don't spuriously passivate and
+      // throw off the passivation counts
+      for (Removable removable : removables)
+      {
+         try
+         {
+            removable.remove();
+         }
+         catch (Exception ignored) {}
+      }
+      
+      removables.clear();
+   }
+
+   protected InitialContext getInitialContext()
+   {
+      return initialContext;
+   }
+   
+   protected Logger getLog()
+   {
+      return log;
+   }
+
+   public long getSleepTime()
+   {
+      return sleepTime;
+   }
+
+   public void setSleepTime(long sleepTime)
+   {
+      this.sleepTime = sleepTime;
+   }
+
+   public void sleep(long time)
+   {
+      try {
+         Thread.sleep(time);
+      } catch (InterruptedException e) {
+         e.printStackTrace();
+      }
+   }
+   
+   public void sleep()
+   {
+      sleep(getSleepTime());
+   }
+
+   public int getPassivationPerInvocation()
+   {
+      return passivationPerInvocation;
+   }
+
+   public void setPassivationPerInvocation(int passivationPerInvocation)
+   {
+      this.passivationPerInvocation = passivationPerInvocation;
+   }
+
+   public int getPassivationPerSleep()
+   {
+      return passivationPerSleep;
+   }
+
+   public void setPassivationPerSleep(int passivationPerSleep)
+   {
+      this.passivationPerSleep = passivationPerSleep;
+   }
+   
+   public int getExpectedPassivations(int sleepCycles, int invocations)
+   {
+      return (sleepCycles * passivationPerSleep) + 
+             (invocations * passivationPerInvocation);
+   }
+   
+   public void addRemovable(Removable bean)
+   {
+      removables.add(bean);
+   }
+
+   public void removeBean(Removable bean)
+   {
+      try
+      {
+         bean.remove();
+      }
+      catch (NoSuchEJBException ignored) 
+      {
+         // this is OK; it was already removed
+      }
+      removables.remove(bean);
+   }
+
+}
\ No newline at end of file


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/BaseTestRunner.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.unit;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Tests for ExtendedPersistenceContext management.
+ * 
+ * This class uses a delegate to execute the tests so the clustered
+ * version of the tests (which derive from a different base class)
+ * can use the same delegate code.
+ *
+ * @author Ben Wang
+ * @version $Id$
+ */
+public class ExtendedPersistenceUnitTestCase extends JBossTestCase
+{
+   private XPCTestRunner runner;
+   
+   public ExtendedPersistenceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(ExtendedPersistenceUnitTestCase.class,
+                               "stateful-test.jar");
+   }
+
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      runner = new XPCTestRunner(getInitialContext(), getLog());
+      runner.setUp();
+      // Use a sleep time just a bit longer than twice the bean timeout
+      runner.setSleepTime(2100L);
+   }
+
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      if (runner != null)
+         runner.tearDown();
+   }
+
+
+   public void testBasic() throws Exception
+   {
+      runner.testBasic();
+   }
+   
+   public void testDependentLifecycle() throws Exception
+   {
+      runner.testDependentLifecycle();
+   }
+   
+   public void testXPCSharing() throws Exception
+   {
+      runner.testXPCSharing();
+   }
+
+   public void testPassivation() throws Exception
+   {
+      runner.testPassivation();
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/ExtendedPersistenceUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,194 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.unit;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.stateful.Stateful;
+import org.jboss.logging.Logger;
+import org.jboss.security.client.SecurityClient;
+import org.jboss.security.client.SecurityClientFactory;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MetricsUnitTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
+   
+   private SecurityClient client = null;
+
+   public MetricsUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      this.client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MetricsUnitTestCase.class, "stateful-test.jar");
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      if(client == null)
+         return;
+      client.logout();
+      client = null;
+      
+      super.tearDown();
+   }
+   
+   protected void testJmxMetrics(MBeanServerConnection server, String jndiBinding, String objectName) throws Exception
+   {
+      ObjectName testerName = new ObjectName(objectName);
+      
+      // Get the start cache size 
+      int startCacheSize = (Integer)server.getAttribute(testerName, "CacheSize");
+      int startTotalSize = (Integer)server.getAttribute(testerName, "TotalSize");
+      
+      // 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);
+      
+      totalSize = (Integer)server.getAttribute(testerName, "TotalSize");
+      assertEquals(cacheSize + passivatedCount, totalSize);
+      
+      stateful.removeMe();
+      cacheSize = (Integer)server.getAttribute(testerName, "CacheSize");
+      assertEquals(0, cacheSize);
+      
+      removeCount = (Integer)server.getAttribute(testerName, "RemoveCount");
+      assertEquals(2, removeCount);
+      
+      totalSize = (Integer)server.getAttribute(testerName, "TotalSize");
+      assertEquals(cacheSize + passivatedCount, totalSize);
+      
+   }
+
+   public void testJmxMetricsStateful() throws Exception
+   {
+      MBeanServerConnection server = getServer();
+
+      // Note: we got one creation in ServiceBean
+      
+      testJmxMetrics(server, "Stateful", "jboss.j2ee:jar=stateful-test.jar,name=StatefulBean,service=EJB3");
+   }
+   
+   public void testJmxMetricsTreeCacheStateful() throws Exception
+   {
+      MBeanServerConnection server = getServer();
+
+      testJmxMetrics(server, "TreeCacheStateful", "jboss.j2ee:jar=stateful-test.jar,name=TreeCacheStatefulBean,service=EJB3");
+   }
+   
+   public void testJmxMetricsTreeCacheRemovalStateful() throws Exception
+   {
+      MBeanServerConnection server = getServer();
+
+      testJmxMetrics(server, "TreeCacheRemovalStateful", "jboss.j2ee:jar=stateful-test.jar,name=TreeCacheRemovalStatefulBean,service=EJB3");
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,493 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.unit;
+
+import java.rmi.dgc.VMID;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Assert;
+
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedBeanMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulRemote;
+import org.jboss.logging.Logger;
+
+/**
+ * Encapsulates the functions needed for tests of nested SFSBs in
+ * a class that can be used either by a JBossTestCase subclass or
+ * a JBossClusteredTestCase subclass.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class NestedBeanTestRunner extends BaseTestRunner
+{
+   public NestedBeanTestRunner(InitialContext context, Logger log)
+   {
+      super(context, log);
+   }
+   
+   
+   public void testBasic()
+   throws Exception
+   {
+      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");
+   }
+   
+   public void testDependentLifecycle()
+   throws Exception
+   {
+      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();
+      Assert.assertNotNull("Got a localDeepId", localDeepId);
+      Assert.assertFalse("Got a non-ERROR localDeepId", "ERROR".equals(localDeepId));
+       
+      removeBean(parent);
+       
+      // Confirm parent is dead
+      Assert.assertEquals("Remote counter (via dead parent): ", -1, monitor.incrementParent());
+      Assert.assertFalse("parent.remove() fails", monitor.removeParent());
+      
+      // Confirm nested beans still work following parent remove
+      Assert.assertEquals("Remote counter (direct):", 2 ,nested.increment());      
+      Assert.assertEquals("Local counter (monitor):", 1 , monitor.incrementLocalNested());
+      Assert.assertEquals("Deep nested id", deepId, monitor.getDeepNestedId());
+      Assert.assertEquals("Local deep nested id", localDeepId, monitor.getLocalDeepNestedId());
+      
+      // Remove the bottom tier
+      Assert.assertTrue("Local deep nested removed", monitor.removeLocalDeepNested());
+      
+      // Confirm it is dead
+      Assert.assertEquals("Local deep nested removed", "ERROR", monitor.getLocalDeepNestedId());
+      Assert.assertFalse("localDeepNested.remove() fails", monitor.removeLocalDeepNested());
+      
+      // Confirm other beans still work following parent remove
+      Assert.assertEquals("Remote counter (direct):", 3 ,nested.increment());      
+      Assert.assertEquals("Local counter (monitor):", 2 , monitor.incrementLocalNested());
+      Assert.assertEquals("Deep nested id", deepId, monitor.getDeepNestedId());
+      
+      // Remove the nested bean
+      removeBean(nested);
+      
+      Assert.assertEquals("Remote counter (via monitor): ", -1, monitor.incrementNested());
+      Assert.assertFalse("nested.remove() fails", monitor.removeNested());
+      
+      // Confirm other beans still work
+      Assert.assertEquals("Local counter (monitor):", 3 , monitor.incrementLocalNested());
+      Assert.assertEquals("Deep nested id", deepId, monitor.getDeepNestedId());
+      
+      // Remove the local nested bean
+      Assert.assertTrue("Local nested removed", monitor.removeLocalNested());
+      
+      // Confirm it is dead
+      Assert.assertEquals("Local nested removed", -1, monitor.incrementLocalNested());
+      Assert.assertFalse("localNested.remove() fails", monitor.removeLocalNested());
+      
+      // Confirm other beans still work following parent remove
+      Assert.assertEquals("Deep nested id", deepId, monitor.getDeepNestedId());
+      
+      // Remove the deep nested bean
+      Assert.assertTrue("Deep removed", monitor.removeDeepNested());
+      
+      // Confirm it is dead
+      Assert.assertEquals("Local nested removed", "ERROR", monitor.getDeepNestedId());
+      Assert.assertFalse("deepNested.remove() fails", monitor.removeDeepNested());
+      
+      removeBean(monitor);
+      
+      getLog().debug("ok");
+      
+   }
+
+   public void testStatefulPassivation()
+   throws Exception
+   {
+      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
+
+//    Assert.assertEquals("Remote counter: ", 1, parent.increment());
+      Assert.assertEquals("Remote counter: ", 1, monitor.incrementParent());
+      parentInv++; //3
+      nestedInv++; //2
+
+//    Assert.assertEquals("Remote counter: ", 2, parent.increment());
+      Assert.assertEquals("Remote counter: ", 2, monitor.incrementParent());
+      parentInv++; //4
+      nestedInv++; //3
+//    Assert.assertEquals("Local counter: ", 1, parent.incrementLocal());
+      Assert.assertEquals("Local counter: ", 1, monitor.incrementLocalNested());
+      parentInv++; //5
+//    Assert.assertEquals("Local counter: ", 2, parent.incrementLocal());
+      Assert.assertEquals("Local counter: ", 2, monitor.incrementLocalNested());
+      parentInv++; //6
+      
+      // How the nested bean behaves depends on whether its context is
+      // contained by the parent bean context, which varies. Here we use
+      // the passivation counts to determine what the situation is and
+      // then use that behavior later to establish correct assertions.
+      int parentPre = monitor.getParentPassivations();
+      Assert.assertEquals("Parent passivate count: ",
+                          getExpectedPassivations(0, parentInv), 
+                          parentPre);
+      parentInv++; //7
+      boolean nestedIsContained = (monitor.getNestedPassivations() == parentPre + 1); // add one because parent.getPrePassivate() added one
+      System.err.println("nestedIsContained = " + nestedIsContained);
+      if (nestedIsContained)
+      {
+         // Above parentInv++ should also have been nestedInv++
+         // plus one more from getNestedBeanSet()
+         nestedInv += 4; //3-7
+         // nested.getPrePassivate() activates the parent, which means
+         // the passivation below will increment the passivate count.
+         // So record that
+         parentInv++; //6-7
+      }
+      // nested.getPrePassivate() activates nested, which means
+      // the passivation below will increment the passivate count.
+      // So record that 
+      nestedInv++; //4-8
+      
+      sleep(getSleepTime());  // should passivate
+
+      Assert.assertEquals("Parent passivate count: ",
+                          getExpectedPassivations(1, parentInv),  
+//                          parent.getPrePassivate());
+                          monitor.getParentPassivations());
+      parentInv++; //7-8
+      if (nestedIsContained)
+      {
+         nestedInv++; //4-9
+      }
+      Assert.assertEquals("Parent activate count: ",
+                          getExpectedPassivations(1, parentInv),
+//                          parent.getPostActivate());
+                          monitor.getParentActivations());
+      parentInv++; //8-9
+      if (nestedIsContained)
+      {
+         nestedInv++; //4-10
+      }
+      Assert.assertEquals("Remote nested passivate count: ",
+                          getExpectedPassivations(1, nestedInv),  
+//                          nested.getPrePassivate());
+                          monitor.getNestedPassivations());
+      Assert.assertEquals("Remote nested activate count: ",
+                          getExpectedPassivations(1, nestedInv),
+//                          nested.getPostActivate());
+                          monitor.getNestedActivations());
+      Assert.assertEquals("Local nested passivate count: ",
+                          getExpectedPassivations(1, parentInv),
+//                          parent.getLocalNestedPrePassivate());
+                          monitor.getLocalNestedPassivations());
+      parentInv++; //9-10
+      if (nestedIsContained)
+      {
+         nestedInv++; //4-11
+      }
+      Assert.assertEquals("Local nested activate count: ",
+                          getExpectedPassivations(1, parentInv),
+//                          parent.getLocalNestedPostActivate());
+                          monitor.getLocalNestedActivations());
+      parentInv++; //10-11
+      if (nestedIsContained)
+      {
+         nestedInv++; //4-12
+      }
+      
+      // Use the monitor to check the deep nested beans.  In a cluster these
+      // are marked not to treat replication as passivation, so we ignore 
+      // the number of invocations
+      Assert.assertEquals("Deep nested passivate count: ", 1, monitor.getDeepNestedPassivations());
+      nestedInv++; //5-13
+      if (nestedIsContained)
+      {
+         parentInv++; //10-12
+      }
+      Assert.assertEquals("Deep nested activate count: ", 1, monitor.getDeepNestedActivations());
+      nestedInv++; //6-14
+      if (nestedIsContained)
+      {
+         parentInv++; //10-13
+      }
+      Assert.assertEquals("Local deep nested passivate count: ", 1, monitor.getLocalDeepNestedPassivations());
+      parentInv++; //11-14
+      if (nestedIsContained)
+      {
+         nestedInv++; //6-15
+      }
+      Assert.assertEquals("Local deep nested activate count: ", 1, monitor.getLocalDeepNestedActivations());
+      parentInv++; //12-15
+      if (nestedIsContained)
+      {
+         nestedInv++; //6-16
+      }
+      
+//    Assert.assertEquals("Remote counter: ", 3, parent.increment());
+      Assert.assertEquals("Remote counter: ", 3, monitor.incrementParent());
+      parentInv++; //13-16
+      nestedInv++; //7-17
+//    Assert.assertEquals("Remote counter: ", 4, parent.increment());
+      Assert.assertEquals("Remote counter: ", 4, monitor.incrementParent());
+      parentInv++; //14-17
+      nestedInv++; //8-18
+//    Assert.assertEquals("Local counter: ", 3, parent.incrementLocal());
+      Assert.assertEquals("Local counter: ", 3, monitor.incrementLocalNested());
+      parentInv++; //15-18
+      if (nestedIsContained)
+      {
+         nestedInv++; //8-19
+      }
+//    Assert.assertEquals("Local counter: ", 4, parent.incrementLocal());
+      Assert.assertEquals("Local counter: ", 4, monitor.incrementLocalNested()); 
+      parentInv++;  //16-19
+      if (nestedIsContained)
+      {
+         nestedInv++; //8-20
+      }   
+      
+      sleep(getSleepTime());  // should passivate
+
+      Assert.assertEquals("Parent passivate count: ",
+                          getExpectedPassivations(2, parentInv),  
+//                          parent.getPrePassivate());
+                          monitor.getParentPassivations());
+      parentInv++; //17-20
+      if (nestedIsContained)
+      {
+         nestedInv++; //8-21
+      }
+      Assert.assertEquals("Parent activate count: ",
+                          getExpectedPassivations(2, parentInv),
+//                          parent.getPostActivate());
+                          monitor.getParentActivations());
+      parentInv++; //18-21
+      if (nestedIsContained)
+      {
+         nestedInv++; //8-22
+      }
+      Assert.assertEquals("Remote nested passivate count: ",
+                          getExpectedPassivations(2, nestedInv),  
+//                          nested.getPrePassivate());
+                          monitor.getNestedPassivations());
+      Assert.assertEquals("Remote nested activate count: ",
+                          getExpectedPassivations(2, nestedInv),  
+//                          nested.getPostActivate());
+                          monitor.getNestedActivations());
+      Assert.assertEquals("Local nested passivate count: ",
+                          getExpectedPassivations(2, parentInv), 
+//                          parent.getLocalNestedPrePassivate());
+                          monitor.getLocalNestedPassivations());
+      parentInv++; //19-22
+      if (nestedIsContained)
+      {
+         nestedInv++; //8-23
+      }
+      Assert.assertEquals("Local nested activate count: ",
+                          getExpectedPassivations(2, parentInv), 
+//                          parent.getLocalNestedPostActivate());
+                          monitor.getLocalNestedActivations());
+      parentInv++; //20-23
+      if (nestedIsContained)
+      {
+         nestedInv++; //8-24
+      }
+      
+      // Use the monitor to check the deep nested beans.
+      Assert.assertEquals("Deep nested passivate count: ", 2, monitor.getDeepNestedPassivations());
+      nestedInv++; //9-25
+      if (nestedIsContained)
+      {
+         parentInv++; //20-24
+      }
+      Assert.assertEquals("Deep nested activate count: ", 2, monitor.getDeepNestedActivations());
+      nestedInv++; //10-26
+      if (nestedIsContained)
+      {
+         parentInv++; //20-25
+      }
+      Assert.assertEquals("Local deep nested passivate count: ", 2, monitor.getLocalDeepNestedPassivations());
+      parentInv++; //21-26
+      if (nestedIsContained)
+      {
+         nestedInv++; //10-27
+      }
+      Assert.assertEquals("Local deep nested activate count: ", 2, monitor.getLocalDeepNestedActivations());
+      parentInv++; //22-27
+      if (nestedIsContained)
+      {
+         nestedInv++; //10-28
+      }
+      
+//    Assert.assertEquals("Remote counter: ", 5, parent.increment());
+      Assert.assertEquals("Remote counter: ", 5, monitor.incrementParent());
+      parentInv++; //23-28
+      nestedInv++; //11-29
+//    Assert.assertEquals("Remote counter: ", 6, parent.increment());
+      Assert.assertEquals("Remote counter: ", 6, monitor.incrementParent());
+      parentInv++; // 24-29
+      nestedInv++; //12-30
+//    Assert.assertEquals("Local counter: ", 5, parent.incrementLocal());
+      Assert.assertEquals("Local counter: ", 5, monitor.incrementLocalNested());
+      parentInv++;  //25-30
+      if (nestedIsContained)
+      {
+         nestedInv++; //12-31
+      }
+//    Assert.assertEquals("Local counter: ", 6, parent.incrementLocal());
+      Assert.assertEquals("Local counter: ", 6, monitor.incrementLocalNested());
+      parentInv++; //26-31
+      if (nestedIsContained)
+      {
+         nestedInv++; //12-32
+      }
+      
+      removeBean(parent);
+      if (nestedIsContained)
+      {
+         nestedInv++; //12-33
+      }
+      
+      // Force the nested bean to go through another passivation
+      // to check the activation process can survive the removal 
+      // of its parent
+      sleep(getSleepTime());
+      
+      // Confirm nested still works following parent remove
+//    Assert.assertEquals("Remote counter (direct): ", 7, nested.increment());
+      Assert.assertEquals("Remote counter (direct): ", 7, monitor.incrementNested());
+      nestedInv++; //13-34
+      Assert.assertEquals("Remote nested passivate count: ",
+                          getExpectedPassivations(3, nestedInv), 
+//                          nested.getPrePassivate());
+                          monitor.getNestedPassivations());
+      Assert.assertEquals("Remote nested activate count: ",
+                          getExpectedPassivations(3, nestedInv), 
+//                          nested.getPostActivate());
+                          monitor.getNestedActivations());
+      
+      removeBean(nested);
+      
+      getLog().debug("ok");
+   }
+   
+   public NestedBeanSet getNestedBeanSet()
+   throws Exception
+   {
+      // We want a colocated monitor and SFSB to test passivation/destruction
+      // StatelessRemoteBean is not clustered, so once we have it's VMID
+      // we can keep creating SFSBs until we get one we want
+      getLog().debug("Looking up NestedBeanMonitorBean...");
+      NestedBeanMonitor monitor = (NestedBeanMonitor) getInitialContext().lookup("NestedBeanMonitorBean/remote");
+      VMID monitorVM = monitor.getVMID();
+      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;
+      result.parent = parent;
+      result.nested = nested;
+      result.parentInvocations = parentInv;
+      result.nestedInvocations = nestedInv;
+      
+      return result;
+   }
+   
+   
+
+   public static class NestedBeanSet
+   {
+      public NestedBeanMonitor monitor;
+      public ParentStatefulRemote parent;
+      public NestedStateful nested;
+      public int parentInvocations = 0;
+      public int nestedInvocations = 0;
+   }
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanTestRunner.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.stateful.unit;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test nested SFSB for repeated passivation
+ *
+ * @author  Ben.Wang at jboss.org
+ * @version $Revision$
+ */
+public class NestedBeanUnitTestCase extends JBossTestCase
+{
+   private NestedBeanTestRunner runner;
+   
+   public NestedBeanUnitTestCase (String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(NestedBeanUnitTestCase.class, "stateful-test.jar");
+   }
+   
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      runner = new NestedBeanTestRunner(getInitialContext(), getLog());
+      runner.setUp();
+      // Use a sleep time just a bit longer than twice the bean timeout
+      runner.setSleepTime(2100L);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      if (runner != null)
+         runner.tearDown();
+   }
+
+   public void testBasic()
+   throws Exception
+   {
+      runner.testBasic();
+   }
+   
+   public void testDependentLifecycle()
+   throws Exception
+   {
+      runner.testDependentLifecycle();      
+   }
+
+   public void testStatefulPassivation()
+   throws Exception
+   {
+      runner.testStatefulPassivation();
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,860 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.stateful.unit;
+
+import java.util.Map;
+import java.util.Random;
+
+import javax.ejb.NoSuchEJBException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.ClientKernelAbstraction;
+import org.jboss.ejb3.KernelAbstractionFactory;
+import org.jboss.ejb3.test.stateful.AnnotatedAppException;
+import org.jboss.ejb3.test.stateful.CheckedApplicationException;
+import org.jboss.ejb3.test.stateful.ClusteredStateful;
+import org.jboss.ejb3.test.stateful.ConcurrentStateful;
+import org.jboss.ejb3.test.stateful.Entity;
+import org.jboss.ejb3.test.stateful.EntityFacade;
+import org.jboss.ejb3.test.stateful.ExtendedState;
+import org.jboss.ejb3.test.stateful.RemoteBindingInterceptor;
+import org.jboss.ejb3.test.stateful.ServiceRemote;
+import org.jboss.ejb3.test.stateful.SmallCacheStateful;
+import org.jboss.ejb3.test.stateful.State;
+import org.jboss.ejb3.test.stateful.Stateful;
+import org.jboss.ejb3.test.stateful.Stateful21;
+import org.jboss.ejb3.test.stateful.StatefulHome;
+import org.jboss.ejb3.test.stateful.StatefulInvoker;
+import org.jboss.ejb3.test.stateful.StatefulTimeout;
+import org.jboss.ejb3.test.stateful.StatefulTx;
+import org.jboss.ejb3.test.stateful.Stateless;
+import org.jboss.ejb3.test.stateful.Tester;
+import org.jboss.logging.Logger;
+import org.jboss.security.client.SecurityClient;
+import org.jboss.security.client.SecurityClientFactory;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Sample client for the jboss container.
+ *
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @version $Id$
+ */
+
+public class RemoteUnitTestCase
+extends JBossTestCase
+{
+   @SuppressWarnings("unused")
+   private static final Logger log = Logger.getLogger(RemoteUnitTestCase.class);
+
+   static boolean deployed = false;
+   static int test = 0;
+
+   public RemoteUnitTestCase(String name)
+   {
+
+      super(name);
+
+   }
+   
+   private class ConcurrentInvocation extends Thread
+   {
+      SmallCacheStateful small = null;
+      public Exception ex;
+      private int id;
+      
+      public ConcurrentInvocation(int id)
+      {
+         this.id = id;
+         try
+         {
+            small = (SmallCacheStateful)getInitialContext().lookup("SmallCacheStatefulBean/remote");
+            small.setId(id);
+         }
+         catch (Exception e)
+         {
+         }
+      }
+      
+      public void run()
+      {
+         for (int i = 0; i < 5; i++)
+         {
+            try
+            {
+               assertEquals(small.doit(id),i);
+            }
+            catch (Exception e)
+            {
+               ex = e;
+            }
+            catch (Error er)
+            {
+               ex = new RuntimeException("Failed assert: " + id, er);
+            }
+         }
+      }
+   }
+   
+   private class ConcurrentStatefulTimeoutClient extends Thread
+   {
+      StatefulTimeout sfsb;
+      public Exception ex;
+      private int id;
+      private int wait;
+      public boolean removed = false;
+      public Exception failure = null;
+      
+      public ConcurrentStatefulTimeoutClient(int id, int wait) throws Exception
+      {
+         this.id = id;
+         this.wait = wait;
+         sfsb = (StatefulTimeout)getInitialContext().lookup("StatefulClusteredTimeoutBean/remote");
+      }
+      
+      public void run()
+      {
+         Random random = new Random(id);
+         
+         while (!removed)
+         {
+            try
+            {
+               sfsb.test();
+               int millis = random.nextInt(wait);
+               if (millis <= wait/10)
+               {
+                  sfsb.remove();
+                  removed = true;
+                  System.out.println("Bean has been removed " + id);
+               }
+               else
+                  Thread.sleep(millis);
+            }
+            catch (javax.ejb.NoSuchEJBException e)
+            {
+               System.out.println("Bean has timed out " + id);
+               removed = true;
+            }
+            catch (Exception e)
+            {
+               failure = e;
+               log.debug("Concurrent invocation failed on " + sfsb, e);
+               return;
+            }
+         }
+      }
+   }
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      serverFound();
+   }
+   
+   // Keep this test first so we test everything after a deployment restart
+   public void testJmxName() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      stateful.setState("state");
+      stateful.removeMe();
+      
+      ObjectName deployment = new ObjectName("test.ejb3:name=Bill,service=EJB3");
+
+      ClientKernelAbstraction kernel = KernelAbstractionFactory.getClientInstance();
+      kernel.invoke(deployment, "stop", new Object[0], new String[0]);
+      kernel.invoke(deployment, "start", new Object[0], new String[0]);
+      
+      stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      stateful.setState("state");
+      stateful.removeMe();
+   }
+   
+   public void testSmallCache() throws Exception
+   {
+      ConcurrentInvocation[] threads = new ConcurrentInvocation[5];
+      for (int i = 0; i < 5; i++) threads[i] = new ConcurrentInvocation(i);
+      for (int i = 0; i < 5; i++) threads[i].start();
+      for (int i = 0; i < 5; i++) threads[i].join();
+      for (int i = 0; i < 5; i++)
+      {
+         if (threads[i].ex != null)
+         {
+            throw new Exception(threads[i].ex);
+         }
+      }
+   }
+   
+   
+
+   public void testStatefulSynchronization() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      Tester test = (Tester) getInitialContext().lookup("TesterBean/remote");
+      test.testSessionSynchronization();
+
+   }
+   
+   public void testEJBObject() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      StatefulHome home = (StatefulHome)getInitialContext().lookup("StatefulBean/home");
+      assertNotNull(home);
+      javax.ejb.EJBObject stateful = (javax.ejb.EJBObject)home.create(); 
+      assertNotNull(stateful);
+   }
+   
+   public void testStatefulTx() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      StatefulTx stateful = (StatefulTx)getInitialContext().lookup("StatefulTxBean/remote");
+      assertNotNull(stateful);
+      
+      boolean transacted = stateful.isLocalTransacted();
+      assertTrue(transacted);
+      transacted = stateful.isGlobalTransacted();
+      assertFalse(transacted);
+      transacted = stateful.testNewTx();
+      assertTrue(transacted);
+      
+      try
+      {
+         stateful.testTxRollback();
+         fail("should have caught exception");
+      }
+      catch (javax.ejb.EJBException e)
+      {
+      }
+   }
+   
+   public void testTemplateInterfaceTx() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      StatefulTx stateful = (StatefulTx)getInitialContext().lookup("StatefulTxBean/remote");
+      assertNotNull(stateful);
+      
+      try
+      {
+         stateful.testMandatoryTx(new State("test"));
+         fail("should have caught exception");
+      }
+      catch (javax.ejb.EJBTransactionRequiredException e)
+      {
+      }
+   }
+   
+   public void testNotSerialableSFSB() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      stateful.setState("state");
+      String state = stateful.getState();
+      assertEquals("state", state);
+   }
+   
+   public void testSFSBInit() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      StatefulHome home = (StatefulHome)getInitialContext().lookup("StatefulBean/home");
+      assertNotNull(home);
+      ExtendedState state = new ExtendedState("init");
+      Stateful stateful = home.create(state);
+      assertNotNull(stateful);
+      String s = stateful.getState();
+      assertEquals("Extended_init", s);
+   }
+   
+   public void testStackTrace() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      
+      try
+      {
+         stateful.testThrownException();
+         fail("no exception caught");
+      } 
+      catch (Exception e)
+      {
+         StackTraceElement[] stackTrace = e.getStackTrace();
+         assertTrue(stackTrace[stackTrace.length - 1].getClassName().startsWith("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"));
+      }
+   }
+   
+   public void testExceptionCase() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      
+      try
+      {
+         stateful.testExceptionCause();
+         fail("no exception caught");
+      } 
+      catch (Exception e)
+      {
+         Throwable cause = e.getCause();
+         assertNotNull(cause);
+         assertEquals(NullPointerException.class.getName(), cause.getClass().getName());
+      }
+   }
+   
+   public void testRemoteBindingInterceptorStack() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      assertFalse(stateful.interceptorAccessed());
+      assertTrue(RemoteBindingInterceptor.accessed);
+   }
+
+   public void testUninstantiatedPassivation() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      stateful.lookupStateful();
+      Thread.sleep(10 * 1000);
+      stateful.testStateful();
+      
+      stateful.lookupStateful();
+      stateful.testStateful();
+      Thread.sleep(10 * 1000);
+      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)
+         printStats(server);
+      assertEquals(0, inUseConnections);
+   }
+   
+   protected void printStats(MBeanServerConnection server) throws Exception
+   {
+      ObjectName objectName = new ObjectName("jboss.jca:service=CachedConnectionManager");
+      Object[] params = {};
+      String[] sig = {};
+      Map<?, ?> result = (Map<?, ?>)server.invoke(objectName, "listInUseConnections", params, sig);
+      System.out.println(result);
+      
+      objectName = new ObjectName("jboss:service=TransactionManager");
+      long activeTransactions = (Long)server.getAttribute(objectName, "TransactionCount");
+      System.out.println("activeTransactions \n" + activeTransactions);
+      
+      objectName = new ObjectName("jboss.jca:service=ManagedConnectionPool,name=DefaultDS");
+      long inUseConnectionCount = (Long)server.getAttribute(objectName, "InUseConnectionCount");
+      System.out.println("inUseConnectionCount \n" + inUseConnectionCount);
+      
+      long maxConnectionsInUseCount = (Long)server.getAttribute(objectName, "MaxConnectionsInUseCount");
+      System.out.println("maxConnectionsInUseCount \n" + maxConnectionsInUseCount); 
+   }
+   
+   public void testTimeoutRemoval() throws Exception
+   {
+      StatefulTimeout sfsb = (StatefulTimeout)getInitialContext().lookup("StatefulTimeoutBean/remote");
+      sfsb.test();
+      Thread.sleep(5 * 1000);
+      
+      try
+      {
+         sfsb.test();
+         fail("SFSB should have been removed via timeout");
+      } catch (javax.ejb.NoSuchEJBException e)
+      {
+      }
+      
+      sfsb = (StatefulTimeout)getInitialContext().lookup("StatefulTimeoutBean2/remote");
+      sfsb.test();
+      Thread.sleep(10 * 1000);
+      
+      try
+      {
+         sfsb.test();
+         fail("SFSB should have been removed via timeout");
+      } catch (javax.ejb.NoSuchEJBException e)
+      {
+      }
+   }
+   
+   public void testClusteredTimeoutRemoval() throws Exception
+   {
+      StatefulTimeout sfsb = (StatefulTimeout)getInitialContext().lookup("StatefulClusteredTimeoutBean/remote");
+      sfsb.test();
+      Thread.sleep(5 * 1000);
+      
+      try
+      {
+         sfsb.test();
+         fail("SFSB should have been removed via timeout");
+      } catch (javax.ejb.NoSuchEJBException e)
+      {
+      }
+      
+      sfsb = (StatefulTimeout)getInitialContext().lookup("StatefulClusteredTimeoutBean2/remote");
+      sfsb.test();
+      Thread.sleep(10 * 1000);
+      
+      try
+      {
+         sfsb.test();
+         fail("SFSB should have been removed via timeout");
+      } catch (javax.ejb.NoSuchEJBException e)
+      {
+      }
+   }
+   
+   public void testConcurrentClusteredTimeoutRemoval() throws Exception
+   {
+      int numThreads = 100;
+      ConcurrentStatefulTimeoutClient[] clients = new ConcurrentStatefulTimeoutClient[numThreads];
+      for (int i = 0 ; i < numThreads ; ++i)
+      {
+         clients[i] = new ConcurrentStatefulTimeoutClient(i, 3000);
+         clients[i].start();
+      }
+      
+      Thread.sleep(500);
+      ObjectName objectName = new ObjectName("jboss.j2ee:jar=stateful-test.jar,name=StatefulClusteredTimeoutBean,service=EJB3");
+      MBeanServerConnection server = getServer();
+      int size = (Integer)server.getAttribute(objectName, "TotalSize");
+      assertTrue(size > 0);
+      
+      boolean allRemoved = false;
+      while (!allRemoved)
+      {
+         int i = 0;
+         while (i < numThreads && clients[i].removed && clients[i].failure == null)
+            ++i;
+         
+         if (i < numThreads && clients[i].failure != null)
+            throw clients[i].failure;
+         
+         System.out.println("----- removed " + i);
+         
+         if (i == numThreads)
+            allRemoved = true;
+         
+         Thread.sleep(5000);
+      }
+      
+      size = (Integer)server.getAttribute(objectName, "TotalSize");
+      assertEquals(0, size);
+   }
+
+   public void testPassivation() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      System.out.println("testPassivation");
+      Stateless stateless = (Stateless)getInitialContext().lookup("Stateless");
+      stateless.testInjection();
+      
+      ServiceRemote service = (ServiceRemote) getInitialContext().lookup("ServiceBean/remote");
+      service.testInjection();
+      
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      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();
+   }
+   
+   public void testClusteredPassivation() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      System.out.println("testPassivation");
+      Stateless stateless = (Stateless)getInitialContext().lookup("Stateless");
+      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();
+   }
+
+   
+   public void testRemove() throws Exception
+   {
+      SecurityClient client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+      
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      
+      int startingRemoveCount = stateful.beansRemoved();
+      
+      stateful.removeMe(); 
+      try
+      {
+         stateful.getState();
+         fail("Bean should have been removed");
+      } catch (NoSuchEJBException e)
+      {
+         
+      }
+      
+      stateful = (Stateful)getInitialContext().lookup("Stateful");
+      assertNotNull(stateful);
+      stateful.setState("InMyTimeOfDying");
+      
+      stateful.removeMe(); 
+      try
+      {
+         stateful.getState();
+         fail("Bean should have been removed");
+      } catch (NoSuchEJBException e)
+      {
+         
+      }
+      
+      StatefulHome home = (StatefulHome)getInitialContext().lookup("StatefulBean/home");
+      assertNotNull(home);
+      Stateful21 stateful21 = (Stateful21)home.create(); 
+      assertNotNull(stateful21);
+      stateful21.removeMe();
+      
+      try
+      {
+         stateful.getState();
+         fail("Bean should have been removed");
+      } catch (NoSuchEJBException e)
+      {
+         
+      }
+      
+      stateful = (Stateful)getInitialContext().lookup("Stateful");
+      int beansRemoved = stateful.beansRemoved();
+      assertEquals(3, beansRemoved - startingRemoveCount);
+   }
+
+   public void testRemoveWithRollback() throws Exception
+   {
+      Tester test = (Tester) getInitialContext().lookup("TesterBean/remote");
+      test.testRollback1();
+      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);
+      }
+      
+      for (StatefulInvoker invoker: invokers)
+      {
+         invoker.start();
+      }
+      
+      Thread.sleep(10000);
+      
+      for (StatefulInvoker invoker: invokers)
+      {
+         if (invoker.getException() != null)
+            throw invoker.getException();
+      }
+      
+      stateful = (ConcurrentStateful) new InitialContext().lookup("Stateful");
+      
+      invokers = new StatefulInvoker[2];
+      for (int i = 0; i < 2 ; ++i)
+      {
+         invokers[i] = new StatefulInvoker(stateful);
+      }
+      
+      for (StatefulInvoker invoker: invokers)
+      {
+         invoker.start();
+      }
+      
+      Thread.sleep(10000);
+      
+      boolean wasConcurrentException = false;
+      for (StatefulInvoker invoker: invokers)
+      {
+         if (invoker.getException() != null)
+            wasConcurrentException = true;
+      }
+      
+      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);
+      }
+      
+      for (StatefulInvoker invoker: invokers)
+      {
+         invoker.start();
+      }
+      
+      Thread.sleep(5000);
+      
+      boolean wasConcurrentException = false;
+      for (StatefulInvoker invoker: invokers)
+      {
+         if (invoker.getException() != null)
+            wasConcurrentException = true;
+      }
+
+      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);
+      
+   }
+      
+   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);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(RemoteUnitTestCase.class, "stateful-test.jar");
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,385 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.stateful.unit;
+
+import java.rmi.dgc.VMID;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Assert;
+
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Customer;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.NestedXPCMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCart;
+import org.jboss.logging.Logger;
+
+/**
+ * Encapsulates the functions needed for tests of ExtendedPersistenceContext
+ * management by nested SFSBs in a class that can be used either by a 
+ * JBossTestCase subclass or a JBossClusteredTestCase subclass.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class XPCTestRunner extends BaseTestRunner
+{
+   public XPCTestRunner(InitialContext context, Logger log)
+   {
+      super(context, log);
+   }
+
+   public void testBasic() 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());
+      
+      removeBean(cart);
+      removeBean(monitor);
+   }
+   
+   public void testXPCSharing() throws Exception
+   {
+      getLog().debug("Running testXPCSharing()");
+      getLog().debug("==================================");
+      
+      BeanSet beanSet = 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));
+      
+      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());
+      
+      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));
+      
+      // Confirm this survives passivation/activation
+      
+      parent.reset();
+      
+      sleep(getSleepTime());
+      
+      // DeepContained beans ignore replication in their 
+      // activation/passivation counters, so we can test them
+      // to confirm activation/passivation
+      Assert.assertEquals("Local deep contained passivated once", 1,
+                          monitor.getLocalDeepNestedPassivations());
+      Assert.assertEquals("Local deep contained activated once", 1,
+                          monitor.getLocalDeepNestedActivations());
+      Assert.assertEquals("Deep contained passivated once", 1,
+                          monitor.getDeepNestedPassivations());
+      Assert.assertEquals("Deep contained activated once", 1,
+                          monitor.getDeepNestedActivations());
+      
+      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));      
+      
+      removeBean(parent);
+      removeBean(monitor);      
+   }
+   
+   public void testDependentLifecycle()
+   throws Exception
+   {
+      getLog().debug("Running testDependentLifecycle()");
+      getLog().debug("==================================");
+      
+      BeanSet beanSet = 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));
+      
+      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", 
+                         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));
+      
+      // Remove the parent and see that things still work
+      Assert.assertTrue("Parent removed", monitor.removeParent());
+       
+      // Confirm parent is dead
+      Assert.assertFalse("parent.remove() fails", monitor.removeParent());
+      
+      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));
+      
+      // Remove the bottom tier
+      Assert.assertTrue("Local deep nested removed", monitor.removeLocalDeepNested());
+      
+      // Confirm it is dead
+      Assert.assertFalse("localDeepNested.remove() fails", monitor.removeLocalDeepNested());
+      
+      // Confirm other beans still work following remove
+      Assert.assertNotNull("Local nested still works", monitor.findLocalNested(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));
+      
+      // Remove the nested bean
+      Assert.assertTrue("Remote nested removed", monitor.removeNested());
+      
+      // Confirm it is dead
+      Assert.assertFalse("nested.remove() fails", monitor.removeNested());
+      
+      // Confirm other beans still work
+      Assert.assertNotNull("Local nested still works", monitor.findLocalNested(id));
+      Assert.assertNotNull("Remote deep nested still works", monitor.findDeepNested(id));
+      
+      // Remove the local nested bean
+      Assert.assertTrue("Local nested removed", monitor.removeLocalNested());
+      
+      // Confirm it is dead
+      Assert.assertFalse("localNested.remove() fails", monitor.removeLocalNested());
+      
+      // Confirm other beans still work following parent remove
+      Assert.assertNotNull("Deep nested not null", monitor.findDeepNested(id));
+      
+      // Remove the deep nested bean
+      Assert.assertTrue("Deep removed", monitor.removeDeepNested());
+      
+      // Confirm it is dead
+      Assert.assertEquals("Local nested removed", "ERROR", monitor.getDeepNestedId());
+      Assert.assertFalse("deepNested.remove() fails", monitor.removeDeepNested());
+      
+      removeBean(monitor);
+      
+      getLog().debug("ok");
+      
+   }
+
+   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);
+   }
+
+   public BeanSet getBeanSet() throws Exception
+   {
+      // We want a colocated monitor and SFSB to test passivation/destruction
+      // NestedXPCMonitorBean is not clustered, so once we have it's VMID
+      // 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;
+      
+      return result;
+   }
+   
+   public NestedXPCMonitor getXPCMonitor(InitialContext[] ctxs, VMID vmid)
+   throws Exception
+   {
+      NestedXPCMonitor monitor = null;      
+      boolean vmMatch = false;
+      for (int i = 0; i < 10 && !vmMatch; i++)
+      {
+         InitialContext ctx = ctxs[i % ctxs.length];
+         monitor = (NestedXPCMonitor) ctx.lookup("NestedXPCMonitorBean/remote");
+         
+         vmMatch = vmid.equals(monitor.getVMID());
+         addRemovable(monitor);
+         if (!vmMatch)
+            removeBean(monitor);
+      }
+      
+      Assert.assertTrue("SLSB and SFSB in same VM", vmMatch);
+      
+      return monitor;
+   }
+   
+   public static class BeanSet
+   {
+      public ShoppingCart cart;
+      public NestedXPCMonitor monitor;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/ejb3/test/stateful/unit/XPCTestRunner.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/BogusPolicy.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/BogusPolicy.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/BogusPolicy.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession;
+
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+/**
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class BogusPolicy implements LoadBalancePolicy
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   public Object chooseTarget (FamilyClusterInfo clusterFamily)
+   {
+      throw new RuntimeException("Bogus implementation!");
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/BogusPolicy.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessRemote.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessRemote.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessRemote.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,18 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession;
+
+/**
+ * comment
+ *
+ * @author Ben Wang
+ */
+public interface ClusteredStatelessRemote
+{
+   NodeAnswer getNodeState();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessRemote.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessSessionBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessSessionBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessSessionBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * Simple stateless bean
+ *
+ * @author Ben Wang
+ */
+ at Stateless(name="clusteredStateless")
+ at Clustered(loadBalancePolicy = "RoundRobin")
+ at Remote(ClusteredStatelessRemote.class)
+public class ClusteredStatelessSessionBean implements ClusteredStatelessRemote
+{
+   public static final VMID myId = new VMID();
+   
+   public NodeAnswer getNodeState() {
+      return new NodeAnswer(myId, "test");
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ClusteredStatelessSessionBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/IgnoreReplicationStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/IgnoreReplicationStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/IgnoreReplicationStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.clusteredsession;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * Stateful bean that configures clustering via annotations.
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ */
+ at Stateful(name="testIgnoreReplicationStateful")
+ at Clustered
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1, replicationIsPassivation=false)   // this will get evicted the second time eviction thread wakes up
+ at Remote(StatefulRemote.class)
+public class IgnoreReplicationStatefulBean extends NonAnnotationStatefulBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   // Only difference from superclass is the added class-level annotations
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/IgnoreReplicationStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NodeAnswer.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NodeAnswer.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NodeAnswer.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession;
+
+import java.io.Serializable;
+import java.rmi.dgc.VMID;
+
+/** A data class used to track the identity of the cluster node.
+ *
+ * @author Ben Wang
+ */
+public class NodeAnswer implements Serializable
+{
+   public VMID nodeId = null;
+   public Object answer = null;
+
+   public NodeAnswer (VMID node, Object answer)
+   {
+      this.nodeId = node;
+      this.answer = answer;
+   }
+
+   public VMID getNodeId ()
+   {
+      return this.nodeId;
+   }
+
+   public Object getAnswer()
+   {
+      return this.answer;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      boolean same = (this == obj);
+      
+      if (!same && obj instanceof NodeAnswer)
+      {
+         NodeAnswer other = (NodeAnswer) obj;
+         same = this.nodeId.equals(other.nodeId)
+                && this.answer.equals(other.answer);
+      }
+      return same;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = 17;
+      result = result * 29 + nodeId.hashCode();
+      result = result * 29 + answer.hashCode();
+      return result;
+   }
+
+   public String toString ()
+   {
+      return "{ " + this.nodeId + " ; " + this.answer + " }";
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NodeAnswer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NonAnnotationStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NonAnnotationStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NonAnnotationStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession;
+
+import java.rmi.dgc.VMID;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJBException;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remove;
+import javax.interceptor.Interceptors;
+
+import org.jboss.ejb3.test.clusteredsession.util.ExplicitFailoverInterceptor;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+import org.jboss.logging.Logger;
+
+/**
+ * Base class for various configs of a SFSB.  No class-level clustering 
+ * annotations applied so it can serve as a bean class that doesn't use 
+ * annotations, or be subclassed by a bean that adds annotations. 
+ *
+ * @see StatefulBean
+ * 
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * 
+ * @version $Revision$
+ */
+public class NonAnnotationStatefulBean implements java.io.Serializable, StatefulRemote
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   private Logger log = Logger.getLogger(getClass());
+   private int counter = 0;
+   private String state;
+   public static final VMID myId = VMTracker.VMID;
+   public String name;
+
+   private int postActivateCalled = 0;
+   private int prePassivateCalled = 0;
+
+   public int increment()
+   {
+      System.out.println("INCREMENT - counter: " + (counter++));
+      return counter;
+   }
+
+   public String getHostAddress()
+   {
+      return System.getProperty("jboss.bind.address");
+   }
+
+   /**
+    * Sleep to test
+    * @throws Exception
+    */
+   public void longRunning() throws Exception
+   {
+      log.debug("+++ longRunning() enter ");
+      Thread.sleep(20000); // 20000 will break the passivation test now.
+      log.debug("+++ longRunning() leave ");
+   }
+
+   public int getPostActivate()
+   {
+      return postActivateCalled;
+   }
+
+   public int getPrePassivate()
+   {
+      return prePassivateCalled;
+   }
+
+   public void setState(String state)
+   {
+      this.state = state;
+   }
+
+   public String getState()
+   {
+      log.debug("getState(): entering ...");
+      return this.state;
+   }
+
+   public void reset()
+   {
+      state = null;
+      postActivateCalled = 0;
+      prePassivateCalled = 0;
+   }
+
+   public void resetActivationCounter() 
+   {
+      postActivateCalled = 0;
+      prePassivateCalled = 0;
+   }
+
+   @PostActivate
+   public void postActivate()
+   {
+      postActivateCalled++;
+      log.debug("Activate. My ID: " + myId + " name: " + this.name);
+   }
+
+   @PrePassivate
+   public void prePassivate()
+   {
+      prePassivateCalled++;
+      log.debug("Passivate. My ID: " + myId + " name: " + this.name);
+   }
+
+   @Remove
+   public void remove()
+   {
+   }
+
+   @PostConstruct
+   public void ejbCreate()
+   {
+      log.debug("My ID: " + myId);
+   }
+
+   // Remote Interface implementation ----------------------------------------------
+   
+   // Mimic explict failover
+   @Interceptors({ExplicitFailoverInterceptor.class})
+   public NodeAnswer getNodeState()
+   {
+      NodeAnswer state = new NodeAnswer(myId, this.name);
+      log.debug("getNodeState, " + state);
+      return state;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+      log.debug("Name set to " + name);
+   }
+
+   public void setNameOnlyOnNode(String name, VMID node)
+   {
+      if (node.equals(myId))
+         this.setName(name);
+      else
+         throw new EJBException("Trying to assign value on node " + myId + " but this node expected: " + node);
+   }
+
+   public void setUpFailover(String failover) {
+      // To setup the failover property
+      log.debug("Setting up failover property: " +failover);
+      System.setProperty ("JBossCluster-DoFail", failover);
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/NonAnnotationStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OptimizedStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OptimizedStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OptimizedStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.clusteredsession;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.cache.Optimized;
+
+/**
+ * Stateful bean that configures clustering via annotations.
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ */
+ at Stateful(name="testOptimizedStateful")
+ at Clustered
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1)   // this will get evicted the second time eviction thread wakes up
+ at Remote(StatefulRemote.class)
+public class OptimizedStatefulBean 
+   extends NonAnnotationStatefulBean
+   implements Optimized
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private boolean modified = true;
+   
+   public boolean isModified()
+   {
+      boolean answer = modified;
+      modified = true;
+      return answer;
+   }
+
+   @Override
+   public int getPostActivate()
+   {
+      modified = false;
+      return super.getPostActivate();
+   }
+
+   @Override
+   public int getPrePassivate()
+   {
+      modified = false;
+      return super.getPrePassivate();
+   }
+
+   @Override
+   public void resetActivationCounter()
+   {
+      modified = false;
+      super.resetActivationCounter();
+   }
+   
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OptimizedStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideAnnotationStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideAnnotationStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideAnnotationStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * SFSB whose clustering annotations are overridden in xml.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+ at Stateful(name="OverrideAnnotationStateful")
+ at Clustered(partition="BogusPartition")
+ at Remote(StatefulRemote.class)
+public class OverrideAnnotationStatefulBean extends NonAnnotationStatefulBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideAnnotationStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.logging.Logger;
+
+/**
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful(name="OverrideStateful")
+ at Clustered(partition="BogusPartition", loadBalancePolicy="BogusPolicy")
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=2)
+ at Remote(OverrideStatefulRemote.class)
+public class OverrideStatefulBean implements OverrideStatefulRemote
+{
+   private static final Logger log = Logger.getLogger(OverrideStatefulBean.class);
+   
+   private int state = 0;
+
+   public int increment()
+   {
+      log.info("INCREMENT - counter: " + (state++));
+      return state;
+   }
+   
+   public String getHostAddress()
+   {
+      return System.getProperty("jboss.bind.address");
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulRemote.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulRemote.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulRemote.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession;
+
+/**
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface OverrideStatefulRemote
+{
+   int increment();
+   String getHostAddress();
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/OverrideStatefulRemote.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.clusteredsession;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * Stateful bean that configures clustering via annotations.
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ */
+ at Stateful(name="testStateful")
+ at Clustered
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=3)   // this will get evicted the second time eviction thread wakes up
+ at Remote(StatefulRemote.class)
+public class StatefulBean extends NonAnnotationStatefulBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   // Only difference from superclass is the added class-level annotations
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulRemote.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulRemote.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulRemote.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession;
+
+import java.rmi.dgc.VMID;
+
+/**
+ * Comment
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ */
+public interface StatefulRemote
+{
+   int increment();
+   String getHostAddress();
+
+   int getPostActivate();
+
+   int getPrePassivate();
+
+   void setState(String state);
+
+   String getState();
+
+   void reset();
+
+   void resetActivationCounter();
+
+   void longRunning() throws Exception;
+
+   void remove();
+
+   public NodeAnswer getNodeState();
+
+   public void setName(String name);
+
+   public void setNameOnlyOnNode(String name, VMID node);
+
+   public void setUpFailover(String failover);
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/StatefulRemote.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTester.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTester.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTester.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.islocal;
+
+import java.rmi.dgc.VMID;
+
+import javax.naming.NamingException;
+
+/**
+ * Provides access to a static VMID field and ability to
+ * download a remote proxy and check the VMID of its bean.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface VMTester
+{
+   public static final VMID VMID = new VMID();
+   
+   VMID getVMID();
+   
+   VMID getCreatorVMID();
+   
+   VMID getVMIDFromRemote(VMTester remote) throws NamingException;
+   
+   VMID getVMIDFromRemoteLookup(String jndiURL, String name) throws NamingException;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTester.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterBase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterBase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterBase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.islocal;
+
+import java.rmi.dgc.VMID;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author Brian Stansberry
+ */
+public class VMTesterBase
+{
+   private static final Logger log = Logger.getLogger(VMTesterBase.class);
+   
+   private final VMID creatorVMID = VMTester.VMID;
+   
+   public VMID getVMID()
+   {
+      log.debug("Ignore; just a stack trace", new Exception("Ignore; just a stack trace"));
+      return VMTester.VMID;
+   }
+   
+   public VMID getCreatorVMID()
+   {
+      return creatorVMID;
+   }
+
+   public VMID getVMIDFromRemoteLookup(String jndiURL, String name)
+   throws NamingException
+   {
+      log.info("Looking up " + jndiURL + "/" + name);
+      Properties env = new Properties();
+      env.setProperty(Context.PROVIDER_URL, jndiURL);
+      env.setProperty("jnp.disableDiscovery", "true");
+      InitialContext ctx = new InitialContext(env);
+      VMTester tester = (VMTester) ctx.lookup(name);
+      return tester.getVMID();
+   }
+   
+   public VMID getVMIDFromRemote(VMTester remote)
+   {
+      return remote.getVMID();
+   }
+
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterBase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.islocal;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+/**
+ * @author Brian Stansberry
+ */
+ at Stateful
+ at Remote(VMTester.class)
+public class VMTesterStatefulBean extends VMTesterBase implements VMTester
+{
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatelessBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatelessBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatelessBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.islocal;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * @author Brian Stansberry
+ */
+ at Stateless
+ at Remote(VMTester.class)
+public class VMTesterStatelessBean extends VMTesterBase implements VMTester
+{
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/islocal/VMTesterStatelessBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/ClusteredDeepNestedStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/ClusteredDeepNestedStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/ClusteredDeepNestedStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested.base;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStatefulBean;
+
+/**
+ * A ClusteredDeepNestedStatefulBean.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Stateful(name="testDeepNestedStateful")
+ at Clustered
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1, replicationIsPassivation=false) 
+ at Local(DeepNestedStateful.class)
+public class ClusteredDeepNestedStatefulBean extends DeepNestedStatefulBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/ClusteredDeepNestedStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredLocalNestedStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredLocalNestedStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredLocalNestedStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested.base.std;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStatefulBean;
+
+/**
+ * Nested SFSB with only a local interface.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * 
+ * @version $Revision$
+ */
+ at Clustered
+ at Stateful(name="testLocalNestedStateful")
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1) 
+ at Local(NestedStateful.class)
+public class ClusteredLocalNestedStatefulBean extends NestedStatefulBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   public VMID getVMID()
+   {
+      return VMTracker.VMID;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredLocalNestedStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredParentStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredParentStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredParentStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested.base.std;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.test.clusteredsession.util.ExplicitFailoverInterceptor;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulBean;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulRemote;
+
+/**
+ * Parent SFSB that contains nested SFSB.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+ at Clustered
+ at Stateful(name="testParentStateful")
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1)   // this will get evicted the second time eviction thread wakes up
+ at Remote(ParentStatefulRemote.class)
+public class ClusteredParentStatefulBean extends ParentStatefulBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   // Mimic explict failover
+   @Interceptors({ExplicitFailoverInterceptor.class})
+   public VMID getVMID()
+   {
+      return super.getVMID();
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredParentStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredRemoteNestedStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredRemoteNestedStatefulBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredRemoteNestedStatefulBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested.base.std;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.OptimizedNestedStatefulBean;
+
+/**
+ * Nested SFSB with a remote interface.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * 
+ * @version $Revision$
+ */
+ at Clustered
+ at Stateful(name="testNestedStateful")
+ at CacheConfig(maxSize=1000, idleTimeoutSeconds=1)
+ at Remote(NestedStateful.class)
+public class ClusteredRemoteNestedStatefulBean extends OptimizedNestedStatefulBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   public VMID getVMID()
+   {
+      return VMTracker.VMID;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/std/ClusteredRemoteNestedStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredDeepNestedContainedBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredDeepNestedContainedBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredDeepNestedContainedBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested.base.xpc;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.DeepNestedContained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.DeepNestedContainedBean;
+
+/**
+ * A ClusteredDeepNestedStatefulBean.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Stateful(name="testDeepNestedContained")
+ at Clustered
+ at CacheConfig(maxSize=10000, idleTimeoutSeconds=1, replicationIsPassivation=false) 
+ at Local(DeepNestedContained.class)
+public class ClusteredDeepNestedContainedBean extends DeepNestedContainedBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredDeepNestedContainedBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredLocalContainedBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredLocalContainedBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredLocalContainedBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested.base.xpc;
+
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Contained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ContainedBean;
+
+/**
+ * ContainedBean bean meant for testing with a clustered SFSB cache.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Stateful(name="testLocalShoppingCartContained")
+ at Clustered
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+ at Local(Contained.class)
+public class ClusteredLocalContainedBean extends ContainedBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredLocalContainedBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredRemoteContainedBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredRemoteContainedBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredRemoteContainedBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested.base.xpc;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Contained;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ContainedBean;
+
+/**
+ * ContainedBean bean meant for testing with a clustered SFSB cache.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Stateful(name="testShoppingCartContained")
+ at Clustered
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+ at Remote(Contained.class)
+public class ClusteredRemoteContainedBean extends ContainedBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredRemoteContainedBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredShoppingCartBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredShoppingCartBean.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredShoppingCartBean.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.nested.base.xpc;
+
+import java.rmi.dgc.VMID;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.test.clusteredsession.util.ExplicitFailoverInterceptor;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCart;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCartBean;
+
+/**
+ * ShoppingCartBean subclass for testing with a clustered SFSB cache.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Stateful(name="testShoppingCart")
+ at Remote(ShoppingCart.class)
+ at Clustered
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
+public class ClusteredShoppingCartBean extends ShoppingCartBean
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   // Mimic explict failover
+   @Interceptors({ExplicitFailoverInterceptor.class})
+   public VMID getVMID()
+   {
+      return super.getVMID();
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/nested/base/xpc/ClusteredShoppingCartBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/BeanUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/BeanUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/BeanUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,279 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Date;
+import java.util.Properties;
+
+import junit.framework.Test;
+import org.jboss.ejb3.test.clusteredsession.StatefulRemote;
+import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
+
+/**
+ * Test SFSB for load-balancing and failover behaviour
+ *
+ * @author  Ben.Wang at jboss.org
+ * @author  Brian Stansberry
+ * @version $Revision$
+ */
+public class BeanUnitTestCase extends JBossClusteredTestCase
+{
+   static boolean deployed = false;
+   public static int test = 0;
+   static Date startDate = new Date();
+
+   protected final String namingFactory =
+   System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+
+   protected final String providerURL =
+   System.getProperty(Context.PROVIDER_URL);
+
+   public BeanUnitTestCase (String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      final String jarName = "clusteredsession-test.jar";
+      Test t1 = JBossClusteredTestCase.getDeploySetup(BeanUnitTestCase.class,
+              jarName);
+      return t1;
+   }
+
+   protected InitialContext getInitialContext(int node) throws Exception {
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[node]);
+      return new InitialContext(env1);
+   }
+
+   public void testBasic()
+   throws Exception
+   {
+      basicTest("testStateful/remote");
+   }
+
+   public void testBasicWithoutAnnotation()
+   throws Exception
+   {
+      basicTest("NonAnnotationStateful/remote");
+   }
+
+   public void testBasicWithXMLOverride()
+   throws Exception
+   {
+      basicTest("OverrideAnnotationStateful/remote");
+   }
+
+   public void testBasicWithEjbJarXMLOverride()
+   throws Exception
+   {
+      basicTest("EjbJarOverrideAnnotationStateful/remote");
+   }
+   
+   private void basicTest(String jndiBinding) throws Exception
+   {
+      getLog().debug(++org.jboss.ejb3.test.clusteredsession.unit.BeanUnitTestCase.test +"- "
+              +"Trying the context...");
+
+      // Connect to the server0 JNDI
+      InitialContext ctx = getInitialContext(0);
+
+      getLog().debug("Basic Test with " + jndiBinding);
+      getLog().debug("==================================");
+      getLog().debug(++org.jboss.ejb3.test.clusteredsession.unit.BeanUnitTestCase.test +"- "
+            +"Looking up " + jndiBinding + "...");
+      StatefulRemote stateful = (StatefulRemote) ctx.lookup(jndiBinding);
+
+      stateful.setName("The Code");
+      _sleep(300);
+
+      NodeAnswer node1 = stateful.getNodeState ();
+      getLog ().debug ("Node 1 ID: " +node1);
+
+      assertEquals("Counter: ", 1, stateful.increment());
+      assertEquals("Counter: ", 2, stateful.increment());
+
+      stateful.remove();
+      getLog().debug("ok");
+   }
+
+   public void testStatefulBeanCounterFailover()
+   throws Exception
+   {
+      statefulBeanCounterFailoverTest("testStateful/remote");
+   }
+
+   public void testStatefulBeanCounterFailoverWithoutAnnotation()
+   throws Exception
+   {
+      statefulBeanCounterFailoverTest("NonAnnotationStateful/remote");
+   }
+
+   public void testStatefulBeanCounterFailoverWithXMLOverride()
+   throws Exception
+   {
+      statefulBeanCounterFailoverTest("OverrideAnnotationStateful/remote");
+   }
+
+   public void testStatefulBeanCounterFailoverWithEjbJarXMLOverride()
+   throws Exception
+   {
+      statefulBeanCounterFailoverTest("EjbJarOverrideAnnotationStateful/remote");
+   }
+   
+   private void statefulBeanCounterFailoverTest(String jndiBinding) 
+   throws Exception
+   {  
+      getLog().debug(++org.jboss.ejb3.test.clusteredsession.unit.BeanUnitTestCase.test +"- "+"Trying the context...");
+
+      // Connect to the server0 JNDI
+      InitialContext ctx = getInitialContext(0);
+
+      getLog().debug("Test Stateful Bean Counter Failover with " + jndiBinding);
+      getLog().debug("=========================================================");
+      getLog().debug(++org.jboss.ejb3.test.clusteredsession.unit.BeanUnitTestCase.test +"- "
+              +"Looking up " + jndiBinding + "...");
+      StatefulRemote stateful = (StatefulRemote) ctx.lookup(jndiBinding);
+
+      stateful.setName("The Code");
+      NodeAnswer node1 = stateful.getNodeState ();
+      getLog ().debug ("Node 1 ID: " +node1);
+
+      assertEquals("Counter: ", 1, stateful.increment());
+      assertEquals("Counter: ", 2, stateful.increment());
+      _sleep(300);
+
+      // Now we switch to the other node, simulating a failure on node 1
+      //
+      stateful.setUpFailover("once");
+      NodeAnswer node2 = stateful.getNodeState ();
+      assertNotNull("State node: ", node2);
+      getLog ().debug ("Node 2 ID : " +node2);
+
+      assertFalse("Failover has occured", node1.nodeId.equals(node2.nodeId));
+
+      assertEquals ("Node 1: ", "The Code", node1.answer);
+      assertEquals ("Node 2: ", "The Code", node2.answer);
+
+      assertEquals("Counter: ", 3, stateful.increment());
+      assertEquals("Counter: ", 4, stateful.increment());
+
+      stateful.remove();
+      getLog().debug("ok");
+   }
+
+   public void testStatefulBeanFailover()
+   throws Exception
+   {
+      statefulBeanFailoverTest("testStateful/remote");
+   }
+
+   public void testStatefulBeanFailoverWithoutAnnotation()
+   throws Exception
+   {
+      statefulBeanFailoverTest("NonAnnotationStateful/remote");
+   }
+
+   public void testStatefulBeanFailoverWithXMLOverride()
+   throws Exception
+   {
+      statefulBeanFailoverTest("OverrideAnnotationStateful/remote");
+   }
+
+   public void testStatefulBeanFailoverWithEjbJarXMLOverride()
+   throws Exception
+   {
+      statefulBeanFailoverTest("EjbJarOverrideAnnotationStateful/remote");
+   }
+   
+   private void statefulBeanFailoverTest(String jndiBinding) 
+   throws Exception
+   {  
+      getLog().debug(++org.jboss.ejb3.test.clusteredsession.unit.BeanUnitTestCase.test +"- "+"Trying the context...");
+
+      // Connect to the server0 JNDI
+      InitialContext ctx = getInitialContext(0);
+
+      getLog().debug("Test Stateful Bean Failover with " + jndiBinding);
+      getLog().debug("================================================");
+      getLog().debug(++org.jboss.ejb3.test.clusteredsession.unit.BeanUnitTestCase.test +"- "
+            +"Looking up " + jndiBinding + "...");
+      StatefulRemote stateful = (StatefulRemote) ctx.lookup(jndiBinding);
+
+      stateful.setName("Bupple-Dupple");
+      _sleep(300);
+
+      NodeAnswer node1 = stateful.getNodeState ();
+      getLog ().debug ("Node 1 ID: " +node1);
+
+      // Now we switch to the other node, simulating a failure on node 1
+      //
+      stateful.setUpFailover("once");
+      NodeAnswer node2 = stateful.getNodeState ();
+      assertNotNull("State node: ", node2);
+      getLog ().debug ("Node 2 ID : " +node2);
+
+      assertFalse("Failover has occured", node1.nodeId.equals(node2.nodeId));
+
+      assertEquals ("Node 1: ", "Bupple-Dupple", node1.answer);
+      assertEquals ("Node 2: ", "Bupple-Dupple", node2.answer);
+
+      // we change our name to see if it replicates to node 1
+      //
+      stateful.setName ("Changed");
+      _sleep(300);
+
+      // now we travel back on node 1
+      //
+      stateful.setUpFailover("once");
+      node1 = stateful.getNodeState ();
+      assertNotNull("State node id should not be null: ", node1.nodeId);
+      getLog ().debug (node1);
+
+      _sleep(300);
+      assertFalse("Failover has occurred", node1.nodeId.equals(node2.nodeId));
+
+      assertEquals ("Value is identical on replicated node", "Changed", node1.answer );
+
+      stateful.remove();
+      getLog().debug("ok");
+   }
+
+   protected void _sleep(long time)
+   {
+      try {
+         Thread.sleep(time);
+      } catch (InterruptedException e) {
+         e.printStackTrace();
+      }
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/BeanUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ExtendedPersistenceUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ExtendedPersistenceUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ExtendedPersistenceUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,253 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import java.rmi.dgc.VMID;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.ejb3.test.common.unit.DBSetup;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.Customer;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.NestedXPCMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.xpc.ShoppingCart;
+import org.jboss.ejb3.test.stateful.unit.XPCTestRunner;
+import org.jboss.ejb3.test.stateful.unit.XPCTestRunner.BeanSet;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Tests for ExtendedPersistenceContext management.
+ * 
+ * This class uses a delegate to execute the tests so the clustered
+ * version of the tests (which derive from a different base class)
+ * can use the same delegate code.
+ *
+ * @author Ben Wang
+ * @version $Id$
+ */
+public class ExtendedPersistenceUnitTestCase 
+   extends JBossClusteredTestCase
+{
+   private XPCTestRunner runner;
+   
+   public ExtendedPersistenceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      TestSuite suite = new TestSuite();
+      Test t1 = getDeploySetup(ExtendedPersistenceUnitTestCase.class,
+                               "clusteredsession-ds.xml, clusteredsession-xpc.jar");
+
+      suite.addTest(t1);
+
+      // Create an initializer for the test suite
+      DBSetup wrapper = new DBSetup(suite);
+      return wrapper;     
+   }
+
+   
+   @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);
+   }
+
+   private InitialContext getInitialContext(int node) throws Exception {
+      // Connect to the serverX JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[node]);
+      return new InitialContext(env1);
+   }
+
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      if (runner != null)
+         runner.tearDown();
+   }
+
+
+   public void testBasic() throws Exception
+   {
+      runner.testBasic();
+   }
+   
+   public void testDependentLifecycle() throws Exception
+   {
+      runner.testDependentLifecycle();
+   }
+   
+   public void testXPCSharing() throws Exception
+   {
+      runner.testXPCSharing();
+   }
+
+   public void testPassivation() throws Exception
+   {
+      runner.testPassivation();
+   }
+   
+   public void testFailover() throws Exception
+   {
+      failoverTest(false, false, false);
+   }
+   
+   public void testRepeatedFailover() throws Exception
+   {
+      failoverTest(false, false, true);
+   }
+   
+   public void testFailoverWithPassivation() throws Exception
+   {
+      failoverTest(true, false, false);
+   }
+   
+   public void testRepeatedFailoverWithPassivation() throws Exception
+   {
+      failoverTest(true, true, true);
+   }
+   
+   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];
+         ctxs[1] = ctxs[0];
+         ctxs[0] = ctx;
+         
+         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));
+         
+      }  
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ExtendedPersistenceUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ForeignPartitionLocalInterceptorUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ForeignPartitionLocalInterceptorUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ForeignPartitionLocalInterceptorUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+/**
+ * @author Brian Stansberry
+ */
+public class ForeignPartitionLocalInterceptorUnitTestCase extends InvokeLocalTestBase
+{
+   private static final String PARTITION_NAME_VALUE = "Ejb3IsLocalTestPartition";
+   
+   private static boolean deployed0 = false;
+   private static boolean deployed1 = false;
+   
+   /**
+    * @param name
+    */
+   public ForeignPartitionLocalInterceptorUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(ForeignPartitionLocalInterceptorUnitTestCase.class,
+                           "testlocal-jboss-beans.xml");
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      cleanDeployments();
+      
+      deployJars();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      cleanDeployments();      
+   }
+   
+   @Override
+   protected String getPartitionName()
+   {
+      return PARTITION_NAME_VALUE;
+   }
+   
+   public void testClusteredStatefulGoesRemote() throws Exception
+   {
+      stayLocalTest("ClusteredStatefulRemote", false, false);
+   }
+   
+   public void testClusteredStatelessGoesRemote() throws Exception
+   {
+      stayLocalTest("ClusteredStatelessRemote", false, false);      
+   }
+   
+   public void testNonClusteredStatefulGoesRemote() throws Exception
+   {
+      stayLocalTest("NonClusteredStatefulRemote", false, false);      
+   }
+   
+   public void testNonClusteredStatelessGoesRemote() throws Exception
+   {
+      stayLocalTest("NonClusteredStatelessRemote", false, false);    
+   }
+
+   private void cleanDeployments() throws Exception
+   {
+      MBeanServerConnection[] adaptors = getAdaptors();
+      
+      if (deployed0)
+      {
+         undeploy(adaptors[0], "clusteredsession-local.jar");
+         deployed0 = false;
+      }
+      
+      if (deployed1)
+      {
+         undeploy(adaptors[1], "clusteredsession-local.jar");
+         deployed1 = false;
+      }
+   }
+   
+   private void deployJars() throws Exception
+   {
+      MBeanServerConnection[] adaptors = getAdaptors();
+      
+      deploy(adaptors[0], "clusteredsession-local.jar");
+      deployed0 = true;
+      
+      
+      deploy(adaptors[1], "clusteredsession-local.jar");
+      deployed1 = true;      
+   }
+   
+   
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ForeignPartitionLocalInterceptorUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/InvokeLocalTestBase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/InvokeLocalTestBase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/InvokeLocalTestBase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import java.rmi.dgc.VMID;
+import java.util.Properties;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.test.clusteredsession.islocal.VMTester;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * @author Brian Stansberry
+ */
+public abstract class InvokeLocalTestBase extends JBossClusteredTestCase
+{
+   public static final String TESTER_JNDI_NAME = "NonClusteredStatelessRemote";
+   private static final String PROPERTIES_SERVICE = "jboss:type=Service,name=SystemProperties";
+   private static final String PARTITION_NAME_PROPERTY = "clusteredsession.islocal.partition";
+   
+   
+   public InvokeLocalTestBase(String name)
+   {
+      super(name);
+   }
+
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      MBeanServerConnection[] adaptors = getAdaptors();
+      setPartitionName(adaptors[0], "DefaultPartition");
+      setPartitionName(adaptors[1], getPartitionName());
+   }
+
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      MBeanServerConnection[] adaptors = getAdaptors();
+      clearPartitionName(adaptors[0]);
+      clearPartitionName(adaptors[1]);
+   }
+
+
+   protected void stayLocalTest(String jndiName, boolean expectLocal, boolean expectLocalViaLookup)
+      throws Exception
+   {
+      String[] jndiURLs = getNamingURLs();
+      
+      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);
+      
+      if (expectLocal)
+         assertEquals("Call stayed local", local, passThroughID);
+      else
+         assertFalse("Call went remote", local.equals(passThroughID));
+      
+      // Tell the server to look up a proxy from node1 and invoke getVMID() on it
+      passThroughID = tester.getVMIDFromRemoteLookup(jndiURLs[1], jndiName);
+      assertNotNull("Got the remote VMID", passThroughID);
+      
+      if (expectLocalViaLookup)
+         assertEquals("Call stayed local", local, passThroughID);
+      else
+         assertFalse("Call went remote", local.equals(passThroughID));
+   }
+   
+   protected abstract String getPartitionName();
+   
+   private void setPartitionName(MBeanServerConnection adaptor, String partitionName) throws Exception
+   {
+      Object[] args = { PARTITION_NAME_PROPERTY, partitionName };
+      String[] sig = { String.class.getName(), String.class.getName() };
+      adaptor.invoke(new ObjectName(PROPERTIES_SERVICE), "set", args, sig);
+   }
+   
+   private void clearPartitionName(MBeanServerConnection adaptor) throws Exception
+   {
+      setPartitionName(adaptor, "DefaultPartition");
+      Object[] args = { PARTITION_NAME_PROPERTY };
+      String[] sig = { String.class.getName() };
+      adaptor.invoke(new ObjectName(PROPERTIES_SERVICE), "remove", args, sig);
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/InvokeLocalTestBase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/NestedBeanUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/NestedBeanUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/NestedBeanUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import java.rmi.dgc.VMID;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulRemote;
+import org.jboss.ejb3.test.stateful.unit.NestedBeanTestRunner;
+import org.jboss.ejb3.test.stateful.unit.NestedBeanTestRunner.NestedBeanSet;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Overrides the parent test to use clustered versions of
+ * the beans.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class NestedBeanUnitTestCase 
+   extends JBossClusteredTestCase
+{
+   private NestedBeanTestRunner runner;
+   
+   
+   public NestedBeanUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(NestedBeanUnitTestCase.class,
+                            "clusteredsession-nested.jar");
+   }
+   
+   
+   @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);
+      // For clustered beans, passivation occurs after already called
+      // @PrePassivate for replication, so don't get a 2nd event
+      runner.setPassivationPerSleep(0);
+   }
+
+   private InitialContext getInitialContext(int node) throws Exception {
+      // Connect to the serverX JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[node]);
+      return new InitialContext(env1);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      if (runner != null)
+         runner.tearDown();
+   }
+
+   public void testBasic()
+   throws Exception
+   {
+      runner.testBasic();
+   }
+   
+   public void testDependentLifecycle()
+   throws Exception
+   {
+      runner.testDependentLifecycle();      
+   }
+
+   public void testStatefulPassivation()
+   throws Exception
+   {
+      runner.testStatefulPassivation();
+   }
+
+
+   public void testStatefulBeanCounterFailoverWithRemote()
+   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);
+
+      assertEquals("Counter: ", 1, stateful.increment());
+      assertEquals("Counter: ", 2, stateful.increment());
+      sleep(300);
+
+      // Now we switch to the other node, simulating a failure on node 1
+      stateful.setUpFailover("once");
+      VMID node2 = stateful.getVMID();
+      assertNotNull("State node: ", node2);
+      getLog ().debug ("Node 2 ID : " +node2);
+
+      assertFalse("Failover has occured", node1.equals(node2));
+
+      assertEquals("Counter: ", 3, stateful.increment());
+      assertEquals("Counter: ", 4, stateful.increment());
+
+      runner.removeBean(stateful);
+      getLog().debug("ok");
+   }
+
+
+   public void testStatefulBeanCounterFailover()
+   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);
+
+      assertEquals("Counter: ", 1, stateful.incrementLocal());
+      assertEquals("Counter: ", 2, stateful.incrementLocal());
+      sleep(300);
+
+      // Now we switch to the other node, simulating a failure on node 1
+      stateful.setUpFailover("once");
+      VMID node2 = stateful.getVMID();
+      assertNotNull("State node: ", node2);
+      getLog ().debug ("Node 2 ID : " +node2);
+
+      assertFalse("Failover has occured", node1.equals(node2));
+
+      assertEquals("Counter: ", 3, stateful.incrementLocal());
+      assertEquals("Counter: ", 4, stateful.incrementLocal());
+
+      runner.removeBean(stateful);
+      getLog().debug("ok");
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/NestedBeanUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/PassivationUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/PassivationUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/PassivationUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.ejb3.test.clusteredsession.StatefulRemote;
+import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Date;
+import java.util.Properties;
+
+import junit.framework.Test;
+
+/**
+ * Test SFSB for load-balancing and failover behaviour
+ *
+ * TODO add a test with a bean configured to not treat replication as
+ * passivation
+ * 
+ * @author  Ben.Wang at jboss.org
+ * @version $Revision$
+ */
+public class PassivationUnitTestCase extends JBossClusteredTestCase
+{
+   static boolean deployed = false;
+   public static int test = 0;
+   static Date startDate = new Date();
+
+   protected final String namingFactory =
+   System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+
+   protected final String providerURL =
+   System.getProperty(Context.PROVIDER_URL);
+
+   public PassivationUnitTestCase (String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      final String jarName = "clusteredsession-test.jar";
+      Test t1 = JBossClusteredTestCase.getDeploySetup(PassivationUnitTestCase.class,
+              jarName);
+      return t1;
+   }
+
+   protected InitialContext getInitialContext(int node) throws Exception {
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[node]);
+      return new InitialContext(env1);
+   }
+
+   /**
+    */
+   public void testStatefulPassivation()
+      throws Exception
+   {
+      log.info("+++ testStatefulPassivation");
+
+      // Connect to the server0 JNDI
+      InitialContext ctx = getInitialContext(0);
+
+      getLog().debug("==================================");
+      getLog().debug(++PassivationUnitTestCase.test +"- "
+              +"Looking up testStateful...");
+      StatefulRemote remote = (StatefulRemote) ctx.lookup("testStateful/remote");
+
+      int invCount = 0;
+      
+      remote.reset();
+      invCount++;
+      remote.setState("hello");
+      invCount++;
+      
+      sleep_(11100);
+      
+      assertEquals("hello", remote.getState());
+      invCount++;
+      
+      assertEquals(invCount, remote.getPrePassivate());
+      invCount++;
+      
+      assertEquals(invCount, remote.getPostActivate());
+
+      remote.remove();
+
+   }
+
+   /**
+    * Tests that @CacheConfig.replicationIsPassivation=false works.
+    */
+   public void testIgnoreReplicationStatefulPassivation()
+      throws Exception
+   {
+      log.info("+++ testIgnoreReplicationStatefulPassivation");
+
+      // Connect to the server0 JNDI
+      InitialContext ctx = getInitialContext(0);
+
+      getLog().debug("==================================");
+      getLog().debug(++PassivationUnitTestCase.test +"- "
+              +"Looking up testIgnoreReplicationStateful...");
+      StatefulRemote remote = (StatefulRemote) ctx.lookup("testIgnoreReplicationStateful/remote");
+
+      remote.reset();
+      remote.setState("hello");
+      
+      sleep_(11100);
+      
+      assertEquals("hello", remote.getState());      
+      assertEquals("@PrePassivate count correct", 1, remote.getPrePassivate());
+      assertEquals("@PostActivate count correct", 1, remote.getPostActivate());
+
+      remote.remove();
+   }
+   
+   /**
+    * Tests that disabling replication via implementing Optimized works.
+    */
+   public void testOptimizedDisablesReplication()
+      throws Exception
+   {
+      log.info("+++ testOptimizedDisablesReplication");
+
+      // Connect to the server0 JNDI
+      InitialContext ctx = getInitialContext(0);
+
+      getLog().debug("==================================");
+      getLog().debug(++PassivationUnitTestCase.test +"- "
+              +"Looking up testOptimizedStateful...");
+      StatefulRemote remote = (StatefulRemote) ctx.lookup("testOptimizedStateful/remote");
+
+      int invCount = 0;
+      remote.reset();
+      invCount++;
+      remote.setState("hello");
+      invCount++;
+      
+      sleep_(10100);
+      
+      assertEquals("hello", remote.getState());
+      invCount++;
+      
+      // Don't include the regular passivation in the count
+      // since there won't be an event following replication
+      assertEquals(invCount, remote.getPrePassivate());
+      // don't increment count
+      assertEquals(invCount, remote.getPostActivate());
+      // don't increment count
+      // Check that getPostActivate() didn't cause replication
+      assertEquals(invCount, remote.getPrePassivate());
+      
+      remote.remove();
+   }
+
+   /** This is to test failover with passivation
+    */
+   public void testFailoverStatefulPassivation()
+      throws Exception
+   {
+      log.info("+++ testFiloverStatefulPassivation");
+
+      // Connect to the server0 JNDI
+      InitialContext ctx = getInitialContext(0);
+
+      getLog().debug("==================================");
+      getLog().debug(++PassivationUnitTestCase.test +"- "
+              +"Looking up testStateful...");
+      StatefulRemote stateful = (StatefulRemote) ctx.lookup("testStateful/remote");
+
+      stateful.reset();
+      
+      stateful.setName("The Code");
+      NodeAnswer node1 = stateful.getNodeState();
+      getLog ().debug ("Node 1 ID: " +node1);
+
+      assertEquals("Counter: ", 1, stateful.increment());
+      assertEquals("Counter: ", 2, stateful.increment());
+      
+      sleep_(10100);
+
+      // Now we switch to the other node, simulating a failure on node 1
+      stateful.setUpFailover("once");
+      NodeAnswer node2 = stateful.getNodeState();
+      assertNotNull("State node: ", node2);
+      getLog ().debug ("Node 2 ID : " +node2);
+
+      assertNotSame ("No failover has occured!", node1.nodeId, node2.nodeId);
+
+      assertEquals ("Node 1: ", "The Code", node1.answer);
+      assertEquals ("Node 2: ", "The Code", node2.answer);
+
+      stateful.resetActivationCounter(); // This will activate the bean.
+      int invCount = 1;
+      
+      sleep_(10100); // let it get passivated again.
+      
+      assertEquals("Counter: ", 3, stateful.increment());
+      invCount++;
+      assertEquals("Counter: ", 4, stateful.increment());
+      invCount++;
+
+      assertEquals(invCount, stateful.getPrePassivate());
+      invCount++;
+      assertEquals(invCount, stateful.getPostActivate());
+
+      stateful.remove();
+   }
+
+   protected void sleep_(long msec)
+   {
+      try {
+         Thread.sleep(msec);
+      } catch (InterruptedException e) {
+         e.printStackTrace();
+      }
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/PassivationUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ProxyTargetsUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ProxyTargetsUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ProxyTargetsUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import java.util.Properties;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.clusteredsession.ClusteredStatelessRemote;
+import org.jboss.ejb3.test.clusteredsession.StatefulRemote;
+import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Tests that the list of remote targets in downloaded clustered bean
+ * proxies are correct.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class ProxyTargetsUnitTestCase extends JBossClusteredTestCase
+{
+   private static boolean deployed0 = true;
+   private static boolean deployed1 = true;
+   
+   private static final String NAME_BASE= "jboss.j2ee:jar=";   
+   private static final String deployment = "clusteredsession-test.jar";
+   private static final String BEAN_PREFIX = ",name=";
+   private static final String SLSB = "clusteredStateless";
+   private static final String SFSB = "testStateful";
+   private static final String NAME_QUALIFIER = ",service=EJB3socketDefaultPartition";
+   
+   /**
+    * Create a new RedeployUnitTestCase.
+    * 
+    * @param name
+    */
+   public ProxyTargetsUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(ProxyTargetsUnitTestCase.class, deployment);
+   }
+   
+   private static String getFamilyName(String beanName)
+   {
+      return NAME_BASE + deployment + BEAN_PREFIX + beanName + NAME_QUALIFIER;
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      MBeanServerConnection[] adaptors = getAdaptors();
+      if (!deployed0)
+      {
+         deploy(adaptors[0], deployment);
+         getLog().debug("Deployed " + deployment + " on server0");
+         deployed0 = true;         
+      }
+      
+      if (!deployed1)
+      {
+         deploy(adaptors[1], deployment);
+         getLog().debug("Deployed " + deployment + " on server1");
+         deployed1 = true;         
+      }
+   }
+
+   private InitialContext getInitialContext(int node) throws Exception {
+      // Connect to the serverX JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[node]);
+      return new InitialContext(env1);
+   }
+   
+   public void testBeanProxyTargets() 
+   throws Exception
+   {  
+      getLog().debug("testBeanProxyTargets");
+      getLog().debug("================================================");
+      
+      getLog().debug("Checking ClusteredStatelessRemote on node 0");
+      ClusteredStatelessRemote csr = (ClusteredStatelessRemote) getInitialContext(0).lookup("clusteredStateless/remote");
+      confirmTargetCount(getFamilyName(SLSB), 2);
+      
+      getLog().debug("Checking ClusteredStatelessRemote on node 1");
+      csr = (ClusteredStatelessRemote) getInitialContext(1).lookup("clusteredStateless/remote");
+      confirmTargetCount(getFamilyName(SLSB), 2);
+      
+      getLog().debug("Checking StatefulRemote on node 0");
+      StatefulRemote sr = (StatefulRemote) getInitialContext(0).lookup("testStateful/remote");
+      confirmTargetCount(getFamilyName(SFSB), 2);
+      
+      getLog().debug("Checking StatefulRemote on node 1");
+      sr = (StatefulRemote) getInitialContext(1).lookup("testStateful/remote");
+      confirmTargetCount(getFamilyName(SFSB), 2);
+
+      // Undeploy on node 1
+      undeploy();
+
+      getLog().debug("Checking ClusteredStatelessRemote on node 0 after undeploy");
+      csr = (ClusteredStatelessRemote) getInitialContext(0).lookup("clusteredStateless/remote");
+      confirmTargetCount(getFamilyName(SLSB), 1);
+      
+      getLog().debug("Checking StatefulRemote on node 0 after undeploy");
+      sr = (StatefulRemote) getInitialContext(0).lookup("testStateful/remote");
+      confirmTargetCount(getFamilyName(SFSB), 1);
+      
+      // Redeploy on node1
+      deploy();
+      
+      getLog().debug("Checking ClusteredStatelessRemote on node 0 after redeploy");
+      csr = (ClusteredStatelessRemote) getInitialContext(0).lookup("clusteredStateless/remote");
+      confirmTargetCount(getFamilyName(SLSB), 2);
+      
+      getLog().debug("Checking ClusteredStatelessRemote on node 1 after redeploy");
+      csr = (ClusteredStatelessRemote) getInitialContext(1).lookup("clusteredStateless/remote");
+      confirmTargetCount(getFamilyName(SLSB), 2);
+      
+      getLog().debug("Checking StatefulRemote on node 0 after redeploy");
+      sr = (StatefulRemote) getInitialContext(0).lookup("testStateful/remote");
+      confirmTargetCount(getFamilyName(SFSB), 2);
+      
+      getLog().debug("Checking StatefulRemote on node 1 after redeploy");
+      sr = (StatefulRemote) getInitialContext(1).lookup("testStateful/remote");
+      confirmTargetCount(getFamilyName(SFSB), 2);
+      
+      getLog().debug("ok");
+   }
+   
+   private void confirmTargetCount(String familyName, int expectedCount)
+   {
+      FamilyClusterInfo info = ClusteringTargetsRepository.getFamilyClusterInfo(familyName);
+      assertNotNull("FamilyClusterInfo exists for " + familyName, info);
+      assertEquals("FamilyClusterInfo for " + familyName + " has correct target count",
+                   expectedCount, info.getTargets().size());
+   }
+   
+   private void undeploy() throws Exception
+   {
+      MBeanServerConnection[] adaptors = getAdaptors();
+      
+      undeploy(adaptors[1], deployment);
+      getLog().debug("Undeployed " + deployment + " on server1");
+      deployed1 = false;
+      
+      sleep(5000);
+   }
+   
+   private void deploy() throws Exception
+   {
+      MBeanServerConnection[] adaptors = getAdaptors();
+      
+      deploy(adaptors[1], deployment);
+      getLog().debug("Deployed " + deployment + " on server1");
+      deployed1 = true;
+      
+      sleep(5000);
+   }
+   
+   
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ProxyTargetsUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/RedeployUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/RedeployUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/RedeployUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import java.rmi.dgc.VMID;
+import java.util.Properties;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
+import org.jboss.ejb3.test.clusteredsession.StatefulRemote;
+import org.jboss.ejb3.test.stateful.nested.base.VMTracker;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Tests redeployment and state transfer.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class RedeployUnitTestCase extends JBossClusteredTestCase
+{
+   private static boolean deployed0 = true;
+   private static boolean deployed1 = true;
+   
+   private static final String deployment = "clusteredsession-test.jar";
+   
+   private StatefulRemote stateful = null;  
+   
+   /**
+    * Create a new RedeployUnitTestCase.
+    * 
+    * @param name
+    */
+   public RedeployUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(RedeployUnitTestCase.class, deployment);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      MBeanServerConnection[] adaptors = getAdaptors();
+      if (!deployed0)
+      {
+         deploy(adaptors[0], deployment);
+         getLog().debug("Deployed " + deployment + " on server0");
+         deployed0 = true;         
+      }
+      
+      if (!deployed1)
+      {
+         deploy(adaptors[1], deployment);
+         getLog().debug("Deployed " + deployment + " on server1");
+         deployed1 = true;         
+      }
+   }
+
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      if (stateful != null)
+      {
+         try
+         {
+            stateful.remove();
+         }
+         catch (Exception e)
+         {
+            log.error("Problem removing stateful", e);
+         }
+         finally
+         {
+            stateful = null;
+         }
+      }
+   }
+
+   private InitialContext getInitialContext(int node) throws Exception {
+      // Connect to the serverX JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[node]);
+      return new InitialContext(env1);
+   }
+   
+   public void testStatefulBeanRedeploy() 
+   throws Exception
+   {  
+      getLog().debug("Test Stateful Bean Redeploy");
+      getLog().debug("================================================");
+      
+      getLog().debug("Trying the context...");
+
+      // Connect to the server0 JNDI
+      InitialContext ctx = getInitialContext(0);
+      
+      // We want a colocated SLSB and SFSB to test passivation/destruction
+      // VMIDTrackerBean is not clustered, so once we have it's VMID
+      // we can keep creating SFSBs until we get one we want
+      getLog().debug("Looking up VMTrackerBean...");
+      VMTracker tracker = (VMTracker) getInitialContext(0).lookup("VMTrackerBean/remote");
+      VMID monitorVM = tracker.getVMID();
+      
+      NodeAnswer node0 = null;
+      boolean vmMatch = false;
+      for (int i = 0; i < 10 && !vmMatch; i++)
+      {
+         getLog().debug("Looking up testStateful/remote... Attempt " + i +1);
+         stateful = (StatefulRemote) ctx.lookup("testStateful/remote");
+         
+         node0 = stateful.getNodeState();
+         vmMatch = monitorVM.equals(node0.getNodeId());
+         if (!vmMatch)
+         {
+            stateful.remove();
+         }
+      }
+      
+      Assert.assertTrue("Tracker and SFSB in same VM", vmMatch);
+
+      stateful.setName("Bupple-Dupple");
+
+      node0 = stateful.getNodeState();
+      getLog().debug ("Node 0 ID: " +node0);
+      
+      sleep(500);
+
+      // Redeploy on node 1
+      redeploy();
+      
+      // Now we switch to the other node, simulating a failure on node 0
+      stateful.setUpFailover("once");
+      NodeAnswer node1 = stateful.getNodeState ();
+      assertNotNull("State node: ", node1);
+      getLog ().debug ("Node 1 ID : " +node1);
+
+      assertFalse("Failover has occured", node0.nodeId.equals(node1.nodeId));
+
+      assertEquals ("Node 0: ", "Bupple-Dupple", node0.answer);
+      assertEquals ("Node 1: ", "Bupple-Dupple", node1.answer);
+      
+      getLog().debug("ok");
+   }
+   
+   private void redeploy() throws Exception
+   {
+      MBeanServerConnection[] adaptors = getAdaptors();
+      
+      undeploy(adaptors[1], deployment);
+      getLog().debug("Undeployed " + deployment + " on server1");
+      deployed1 = false;
+      
+      sleep(2000);
+      deploy(adaptors[1], deployment);
+      getLog().debug("Deployed " + deployment + " on server1");
+      deployed1 = true;
+      
+      sleep(5000);
+   }
+   
+   
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/RedeployUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ScopedExtendedPersistenceUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ScopedExtendedPersistenceUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ScopedExtendedPersistenceUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,56 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.ejb3.test.common.unit.DBSetup;
+
+/**
+ * Tests for extended persistence under clustering with a scoped classloader.
+ *
+ * @author Brian Stansberry
+ * @version $Id$
+ */
+
+public class ScopedExtendedPersistenceUnitTestCase extends ExtendedPersistenceUnitTestCase
+{
+   public ScopedExtendedPersistenceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      TestSuite suite = new TestSuite();
+      Test t1 = getDeploySetup(ScopedExtendedPersistenceUnitTestCase.class,
+                               "clusteredsession-ds.xml, clusteredsession-xpc-scoped.jar");
+
+      suite.addTest(t1);
+
+      // Create an initializer for the test suite
+      DBSetup wrapper = new DBSetup(suite);
+      return wrapper;     
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/ScopedExtendedPersistenceUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/SimpleIsLocalInterceptorUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/SimpleIsLocalInterceptorUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/SimpleIsLocalInterceptorUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import junit.framework.Test;
+
+/**
+ * @author Brian Stansberry *
+ */
+public class SimpleIsLocalInterceptorUnitTestCase 
+extends InvokeLocalTestBase
+{
+
+   public SimpleIsLocalInterceptorUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(SimpleIsLocalInterceptorUnitTestCase.class,
+                           "clusteredsession-local.jar");
+   }
+   
+   @Override
+   protected String getPartitionName()
+   {
+      return "DefaultPartition";
+   }
+
+   public void testClusteredStatefulStaysLocal() throws Exception
+   {
+      stayLocalTest("ClusteredStatefulRemote" ,true, true);
+   }
+   
+   public void testClusteredStatelessStaysLocal() throws Exception
+   {
+      stayLocalTest("ClusteredStatelessRemote" ,true, true);      
+   }
+   
+   public void testNonClusteredStatefulGoesRemote() throws Exception
+   {
+      stayLocalTest("NonClusteredStatefulRemote", false, false);      
+   }
+   
+   public void testNonClusteredStatelessGoesRemote() throws Exception
+   {
+      stayLocalTest("NonClusteredStatelessRemote", false, false);    
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/SimpleIsLocalInterceptorUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatefulProxyFactoryLoadBalancingTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatefulProxyFactoryLoadBalancingTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatefulProxyFactoryLoadBalancingTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import java.rmi.dgc.VMID;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.clusteredsession.islocal.VMTester;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class StatefulProxyFactoryLoadBalancingTestCase extends JBossClusteredTestCase
+{
+   public static final String TESTER_JNDI_NAME = "ClusteredStatefulRemote";
+   
+   /**
+    * Create a new StatefulProxyFactoryLoadBalancingTestCase.
+    * 
+    * @param name
+    */
+   public StatefulProxyFactoryLoadBalancingTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(StatefulProxyFactoryLoadBalancingTestCase.class,
+                           "clusteredsession-local.jar");
+   }
+   
+   public void testFactoryProxyLoadBalancing() throws Exception
+   {
+      String[] jndiURLs = getNamingURLs();
+      
+      Properties env1 = new Properties();
+      env1.setProperty(Context.PROVIDER_URL, jndiURLs[0]);
+      env1.setProperty("jnp.disableDiscovery", "true");
+      InitialContext ctx1 = new InitialContext(env1);
+      VMTester tester1 = (VMTester) ctx1.lookup(TESTER_JNDI_NAME);
+      
+      VMID create1 = tester1.getCreatorVMID();
+      // confirm that the bean didn't have to migrate
+      assertEquals("bean targeted where created", create1, tester1.getVMID());
+      
+      // Get another bean from the same server; should target
+      // a different server from the first
+      VMTester tester2 = (VMTester) ctx1.lookup(TESTER_JNDI_NAME);
+      
+      VMID create2 = tester2.getCreatorVMID();
+      assertEquals("2nd bean targeted where created", create2, tester2.getVMID());      
+      assertFalse("creation of 2 beans load balanced", create1.equals(create2));
+      
+      // A third bean should come from the same as the first
+      VMTester tester3 = (VMTester) ctx1.lookup(TESTER_JNDI_NAME);
+      
+      VMID create3 = tester3.getCreatorVMID();
+      assertEquals("3rd bean targeted where created", create3, tester3.getVMID());
+      assertEquals("creation of 3 beans load balanced", create1, create3);
+      
+      // Get the next proxy from the other server, but the overall 
+      // bean creation should still be round robin
+      
+      Properties env2 = new Properties();
+      env2.setProperty(Context.PROVIDER_URL, jndiURLs[1]);
+      env2.setProperty("jnp.disableDiscovery", "true");
+      InitialContext ctx2 = new InitialContext(env2);
+      VMTester tester4 = (VMTester) ctx2.lookup(TESTER_JNDI_NAME);
+      
+      VMID create4 = tester4.getCreatorVMID();
+      assertEquals("4th bean targeted where created", create4, tester4.getVMID());
+      assertEquals("creation of 4 beans load balanced", create2, create4);
+      
+      // One last time
+      VMTester tester5 = (VMTester) ctx2.lookup(TESTER_JNDI_NAME);
+      
+      VMID create5 = tester5.getCreatorVMID();
+      assertEquals("5th bean targeted where created", create5, tester5.getVMID());
+      assertEquals("creation of 5 beans load balanced", create1, create5);
+   }
+
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatefulProxyFactoryLoadBalancingTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatelessUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatelessUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatelessUnitTestCase.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,283 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.unit;
+
+import java.rmi.dgc.VMID;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.ejb3.test.clusteredsession.ClusteredStatelessRemote;
+import org.jboss.ejb3.test.clusteredsession.NodeAnswer;
+import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Test slsb for load-balancing behaviour and others.
+ *
+ * @author  Ben.Wang at jboss.org
+ * @version $Revision$
+ */
+public class StatelessUnitTestCase extends JBossClusteredTestCase
+{
+   public static final String DEPLOYMENT =  "clusteredsession-test.jar";
+
+   private static boolean deployed0 = true;
+   private static boolean deployed1 = true;
+   
+   private static final String NAME_BASE= "jboss.j2ee:jar=";   
+   private static final String deployment = "clusteredsession-test.jar";
+   private static final String BEAN_PREFIX = ",name=";
+   private static final String SLSB = "clusteredStateless";
+   private static final String NAME_QUALIFIER = ",service=EJB3socketDefaultPartition";
+   
+   public static int test = 0;
+   static Date startDate = new Date();
+   
+   
+
+   protected final String namingFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+
+   protected final String providerURL =
+   System.getProperty(Context.PROVIDER_URL);
+
+   public StatelessUnitTestCase (String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      TestSuite suite = new TestSuite();
+      suite.addTest(TestSuite.createTest(StatelessUnitTestCase.class, "testServerFound"));
+      suite.addTest(TestSuite.createTest(StatelessUnitTestCase.class, "testLoadbalance"));
+      suite.addTest(TestSuite.createTest(StatelessUnitTestCase.class, "testLoadBalanceAfterTopologyChange"));
+      return JBossClusteredTestCase.getDeploySetup(suite,
+              DEPLOYMENT);
+   }   
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      if (!deployed0)
+      {
+         deploy(getAdaptors()[0], DEPLOYMENT);
+         deployed0 = true;
+      }
+      
+      if (!deployed1)
+      {
+         deploy(getAdaptors()[1], DEPLOYMENT);
+         deployed1 = true;
+      }
+   }
+
+   protected InitialContext getInitialContext(int node) throws Exception {
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[node]);
+      return new InitialContext(env1);
+   }
+
+   public void testLoadbalance()
+   throws Exception
+   {
+      getLog().debug(++StatelessUnitTestCase.test +"- "+"Trying the context...");
+
+      InitialContext ctx = getInitialContext(0);
+
+      getLog().debug("Test Stateless Bean loadbalancing");
+      getLog().debug("==================================");
+      getLog().debug(++StatelessUnitTestCase.test +"- "
+              +"Looking up clusteredStateless/remote...");
+      ClusteredStatelessRemote stateless = (ClusteredStatelessRemote) ctx.lookup("clusteredStateless/remote");
+      
+      confirmTargetCount(2, true);
+      
+      NodeAnswer node1 = stateless.getNodeState();
+      getLog ().debug ("Node 1 ID: " +node1);
+
+      confirmTargetCount(2, false);
+      
+      Map<VMID, Integer> callCount = new HashMap<VMID, Integer>();
+      
+      int allowedErr = 0;
+      allowedErr = validateBalancing(stateless, callCount, 4, 2, 0);
+      
+      ctx = getInitialContext(1);
+      stateless = (ClusteredStatelessRemote) ctx.lookup("clusteredStateless/remote");
+      confirmTargetCount(2, true);
+      NodeAnswer node2 = stateless.getNodeState();
+      getLog ().debug ("Node 2 ID : " +node2);
+      confirmTargetCount(2, true);
+      
+//      assertFalse("Second call went to different node " + node2.nodeId + " vs " + node1.nodeId,
+//            node1.nodeId.equals(node2.nodeId));
+      
+      validateBalancing(stateless, callCount, 4, 2, allowedErr);
+      
+//      NodeAnswer call3 = stateless.getNodeState();
+//      getLog ().debug ("Call 3 ID : " +call3);
+//      confirmTargetCount(2, false);
+//
+//      assertEquals(node1.nodeId, call3.nodeId);
+   }
+
+   public void testLoadBalanceAfterTopologyChange() throws Exception
+   {
+      getLog().debug(++StatelessUnitTestCase.test +"- "+"Trying the context...");
+
+      InitialContext ctx = getInitialContext(0);
+   
+      getLog().debug("Test Stateless Bean loadbalancing after topology change");
+      getLog().debug("==================================");
+      getLog().debug(++StatelessUnitTestCase.test +"- "
+              +"Looking up clusteredStateless/remote...");
+      ClusteredStatelessRemote stateless = (ClusteredStatelessRemote) ctx.lookup("clusteredStateless/remote");
+      confirmTargetCount(2, true);
+      NodeAnswer node1 = stateless.getNodeState();
+      getLog ().debug ("Node 1 ID: " +node1);
+      confirmTargetCount(2, true);
+      NodeAnswer node2 = stateless.getNodeState();
+      getLog ().debug ("Node 2 ID : " +node2);
+         
+      assertFalse(node1.nodeId.equals(node2.nodeId));
+      confirmTargetCount(2, false);
+      
+      MBeanServerConnection[] adaptors = getAdaptors();
+      
+      deployed0 = false;
+      undeploy(adaptors[0], DEPLOYMENT);
+      
+      NodeAnswer call3 = stateless.getNodeState();
+      getLog ().debug ("Call 3 ID : " +call3);
+      confirmTargetCount(1, true);
+      
+      assertTrue("Call 3 hit existing node", node1.nodeId.equals(call3.nodeId) || node2.nodeId.equals(call3.nodeId));
+      
+      NodeAnswer call4 = stateless.getNodeState();
+      getLog ().debug ("Call 4 ID : " +call4);
+      
+      assertEquals("Call 3 and Call 4 hit the same node", call3.nodeId, call4.nodeId);
+      
+      deploy(adaptors[0], DEPLOYMENT);
+      deployed0 = true;
+      
+      // Call once to get the new topology. The next call after this
+      // might go to the same node if the topology change means the node
+      // that handled this call moves in the target list to the next position
+      NodeAnswer call5 = stateless.getNodeState();
+      getLog ().debug ("Call 5 ID : " +call5);
+      
+      Map<VMID, Integer> callCount = new HashMap<VMID, Integer>();
+      validateBalancing(stateless, callCount, 4, 2, 0);
+      
+      deployed1 = false;
+      undeploy(adaptors[1], DEPLOYMENT);
+      
+      NodeAnswer call6 = stateless.getNodeState();
+      getLog ().debug ("Call 6 ID : " +call6);
+      confirmTargetCount(1, true);
+      
+      assertTrue("Call 6 hit existing node", callCount.containsKey(call6.nodeId));
+      
+      NodeAnswer call7 = stateless.getNodeState();
+      getLog ().debug ("Call 7 ID : " +call7);
+      
+      assertEquals("Call 6 and Call 7 hit the same node", call6.nodeId, call7.nodeId);
+      
+      deploy(adaptors[1], DEPLOYMENT);
+      deployed1 = true;
+      
+      // Call once to get the new topology. The next call after this
+      // might go to the same node if the topology change means the node
+      // that handled this call moves in the target list to the next position
+      NodeAnswer call8 = stateless.getNodeState();
+      getLog ().debug ("Call 8 ID : " +call8);
+      
+      callCount = new HashMap<VMID, Integer>();
+      validateBalancing(stateless, callCount, 4, 2, 0);
+   }
+   
+   private int validateBalancing(ClusteredStatelessRemote stateless, Map<VMID, Integer> callCount, int numCalls, int expectedServers, int allowedError)
+   {
+      for (int i = 0; i < numCalls; i++)
+      {
+         NodeAnswer answer = stateless.getNodeState();
+         Integer count = callCount.get(answer.nodeId);
+         if (count == null)
+         {
+            callCount.put(answer.nodeId, new Integer(1));
+         }
+         else
+         {
+            callCount.put(answer.nodeId, new Integer(count.intValue() + 1));
+         }
+      }
+      
+      assertEquals(expectedServers, callCount.size());
+      
+      int max = -1;
+      int min = -1;
+      
+      for (Map.Entry<VMID, Integer> entry : callCount.entrySet())
+      {
+         int count = entry.getValue().intValue();
+         if (max == -1)
+         {
+            max = min = count;
+         }
+         else if (count > max)
+         {
+            max = count;
+         }
+         else if (count < min)
+         {
+            min = count;
+         }
+         
+         assertTrue(entry.getKey() +" count within allowed error", max - min <= allowedError);
+      }
+      
+      return max - min;
+   }
+   
+   private static String getFamilyName()
+   {
+      return NAME_BASE + DEPLOYMENT + BEAN_PREFIX + SLSB + NAME_QUALIFIER;
+   }
+   
+   private void confirmTargetCount(int expectedCount, boolean logIt)
+   {
+      String familyName = getFamilyName();
+      FamilyClusterInfo info = ClusteringTargetsRepository.getFamilyClusterInfo(familyName);
+      assertNotNull("FamilyClusterInfo exists for " + familyName, info);
+      List targets = info.getTargets();
+      assertEquals("FamilyClusterInfo for " + familyName + " has correct target count " + targets,
+                   expectedCount, targets.size());
+      if (logIt)
+      {
+         this.log.info("Targets are " + targets);
+      }
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/unit/StatelessUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/util/ExplicitFailoverInterceptor.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/util/ExplicitFailoverInterceptor.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/util/ExplicitFailoverInterceptor.java	2010-10-11 15:27:05 UTC (rev 108509)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ejb3.test.clusteredsession.util;
+
+import org.jboss.ha.framework.interfaces.GenericClusteringException;
+import org.jboss.logging.Logger;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * Used for testing clustering: allows to explicitly makes a call to node fail
+ * This will mimic a dead server. This is used as a ejb3 interceptor now.
+ * @author Ben Wang
+ *
+ */
+public class ExplicitFailoverInterceptor
+{
+   private Logger log = Logger.getLogger(ExplicitFailoverInterceptor.class);
+
+   @AroundInvoke
+   public Object invoke(InvocationContext ctx)
+      throws Exception
+   {
+      checkFailoverNeed (ctx);
+      return ctx.proceed();
+   }
+
+   protected void checkFailoverNeed (InvocationContext ctx)
+      throws Exception
+   {
+      if(ctx.getMethod().getName().equals("setUpFailover"))
+      {
+         return;
+      }
+
+      String failover = (String)System.getProperty ("JBossCluster-DoFail");
+      boolean doFail = false;
+
+      if (failover != null)
+      {
+         String strFailover = failover;
+         if (strFailover.equalsIgnoreCase ("true"))
+         {
+            doFail = true;
+         }
+         else if (strFailover.equalsIgnoreCase ("once"))
+         {
+            doFail = true;
+            System.setProperty ("JBossCluster-DoFail", "false");
+         }
+      }
+
+      if (doFail)
+      {
+         GenericClusteringException e = new GenericClusteringException
+         (GenericClusteringException.COMPLETED_NO, "Test failover from ejb interceptor", false);
+         
+         log.debug ("WE FAILOVER IN EJB INTERCEPTOR (explicit failover)!", e);
+
+         throw e;
+      }
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/util/ExplicitFailoverInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF



More information about the jboss-cvs-commits mailing list