[jboss-cvs] JBossAS SVN: r103101 - in projects/ejb3/trunk/testsuite: 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
Mon Mar 29 05:57:27 EDT 2010


Author: jaikiran
Date: 2010-03-29 05:57:27 -0400 (Mon, 29 Mar 2010)
New Revision: 103101

Added:
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/EJBContextTester.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/SimpleStatefulBean.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/SimpleStatelessBean.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/unit/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/unit/EJBContextLookupTestCase.java
Modified:
   projects/ejb3/trunk/testsuite/build-test.xml
Log:
EJBTHREE-2038 Added a new testcase to test the bug fix

Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml	2010-03-29 09:41:28 UTC (rev 103100)
+++ projects/ejb3/trunk/testsuite/build-test.xml	2010-03-29 09:57:27 UTC (rev 103101)
@@ -4217,6 +4217,11 @@
          <fileset dir="${resources}/test/ejbthree1995"/>
       </jar>
    </target>
+   
+    <target name="ejbthree2038">
+          <build-simple-jar name="ejbthree2038"/>
+    </target>
+   
 
    <target name="jars" depends="removedislocal, statelesscreation, defaultremotebindings, localfromremote, clusteredjms, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
       concurrent,
@@ -4250,7 +4255,7 @@
       composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
       localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
       statelesscreation, changexml, externalrefscoped, ejbthree1671, ejbthree1677, ejbthree1629, 
-      ejbthree1807, ejbthree1346, ejbthree1823, ejbthree1858, ejbthree1876, ejbthree1926"/>
+      ejbthree1807, ejbthree1346, ejbthree1823, ejbthree1858, ejbthree1876, ejbthree1926, ejbthree2038"/>
 
    <target name="test" depends="init" if="test"
       description="Execute all tests in the given test directory.">
@@ -5073,6 +5078,9 @@
       <antcall target="test" inheritRefs="true">
          <param name="test" value="ejbthree1995"/>
       </antcall>
+     <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree2038"/>
+      </antcall>
       <antcall target="test" inheritRefs="true">
          <param name="test" value="statelesscreation"/>
       </antcall>

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/EJBContextTester.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/EJBContextTester.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/EJBContextTester.java	2010-03-29 09:57:27 UTC (rev 103101)
@@ -0,0 +1,33 @@
+/*
+* 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.ejbthree2038;
+
+/**
+ * Echo
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface EJBContextTester
+{
+   boolean wasEJBContextAvailableInPostConstruct();
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/SimpleStatefulBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/SimpleStatefulBean.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/SimpleStatefulBean.java	2010-03-29 09:57:27 UTC (rev 103101)
@@ -0,0 +1,71 @@
+/*
+* 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.ejbthree2038;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.logging.Logger;
+
+/**
+ * SimpleStatefulBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateful
+ at Remote (EJBContextTester.class)
+ at RemoteBinding (jndiBinding = SimpleStatefulBean.JNDI_NAME)
+public class SimpleStatefulBean implements EJBContextTester
+{
+
+   private static Logger logger = Logger.getLogger(SimpleStatefulBean.class);
+
+   private boolean wasEJBContextAvailableInPostConstruct = false;
+   
+   public static final String JNDI_NAME = "ejbthree2038-statefulbean";
+
+   @PostConstruct
+   public void onConstruct() throws Exception
+   {
+      Context ctx = new InitialContext();
+      Context enc = (Context) ctx.lookup("java:comp");
+      SessionContext sessionContext = (SessionContext) enc.lookup("EJBContext");
+      this.wasEJBContextAvailableInPostConstruct = true;
+      logger.debug("Session context in postconstruct of bean " + this.getClass() + " is " + sessionContext);
+
+   }
+
+   /**
+    * @see org.jboss.ejb3.test.ejbthree2038.EJBContextTester#wasEJBContextAvailableInPostConstruct()
+    */
+   public boolean wasEJBContextAvailableInPostConstruct()
+   {
+      return this.wasEJBContextAvailableInPostConstruct;
+   }
+
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/SimpleStatelessBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/SimpleStatelessBean.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/SimpleStatelessBean.java	2010-03-29 09:57:27 UTC (rev 103101)
@@ -0,0 +1,71 @@
+/*
+* 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.ejbthree2038;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.log4j.Logger;
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+/**
+ * SimpleStatelessBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote (EJBContextTester.class)
+ at RemoteBinding (jndiBinding = SimpleStatelessBean.JNDI_NAME)
+public class SimpleStatelessBean implements EJBContextTester
+{
+
+   public static final String JNDI_NAME = "ejbthree2038-statelessbean";
+   
+   private static Logger logger = Logger.getLogger(SimpleStatelessBean.class);
+   
+   private boolean wasEJBContextAvailableInPostConstruct = false;
+   
+   @PostConstruct
+   public void onConstruct() throws Exception
+   {
+      Context ctx = new InitialContext();
+      Context enc = (Context) ctx.lookup("java:comp");
+      SessionContext sessionContext = (SessionContext) enc.lookup("EJBContext");
+      this.wasEJBContextAvailableInPostConstruct = true;
+      logger.debug("Session context in postconstruct of bean " + this.getClass() + " is " + sessionContext);
+      
+   }
+
+   /**
+    * @see org.jboss.ejb3.test.ejbthree2038.EJBContextTester#wasEJBContextAvailableInPostConstruct()
+    */
+   public boolean wasEJBContextAvailableInPostConstruct()
+   {
+      return this.wasEJBContextAvailableInPostConstruct;
+   }
+  
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/unit/EJBContextLookupTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/unit/EJBContextLookupTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2038/unit/EJBContextLookupTestCase.java	2010-03-29 09:57:27 UTC (rev 103101)
@@ -0,0 +1,88 @@
+/*
+* 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.ejbthree2038.unit;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree2038.EJBContextTester;
+import org.jboss.ejb3.test.ejbthree2038.SimpleStatefulBean;
+import org.jboss.ejb3.test.ejbthree2038.SimpleStatelessBean;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test the fix for EJBTHREE-2038 bug https://jira.jboss.org/jira/browse/EJBTHREE-2038
+ *<p>
+ *  Lookup of java:comp/EJBContext from a PostConstruct method
+ *  used to result in a NullPointerException. This testcase tests the
+ *  fix for that bug 
+ *</p>
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class EJBContextLookupTestCase extends JBossTestCase
+{
+
+   /**
+    * @param name
+    */
+   public EJBContextLookupTestCase(String name)
+   {
+      super(name);
+
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(EJBContextLookupTestCase.class, "ejbthree2038.jar");
+   }
+
+   /**
+    * Test that java:comp/EJBContext can be looked up from the PostConstruct method
+    * of a Stateless session bean
+    * 
+    * @throws Exception
+    */
+   @org.junit.Test
+   public void testEJBContextLookupInSLSB() throws Exception
+   {
+      EJBContextTester bean = (EJBContextTester) this.getInitialContext().lookup(SimpleStatelessBean.JNDI_NAME);
+      Assert.assertTrue("EJBContext was *not* available in postconstruct of SLSB", bean
+            .wasEJBContextAvailableInPostConstruct());
+
+   }
+
+   /**
+    *  Test that java:comp/EJBContext can be looked up from the PostConstruct method
+    * of a Stateful session bean
+    * @throws Exception
+    */
+   @org.junit.Test
+   public void testEJBContextLookupInSFSB() throws Exception
+   {
+      EJBContextTester bean = (EJBContextTester) this.getInitialContext().lookup(SimpleStatefulBean.JNDI_NAME);
+      Assert.assertTrue("EJBContext was *not* available in postconstruct of SFSB", bean
+            .wasEJBContextAvailableInPostConstruct());
+
+   }
+}




More information about the jboss-cvs-commits mailing list