[jboss-cvs] JBossAS SVN: r71285 - 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
Wed Mar 26 00:21:36 EDT 2008
Author: ALRubinger
Date: 2008-03-26 00:21:36 -0400 (Wed, 26 Mar 2008)
New Revision: 71285
Added:
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbRemoteBusiness.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocal.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalBusiness.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalHome.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/TestStatefulWithRemoveMethodRemoteBusiness.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] Enhanced Unit Tests to cover local/business local SFSB
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbBean.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -0,0 +1,75 @@
+package org.jboss.ejb3.test.ejbthree1222;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.RemoveException;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+ at Stateful
+ at Remote(AccessLocalSfsbRemoteBusiness.class)
+ at RemoteBinding(jndiBinding = AccessLocalSfsbRemoteBusiness.JNDI_NAME)
+public class AccessLocalSfsbBean implements AccessLocalSfsbRemoteBusiness
+{
+
+ // Instance Members
+
+ @EJB
+ TestStatefulWithRemoveMethodLocalHome localHome;
+
+ TestStatefulWithRemoveMethodLocal local;
+
+ @EJB
+ TestStatefulWithRemoveMethodLocalBusiness localBusiness;
+
+ // Required Implementations
+
+ public void resetOnLocalBusiness()
+ {
+ this.localBusiness.reset();
+ }
+
+ public void removeOnLocalBusiness()
+ {
+ this.localBusiness.remove();
+ }
+
+ public int getCallsOnLocalBusiness()
+ {
+ return this.localBusiness.getCalls();
+ }
+
+ public void resetOnLocal()
+ {
+ this.getLocal().reset();
+ }
+
+ public void removeOnLocal() throws RemoveException
+ {
+ this.getLocal().remove();
+ }
+
+ public int getCallsOnLocal()
+ {
+ return this.getLocal().getCalls();
+ }
+
+ private TestStatefulWithRemoveMethodLocal getLocal()
+ {
+ if(local==null)
+ {
+ try
+ {
+ local = localHome.create();
+ }
+ catch(CreateException ce)
+ {
+ throw new RuntimeException(ce);
+ }
+ }
+
+ return local;
+ }
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbRemoteBusiness.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbRemoteBusiness.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbRemoteBusiness.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+import javax.ejb.RemoveException;
+
+/**
+ * AccessLocalSfsbRemoteBusiness
+ *
+ * Used to get access to the local views of the Test Bean
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface AccessLocalSfsbRemoteBusiness
+{
+ String JNDI_NAME = "AccessLocalSfsb/remote";
+
+ void resetOnLocalBusiness();
+
+ void removeOnLocalBusiness();
+
+ int getCallsOnLocalBusiness();
+
+ void resetOnLocal();
+
+ void removeOnLocal() throws RemoveException;
+
+ int getCallsOnLocal();
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/AccessLocalSfsbRemoteBusiness.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-26 03:24:14 UTC (rev 71284)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodBean.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -21,11 +21,16 @@
*/
package org.jboss.ejb3.test.ejbthree1222;
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
import javax.ejb.Remote;
import javax.ejb.RemoteHome;
import javax.ejb.Stateful;
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.LocalHomeBinding;
import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteHomeBinding;
/**
* TestStatefulWithRemoveMethodBean
@@ -38,10 +43,16 @@
* @version $Revision: $
*/
@Stateful
+ at Local(
+{TestStatefulWithRemoveMethodLocal.class, TestStatefulWithRemoveMethodLocalBusiness.class})
@Remote(
{TestStatefulWithRemoveMethodRemoteBusiness.class, TestStatefulWithRemoveMethodRemote.class})
+ at LocalHome(TestStatefulWithRemoveMethodLocalHome.class)
@RemoteHome(TestStatefulWithRemoveMethodRemoteHome.class)
+ at LocalBinding(jndiBinding = TestStatefulWithRemoveMethodLocalBusiness.JNDI_NAME)
@RemoteBinding(jndiBinding = TestStatefulWithRemoveMethodRemoteBusiness.JNDI_NAME)
+ at LocalHomeBinding(jndiBinding = TestStatefulWithRemoveMethodLocalHome.JNDI_NAME)
+ at RemoteHomeBinding(jndiBinding = TestStatefulWithRemoveMethodRemoteHome.JNDI_NAME)
public class TestStatefulWithRemoveMethodBean implements TestStatefulWithRemoveMethodRemoteBusiness
{
// Instance Members
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocal.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocal.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocal.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * TestStatefulWithRemoveMethodRemote
+ *
+ * Defines a local interface for a Session Bean
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface TestStatefulWithRemoveMethodLocal extends EJBLocalObject
+{
+ void reset();
+
+ int getCalls();
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalBusiness.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalBusiness.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalBusiness.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -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;
+
+/**
+ * TestStatefulWithRemoveMethodLocalBusiness
+ *
+ * Defines a local 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 TestStatefulWithRemoveMethodLocalBusiness
+{
+ String JNDI_NAME="TestStatefulWithRemoveMethod/local";
+
+ void remove();
+
+ void reset();
+
+ int getCalls();
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalBusiness.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalHome.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalHome.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalHome.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+/**
+ * TestStatefulWithRemoveMethodLocalHome
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface TestStatefulWithRemoveMethodLocalHome extends EJBLocalHome
+{
+ String JNDI_NAME = "TestStatefulWithRemoveMethod/localHome";
+
+ TestStatefulWithRemoveMethodLocal create() throws CreateException;
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodLocalHome.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteBusiness.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteBusiness.java 2008-03-26 03:24:14 UTC (rev 71284)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteBusiness.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -22,7 +22,7 @@
package org.jboss.ejb3.test.ejbthree1222;
/**
- * TestStatefulWithRemoveMethodRemote
+ * TestStatefulWithRemoveMethodRemoteBusiness
*
* Defines a remote business interface for a Session Bean
* with a "void remove()" method
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-26 03:24:14 UTC (rev 71284)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/TestStatefulWithRemoveMethodRemoteHome.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -34,7 +34,7 @@
*/
public interface TestStatefulWithRemoveMethodRemoteHome extends EJBHome
{
- String JNDI_NAME = "TestStatefulWithRemoveMethodBean/home";
+ String JNDI_NAME = "TestStatefulWithRemoveMethod/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-26 03:24:14 UTC (rev 71284)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/ejbthree1222/unit/RegularRemoveMethodUnitTestCase.java 2008-03-26 04:21:36 UTC (rev 71285)
@@ -28,6 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.ejb3.test.ejbthree1222.AccessLocalSfsbRemoteBusiness;
import org.jboss.ejb3.test.ejbthree1222.TestStatefulWithRemoveMethodRemote;
import org.jboss.ejb3.test.ejbthree1222.TestStatefulWithRemoveMethodRemoteBusiness;
import org.jboss.ejb3.test.ejbthree1222.TestStatefulWithRemoveMethodRemoteHome;
@@ -58,9 +59,9 @@
/**
* Tests that a call to an unannotated "void remove()"
- * method is a traditional call
+ * method is a traditional call on a remote view
*/
- public void testNormalMethodNamedRemove() throws Exception
+ public void testRemoteNormalMethodNamedRemove() throws Exception
{
// Lookup Bean
TestStatefulWithRemoveMethodRemoteBusiness bean = (TestStatefulWithRemoveMethodRemoteBusiness) this
@@ -92,8 +93,85 @@
}
}
+
+ /**
+ * Tests that a call to an unannotated "void remove()"
+ * method is a traditional call on a local view
+ */
+ public void testLocalNormalMethodNamedRemove() throws Exception
+ {
+ // Lookup Access Bean
+ AccessLocalSfsbRemoteBusiness bean = (AccessLocalSfsbRemoteBusiness) this
+ .getInitialContext().lookup(AccessLocalSfsbRemoteBusiness.JNDI_NAME);
+ // Reset the number of calls, if any
+ bean.resetOnLocalBusiness();
+
+ // Make a call
+ try
+ {
+ bean.removeOnLocalBusiness();
+ }
+ catch (Exception e)
+ {
+ logger.error(e.getMessage(), e);
+ TestCase.fail(e.getMessage());
+ }
+
+ try
+ {
+ // Ensure the call was received and the bean instance is still available
+ TestCase.assertEquals(1, bean.getCallsOnLocalBusiness());
+ }
+ catch (NoSuchEJBException nsee)
+ {
+ // "void remove()" should not have been handled as EJB2.1 call
+ TestCase.fail("Bean should not have been removed: " + nsee.getMessage());
+ }
+
+ }
+
/**
+ * Tests that a call to EJBLocalObject's "void remove()"
+ * results in proper bean removal
+ */
+ public void testEjbLocalObjectRemove() throws Exception
+ {
+ // Lookup Access Bean
+ AccessLocalSfsbRemoteBusiness bean = (AccessLocalSfsbRemoteBusiness) this.getInitialContext().lookup(
+ AccessLocalSfsbRemoteBusiness.JNDI_NAME);
+
+ // Reset the number of calls, if any
+ bean.resetOnLocal();
+
+ // Remove the instance (EJB2.1 Call)
+ try
+ {
+ bean.removeOnLocal();
+ }
+ catch (Exception e)
+ {
+ logger.error(e.getMessage(), e);
+ TestCase.fail(e.getMessage());
+ }
+
+ try
+ {
+ // Ensure the instance was removed by making another call
+ bean.getCallsOnLocal();
+ }
+ catch (NoSuchEJBException nsee)
+ {
+ // Expected
+ return;
+ }
+
+ // NSEE should have been thrown
+ TestCase.fail(NoSuchEJBException.class.getName() + " should have been thrown.");
+
+ }
+
+ /**
* Tests that a call to EJBObject's "void remove()"
* results in proper bean removal
*/
More information about the jboss-cvs-commits
mailing list