[jboss-cvs] JBossAS SVN: r63181 - in trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext: unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 22 09:29:19 EDT 2007


Author: wolfc
Date: 2007-05-22 09:29:19 -0400 (Tue, 22 May 2007)
New Revision: 63181

Added:
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Base.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/BaseBean.java
Modified:
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateful.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateless.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessLocal.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java
Log:
EJBTHREE-972: unit test

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Base.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Base.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Base.java	2007-05-22 13:29:19 UTC (rev 63181)
@@ -0,0 +1,33 @@
+/*
+ * 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.ejbcontext;
+
+/**
+ * Comment
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version: $Revision: $
+ */
+public interface Base
+{
+   <T> T testBusinessObject(Class<T> businessInterface);
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/BaseBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/BaseBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/BaseBean.java	2007-05-22 13:29:19 UTC (rev 63181)
@@ -0,0 +1,42 @@
+/*
+ * 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.ejbcontext;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+
+/**
+ * Comment
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version: $Revision: $
+ */
+public class BaseBean
+{
+   @Resource
+   protected SessionContext sessionContext;
+   
+   public <T> T testBusinessObject(Class<T> businessInterface)
+   {
+      return sessionContext.getBusinessObject(businessInterface);
+   }
+}

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateful.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateful.java	2007-05-22 11:12:55 UTC (rev 63180)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateful.java	2007-05-22 13:29:19 UTC (rev 63181)
@@ -31,7 +31,7 @@
  * @version $Revision$
  */
 @Remote
-public interface Stateful
+public interface Stateful extends Base
 {
    public void testEjbContext() throws Exception;
 

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulBean.java	2007-05-22 11:12:55 UTC (rev 63180)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulBean.java	2007-05-22 13:29:19 UTC (rev 63181)
@@ -21,13 +21,9 @@
  */
 package org.jboss.ejb3.test.ejbcontext;
 
-import javax.annotation.Resource;
 import javax.ejb.EJB;
 import javax.ejb.EJBContext;
-import javax.ejb.Remote;
-import javax.ejb.SessionContext;
 import javax.ejb.Stateful;
-
 import javax.naming.InitialContext;
 
 import org.jboss.annotation.ejb.RemoteBinding;
@@ -42,14 +38,11 @@
  */
 @Stateful(name="Stateful")
 @RemoteBindings({@RemoteBinding(jndiBinding = "Stateful"), @RemoteBinding(jndiBinding = "StatefulRemote")})
-public class StatefulBean
+public class StatefulBean extends BaseBean
    implements org.jboss.ejb3.test.ejbcontext.Stateful, StatefulRemote
 {
    private static final Logger log = Logger.getLogger(StatefulBean.class);
    
-   @Resource
-   SessionContext sessionContext;
-   
    @EJB(mappedName="StatefulRemote")
    StatefulRemote statefulRemote = null;
 

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateless.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateless.java	2007-05-22 11:12:55 UTC (rev 63180)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateless.java	2007-05-22 13:29:19 UTC (rev 63181)
@@ -29,14 +29,12 @@
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  * @version $Revision$
  */
-public interface Stateless
+public interface Stateless extends Base
 {
    public void testEjbContextLookup() throws Exception;
    
    public Class testInvokedBusinessInterface() throws Exception;
    
-   public Object testBusinessObject(Class businessInterface) throws Exception;
-   
    public void testEjbObject() throws Exception;
 
    public void testEjbLocalObject() throws Exception;

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessBean.java	2007-05-22 11:12:55 UTC (rev 63180)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessBean.java	2007-05-22 13:29:19 UTC (rev 63181)
@@ -21,10 +21,8 @@
  */
 package org.jboss.ejb3.test.ejbcontext;
 
-import javax.annotation.Resource;
 import javax.ejb.Local;
 import javax.ejb.Remote;
-import javax.ejb.SessionContext;
 import javax.ejb.Stateless;
 
 import org.jboss.annotation.ejb.LocalBinding;
@@ -42,14 +40,12 @@
 @Remote(org.jboss.ejb3.test.ejbcontext.Stateless.class)
 @LocalBinding(jndiBinding = "StatelessLocal")
 @RemoteBinding(jndiBinding = "Stateless")
-public class StatelessBean
+public class StatelessBean extends BaseBean
    implements org.jboss.ejb3.test.ejbcontext.Stateless, StatelessLocal
 {
+   @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(StatelessBean.class);
    
-   @Resource
-   SessionContext sessionContext;
-
    public void noop()
    {
       
@@ -66,11 +62,6 @@
       return sessionContext.getInvokedBusinessInterface();
    }
    
-   public Object testBusinessObject(Class businessInterface) throws Exception
-   {
-      return sessionContext.getBusinessObject(businessInterface);
-   }
-   
    public void testEjbObject() throws Exception
    {
       javax.ejb.EJBObject ejbObject = sessionContext.getEJBObject();

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessLocal.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessLocal.java	2007-05-22 11:12:55 UTC (rev 63180)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessLocal.java	2007-05-22 13:29:19 UTC (rev 63181)
@@ -35,8 +35,6 @@
 
    public Class testInvokedBusinessInterface() throws Exception;
 
-   public Object testBusinessObject(Class businessInterface) throws Exception;
-
    public void testEjbObject() throws Exception;
 
    public void testEjbLocalObject() throws Exception;

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java	2007-05-22 11:12:55 UTC (rev 63180)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java	2007-05-22 13:29:19 UTC (rev 63181)
@@ -21,6 +21,8 @@
  */
 package org.jboss.ejb3.test.ejbcontext.unit;
 
+import javax.ejb.EJBException;
+
 import org.jboss.ejb3.test.ejbcontext.Stateful;
 import org.jboss.ejb3.test.ejbcontext.StatefulRemote;
 import org.jboss.ejb3.test.ejbcontext.Stateless;
@@ -160,6 +162,36 @@
       
    }
 
+   public void testGetBusinessObjectNullStateful() throws Exception
+   {
+      Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
+      try
+      {
+         stateful.testBusinessObject(null);
+         fail("Expected an EJBException");
+      }
+      catch(EJBException e)
+      {
+         assertNotNull(e.getCause());
+         assertEquals(e.getCause().getClass(), IllegalStateException.class);
+      }
+   }
+   
+   public void testGetBusinessObjectNullStateless() throws Exception
+   {
+      Stateless stateless = (Stateless)getInitialContext().lookup("Stateless");
+      try
+      {
+         stateless.testBusinessObject(null);
+         fail("Expected an EJBException");
+      }
+      catch(EJBException e)
+      {
+         assertNotNull(e.getCause());
+         assertEquals(e.getCause().getClass(), IllegalStateException.class);
+      }
+   }
+   
    public static Test suite() throws Exception
    {
       return getDeploySetup(EjbContextUnitTestCase.class, "ejbcontext.jar");




More information about the jboss-cvs-commits mailing list