[jboss-cvs] JBossAS SVN: r71165 - in projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222: unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 21 17:58:11 EDT 2008


Author: ALRubinger
Date: 2008-03-21 17:58:11 -0400 (Fri, 21 Mar 2008)
New Revision: 71165

Added:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteBusiness.java
Removed:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemote.java
Modified:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodBean.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteHome.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/unit/RegularRemoveMethodUnitTestCase.java
Log:
[EJBTHREE-1222] Make proper remote interface for test bean

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodBean.java	2008-03-21 21:44:39 UTC (rev 71164)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodBean.java	2008-03-21 21:58:11 UTC (rev 71165)
@@ -21,7 +21,6 @@
  */
 package org.jboss.ejb3.test.ejbthree1222;
 
-import javax.ejb.EJBObject;
 import javax.ejb.Remote;
 import javax.ejb.RemoteHome;
 import javax.ejb.Stateful;
@@ -40,14 +39,14 @@
  */
 @Stateful
 @Remote(
-{TestStatefulWithRemoveMethodRemote.class, EJBObject.class})
+{TestStatefulWithRemoveMethodRemoteBusiness.class, TestStatefulWithRemoveMethodRemote.class})
 @RemoteHome(TestStatefulWithRemoveMethodRemoteHome.class)
- at RemoteBinding(jndiBinding = TestStatefulWithRemoveMethodRemote.JNDI_NAME)
-public class TestStatefulWithRemoveMethodBean implements TestStatefulWithRemoveMethodRemote
+ at RemoteBinding(jndiBinding = TestStatefulWithRemoveMethodRemoteBusiness.JNDI_NAME)
+public class TestStatefulWithRemoveMethodBean implements TestStatefulWithRemoveMethodRemoteBusiness
 {
-   // Class Members
+   // Instance Members
 
-   public static int CALLS = 0;
+   private int calls;
 
    // Required Implementations
 
@@ -56,16 +55,21 @@
     */
    public void remove()
    {
-      TestStatefulWithRemoveMethodBean.CALLS++;
+      this.setCalls(this.getCalls() + 1);
    }
 
    public void reset()
    {
-      TestStatefulWithRemoveMethodBean.CALLS = 0;
+      this.setCalls(0);
    }
 
    public int getCalls()
    {
-      return TestStatefulWithRemoveMethodBean.CALLS;
+      return calls;
    }
+
+   private void setCalls(int calls)
+   {
+      this.calls = calls;
+   }
 }

Deleted: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemote.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemote.java	2008-03-21 21:44:39 UTC (rev 71164)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemote.java	2008-03-21 21:58:11 UTC (rev 71165)
@@ -1,42 +0,0 @@
-/*
- * 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.ejbthree1222;
-
-/**
- * TestStatefulWithRemoveMethodRemote
- * 
- * Defines a remote business interface for a Session Bean 
- * with a "void remove()" method
- *  
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface TestStatefulWithRemoveMethodRemote
-{
-   String JNDI_NAME="TestStatefulWithRemoveMethod/remote";
-   
-   void remove();
-   
-   void reset();
-   
-   int getCalls();
-}

Copied: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteBusiness.java (from rev 71130, projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemote.java)
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteBusiness.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteBusiness.java	2008-03-21 21:58:11 UTC (rev 71165)
@@ -0,0 +1,42 @@
+/*
+ * 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.ejbthree1222;
+
+/**
+ * TestStatefulWithRemoveMethodRemote
+ * 
+ * Defines a remote business interface for a Session Bean 
+ * with a "void remove()" method
+ *  
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface TestStatefulWithRemoveMethodRemoteBusiness
+{
+   String JNDI_NAME="TestStatefulWithRemoveMethod/remote";
+   
+   void remove();
+   
+   void reset();
+   
+   int getCalls();
+}

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteHome.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteHome.java	2008-03-21 21:44:39 UTC (rev 71164)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteHome.java	2008-03-21 21:58:11 UTC (rev 71165)
@@ -35,6 +35,6 @@
 public interface TestStatefulWithRemoveMethodRemoteHome extends EJBHome
 {
    String JNDI_NAME = "TestStatefulWithRemoveMethodBean/home";
-   
+
    TestStatefulWithRemoveMethodRemote create() throws RemoteException, CreateException;
 }

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/unit/RegularRemoveMethodUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/unit/RegularRemoveMethodUnitTestCase.java	2008-03-21 21:44:39 UTC (rev 71164)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/unit/RegularRemoveMethodUnitTestCase.java	2008-03-21 21:58:11 UTC (rev 71165)
@@ -29,6 +29,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.ejb3.test.ejbthree1222.TestStatefulWithRemoveMethodRemote;
+import org.jboss.ejb3.test.ejbthree1222.TestStatefulWithRemoveMethodRemoteBusiness;
+import org.jboss.ejb3.test.ejbthree1222.TestStatefulWithRemoveMethodRemoteHome;
 import org.jboss.test.JBossTestCase;
 
 /**
@@ -61,8 +63,8 @@
    public void testNormalMethodNamedRemove() throws Exception
    {
       // Lookup Bean
-      TestStatefulWithRemoveMethodRemote bean = (TestStatefulWithRemoveMethodRemote) this.getInitialContext().lookup(
-            TestStatefulWithRemoveMethodRemote.JNDI_NAME);
+      TestStatefulWithRemoveMethodRemoteBusiness bean = (TestStatefulWithRemoveMethodRemoteBusiness) this
+            .getInitialContext().lookup(TestStatefulWithRemoveMethodRemoteBusiness.JNDI_NAME);
 
       // Reset the number of calls, if any
       bean.reset();
@@ -91,6 +93,49 @@
 
    }
 
+   /**
+    * Tests that a call to EJBObject's "void remove()"
+    * results in proper bean removal
+    */
+   public void testEjbObjectRemove() throws Exception
+   {
+      // Lookup Home
+      TestStatefulWithRemoveMethodRemoteHome home = (TestStatefulWithRemoveMethodRemoteHome) this.getInitialContext()
+            .lookup(TestStatefulWithRemoveMethodRemoteHome.JNDI_NAME);
+
+      // Create
+      TestStatefulWithRemoveMethodRemote bean = home.create();
+
+      // Reset the number of calls, if any
+      bean.reset();
+
+      // Remove the instance (EJB2.1 Call)
+      try
+      {
+         bean.remove();
+      }
+      catch (Exception e)
+      {
+         logger.error(e.getMessage(), e);
+         TestCase.fail(e.getMessage());
+      }
+
+      try
+      {
+         // Ensure the instance was removed by making another call
+         bean.getCalls();
+      }
+      catch (NoSuchEJBException nsee)
+      {
+         // Expected
+         return;
+      }
+
+      // NSEE should have been thrown
+      TestCase.fail(NoSuchEJBException.class.getName() + " should have been thrown.");
+
+   }
+
    // Suite
 
    public static Test suite() throws Exception




More information about the jboss-cvs-commits mailing list