[jboss-cvs] JBossAS SVN: r73093 - in projects/ejb3/trunk/core: src/test/java/org/jboss/ejb3/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 6 20:08:44 EDT 2008


Author: ALRubinger
Date: 2008-05-06 20:08:43 -0400 (Tue, 06 May 2008)
New Revision: 73093

Added:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/TestPassivationBean.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/TestPassivationRemote.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/unit/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/unit/PassivationSucceedsUnitTestCase.java
Modified:
   projects/ejb3/trunk/core/build-test.xml
Log:
[EJBTHREE-1339] Added Test

Modified: projects/ejb3/trunk/core/build-test.xml
===================================================================
--- projects/ejb3/trunk/core/build-test.xml	2008-05-06 22:59:31 UTC (rev 73092)
+++ projects/ejb3/trunk/core/build-test.xml	2008-05-07 00:08:43 UTC (rev 73093)
@@ -2399,6 +2399,10 @@
    <target name="ejbthree1271">
       <build-simple-jar name="ejbthree1271"/>
    </target>
+	
+   <target name="ejbthree1339">
+      <build-simple-jar name="ejbthree1339"/>
+   </target>
 
    <target name="jbas4489"
       description="Builds a simple jar files."
@@ -4118,9 +4122,8 @@
       ejbthree1062,
       ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
       ejbthree1130, 
-      ejbthree1146, ejbthree1148, ejbthree1154, ejbthree1155, ejbthree1157, ejbthree1222, ejbthree1271, jaxws, jbas4489,
-	  epcpropagation,
-      aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
+      ejbthree1146, ejbthree1148, ejbthree1154, ejbthree1155, ejbthree1157, ejbthree1222, ejbthree1271, ejbthree1339,
+   	  jaxws, jbas4489, epcpropagation, aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
       securitydomain, enventry, security5,
       jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions,
       exception, dd/override, stateless, dd/mdb, bank, dd, longlived, xmlcfg, hbm, pkg, regressionHHH275,
@@ -4927,6 +4930,9 @@
         <param name="test" value="ejbthree1271"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree1339"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="statelesscreation"/>
       </antcall>
       <antcall target="test" inheritRefs="true">

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/TestPassivationBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/TestPassivationBean.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/TestPassivationBean.java	2008-05-07 00:08:43 UTC (rev 73093)
@@ -0,0 +1,97 @@
+/*
+ * 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.ejbthree1339;
+
+import javax.ejb.PostActivate;
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.logging.Logger;
+
+/**
+ * TestPassivationBean
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at Remote(TestPassivationRemote.class)
+ at RemoteBinding(jndiBinding = TestPassivationRemote.JNDI_NAME)
+ at CacheConfig(idleTimeoutSeconds = 1L)
+public class TestPassivationBean implements TestPassivationRemote
+{
+
+   // ---------------------------------------------------------------------------||
+   // Class Members -------------------------------------------------------------||
+   // ---------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(TestPassivationBean.class);
+
+   // ---------------------------------------------------------------------------||
+   // Instance Members ----------------------------------------------------------||
+   // ---------------------------------------------------------------------------||
+
+   /**
+    * Whether the bean has yet been passivated
+    */
+   private boolean beenPassivated = false;
+
+   // ---------------------------------------------------------------------------||
+   // Functional Methods --------------------------------------------------------||
+   // ---------------------------------------------------------------------------||
+
+   /**
+    * Returns the expected result
+    * 
+    * @return
+    */
+   public String returnTrueString()
+   {
+      return TestPassivationRemote.EXPECTED_RESULT;
+   }
+
+   /**
+    * Returns whether or not this instance has been passivated
+    * 
+    * @return
+    */
+   public boolean hasBeenPassivated()
+   {
+      return this.beenPassivated;
+   }
+
+   // ---------------------------------------------------------------------------||
+   // Lifecycle Methods --------------------------------------------------------||
+   // ---------------------------------------------------------------------------||
+
+   /**
+    * Sets the passivation flag before reactivation
+    */
+   @PostActivate
+   public void setPassivateFlag()
+   {
+      log.info(this.toString() + " Activated");
+      this.beenPassivated = true;
+   }
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/TestPassivationRemote.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/TestPassivationRemote.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/TestPassivationRemote.java	2008-05-07 00:08:43 UTC (rev 73093)
@@ -0,0 +1,63 @@
+/*
+ * 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.ejbthree1339;
+
+/**
+ * TestPassivationRemote
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface TestPassivationRemote
+{
+   // ---------------------------------------------------------------------------||
+   // Class Members -------------------------------------------------------------||
+   // ---------------------------------------------------------------------------||
+   /**
+    * The expected result contract
+    */
+   String EXPECTED_RESULT = "true";
+   
+   /**
+    * The JNDI Name to which we'll bind this proxy
+    */
+   String JNDI_NAME = "TestPassivationBean/remote";
+   
+   // ---------------------------------------------------------------------------||
+   // Functional Methods --------------------------------------------------------||
+   // ---------------------------------------------------------------------------||
+   
+   /**
+    * Returns the expected result exposed as a static final variable
+    * by this interface
+    * 
+    * @return
+    */
+   String returnTrueString();
+   
+   /**
+    * Returns whether or not this instance has been passivated
+    * 
+    * @return
+    */
+   boolean hasBeenPassivated();
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/unit/PassivationSucceedsUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/unit/PassivationSucceedsUnitTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1339/unit/PassivationSucceedsUnitTestCase.java	2008-05-07 00:08:43 UTC (rev 73093)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.ejbthree1339.unit;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.jboss.ejb3.test.ejbthree1339.TestPassivationRemote;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * PassivationSucceedsUnitTestCase
+ *
+ * Tests that passivation succeeds, and invocation
+ * is possible upon reactivation
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class PassivationSucceedsUnitTestCase extends JBossTestCase
+{
+   public PassivationSucceedsUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(PassivationSucceedsUnitTestCase.class, "ejbthree1339.jar");
+   }
+
+   public void testCalculator() throws Exception
+   {
+
+      // Lookup and create stateful instance
+      TestPassivationRemote remote = (TestPassivationRemote) getInitialContext()
+            .lookup(TestPassivationRemote.JNDI_NAME);
+
+      // Make an invocation
+      TestCase.assertEquals("Returned result was not expected", TestPassivationRemote.EXPECTED_RESULT, remote
+            .returnTrueString());
+
+      // Sleep, allow SFSB to passivate
+      Thread.sleep(5000L);
+
+      // Make another invocation
+      TestCase.assertEquals("Returned result was not expected", TestPassivationRemote.EXPECTED_RESULT, remote
+            .returnTrueString());
+
+      // Ensure the bean was passivated during the client sleep
+      TestCase.assertTrue("SFSB was not passivated, check CacheConfig and client sleep time", remote
+            .hasBeenPassivated());
+   }
+}




More information about the jboss-cvs-commits mailing list