You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/01/04 21:58:50 UTC

svn commit: r492736 - in /incubator/openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/core/ itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ itests/openejb-itests-beans/src/main/resources/META-I...

Author: dblevins
Date: Thu Jan  4 12:58:49 2007
New Revision: 492736

URL: http://svn.apache.org/viewvc?view=rev&rev=492736
Log:
Patch from Mohammad Nour for "OPENEJB-368: EJBContext.lookup" with some changes.
Thanks Mohammad!

Added:
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessPojoBean.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessPojoContextLookupTests.java
Modified:
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java?view=diff&rev=492736&r1=492735&r2=492736
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java Thu Jan  4 12:58:49 2007
@@ -16,20 +16,22 @@
  */
 package org.apache.openejb.core;
 
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.InterfaceType;
+import org.apache.openejb.RpcContainer;
+import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
+import org.apache.openejb.spi.SecurityService;
+import org.apache.openejb.util.proxy.ProxyManager;
+
 import javax.ejb.EJBHome;
 import javax.ejb.EJBLocalHome;
 import javax.ejb.EJBLocalObject;
 import javax.ejb.TimerService;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import javax.transaction.Status;
 import javax.transaction.TransactionManager;
-
-import org.apache.openejb.RpcContainer;
-import org.apache.openejb.DeploymentInfo;
-import org.apache.openejb.InterfaceType;
-import org.apache.openejb.spi.SecurityService;
-import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
-import org.apache.openejb.util.proxy.ProxyManager;
-
 import java.util.List;
 
 public abstract class CoreContext implements java.io.Serializable {
@@ -131,13 +133,15 @@
 
 
         Class businessLocalInterface = di.getBusinessLocalInterface();
-        if (businessLocalInterface != null && businessLocalInterface.getName().equals(interfce.getName())){
+        if (businessLocalInterface != null && businessLocalInterface.getName().equals(interfce.getName())) {
             interfaceType = InterfaceType.BUSINESS_LOCAL;
-        } else if (di.getBusinessRemoteInterface() == null && di.getBusinessRemoteInterface().getName().equals(interfce.getName())) {
+        } else
+        if (di.getBusinessRemoteInterface() == null && di.getBusinessRemoteInterface().getName().equals(interfce.getName()))
+        {
             interfaceType = InterfaceType.BUSINESS_REMOTE;
         } else {
             // TODO: verify if this is the right exception
-            throw new RuntimeException("Component has no such interface "+interfce.getName());
+            throw new RuntimeException("Component has no such interface " + interfce.getName());
         }
 
         Object newProxy = null;
@@ -185,7 +189,8 @@
             int status = getTransactionManager().getStatus();
             if (status == Status.STATUS_MARKED_ROLLBACK || status == Status.STATUS_ROLLEDBACK)
                 return true;
-            else if (status == Status.STATUS_NO_TRANSACTION)// this would be true for Supports tx attribute where no tx was propagated
+            else
+            if (status == Status.STATUS_NO_TRANSACTION)// this would be true for Supports tx attribute where no tx was propagated
                 throw new IllegalStateException("No current transaction");
             else
                 return false;
@@ -221,10 +226,19 @@
             throw new java.lang.IllegalStateException("container-managed transaction beans can not access the UserTransaction");
     }
 
-    public Object lookup(String name){
-        throw new UnsupportedOperationException("lookup");
-    }
+    public Object lookup(String name) {
+        Context initialContext = null;
+        Object object = null;
 
+        try {
+            initialContext = new InitialContext();
+            object = initialContext.lookup("java:comp/env/"+name);
+        } catch (NamingException nex) {
+            // @see http://java.sun.com/javaee/5/docs/api/javax/ejb/EJBContext.html#lookup(java.lang.String)
+            throw new IllegalArgumentException(nex);
+        }
+        return object;
+    }
 
     /*----------------------------------------------------*/
     /* UNSUPPORTED DEPRICATED METHODS                     */

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessPojoBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessPojoBean.java?view=auto&rev=492736
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessPojoBean.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessPojoBean.java Thu Jan  4 12:58:49 2007
@@ -0,0 +1,278 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.stateless;
+
+import org.apache.openejb.test.TestFailureException;
+import org.apache.openejb.test.stateful.BasicStatefulHome;
+import org.apache.openejb.test.stateful.BasicStatefulObject;
+import org.apache.openejb.test.entity.bmp.BasicBmpHome;
+import org.apache.openejb.test.entity.bmp.BasicBmpObject;
+
+import javax.ejb.SessionContext;
+import javax.ejb.EJBException;
+import javax.sql.DataSource;
+import javax.naming.InitialContext;
+import javax.persistence.EntityManagerFactory;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+
+import java.rmi.RemoteException;
+
+public class ContextLookupStatelessPojoBean {
+
+    private SessionContext ejbContext;
+
+    public void lookupEntityBean() throws TestFailureException {
+        try {
+            try {
+                BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateless/beanReferences/bmp_entity");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicBmpObject object = home.createObject("Enc Bean");
+                Assert.assertNotNull("The EJBObject is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupStatefulBean() throws TestFailureException {
+        try {
+            try {
+                BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("stateless/beanReferences/stateful");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicStatefulObject object = home.createObject("Enc Bean");
+                Assert.assertNotNull("The EJBObject is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupStatelessBean() throws TestFailureException {
+        try {
+            try {
+                BasicStatelessHome home = (BasicStatelessHome) ejbContext.lookup("stateless/beanReferences/stateless");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicStatelessObject object = home.createObject();
+                Assert.assertNotNull("The EJBObject is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupStringEntry() throws TestFailureException {
+        try {
+            try {
+                String expected = new String("1");
+                String actual = (String) ejbContext.lookup("stateless/references/String");
+
+                Assert.assertNotNull("The String looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupDoubleEntry() throws TestFailureException {
+        try {
+            try {
+                Double expected = new Double(1.0D);
+                Double actual = (Double) ejbContext.lookup("stateless/references/Double");
+
+                Assert.assertNotNull("The Double looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupLongEntry() throws TestFailureException {
+        try {
+            try {
+                Long expected = new Long(1L);
+                Long actual = (Long) ejbContext.lookup("stateless/references/Long");
+
+                Assert.assertNotNull("The Long looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupFloatEntry() throws TestFailureException {
+        try {
+            try {
+                Float expected = new Float(1.0F);
+                Float actual = (Float) ejbContext.lookup("stateless/references/Float");
+
+                Assert.assertNotNull("The Float looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupIntegerEntry() throws TestFailureException {
+        try {
+            try {
+                Integer expected = new Integer(1);
+                Integer actual = (Integer) ejbContext.lookup("stateless/references/Integer");
+
+                Assert.assertNotNull("The Integer looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupShortEntry() throws TestFailureException {
+        try {
+            try {
+                Short expected = new Short((short) 1);
+                Short actual = (Short) ejbContext.lookup("stateless/references/Short");
+
+                Assert.assertNotNull("The Short looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupBooleanEntry() throws TestFailureException {
+        try {
+            try {
+                Boolean expected = new Boolean(true);
+                Boolean actual = (Boolean) ejbContext.lookup("stateless/references/Boolean");
+
+                Assert.assertNotNull("The Boolean looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupByteEntry() throws TestFailureException {
+        try {
+            try {
+                Byte expected = new Byte((byte) 1);
+                Byte actual = (Byte) ejbContext.lookup("stateless/references/Byte");
+
+                Assert.assertNotNull("The Byte looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupCharacterEntry() throws TestFailureException {
+        try {
+            try {
+                Character expected = new Character('D');
+                Character actual = (Character) ejbContext.lookup("stateless/references/Character");
+
+                Assert.assertNotNull("The Character looked up is null", actual);
+                Assert.assertEquals(expected, actual);
+
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupResource() throws TestFailureException {
+        try {
+            try {
+                Object obj = ejbContext.lookup("datasource");
+                Assert.assertNotNull("The DataSource is null", obj);
+                Assert.assertTrue("Not an instance of DataSource", obj instanceof DataSource);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+            }
+        } catch (AssertionFailedError afe) {
+            throw new TestFailureException(afe);
+        }
+    }
+
+    public void lookupPersistenceUnit() throws TestFailureException{
+        try{
+            try{
+                InitialContext ctx = new InitialContext();
+                Assert.assertNotNull("The InitialContext is null", ctx);
+                EntityManagerFactory emf = (EntityManagerFactory)ctx.lookup("java:comp/env/persistence/TestUnit");
+                Assert.assertNotNull("The EntityManagerFactory is null", emf );
+
+            } catch (Exception e){
+                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+            }
+        } catch (AssertionFailedError afe){
+            throw new TestFailureException(afe);
+        }
+    }
+
+    /**
+     * Set the associated session context. The container calls this method
+     * after the instance creation.
+     */
+    public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException {
+        ejbContext = ctx;
+    }
+}

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=492736&r1=492735&r2=492736
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml Thu Jan  4 12:58:49 2007
@@ -1578,6 +1578,121 @@
 
         <!--
         ########################################################
+        ID:  client/tests/stateless/ContextLookupStatelessPojoBean
+        ########################################################
+        -->
+
+        <session>
+            <description>
+                The stateless bean for the JNDI ENC tests
+            </description>
+            <ejb-name>ContextLookupStatelessPojoBean</ejb-name>
+            <home>org.apache.openejb.test.stateless.EncStatelessHome</home>
+            <remote>org.apache.openejb.test.stateless.EncStatelessObject</remote>
+            <ejb-class>org.apache.openejb.test.stateless.ContextLookupStatelessBean</ejb-class>
+            <session-type>Stateless</session-type>
+            <transaction-type>Bean</transaction-type>
+
+
+            <env-entry>
+                <env-entry-name>stateless/references/JNDI_access_to_java_comp_env</env-entry-name>
+                <env-entry-type>java.lang.String</env-entry-type>
+                <env-entry-value>Success</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/Boolean</env-entry-name>
+                <env-entry-type>java.lang.Boolean</env-entry-type>
+                <env-entry-value>true</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/String</env-entry-name>
+                <env-entry-type>java.lang.String</env-entry-type>
+                <env-entry-value>1</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/Double</env-entry-name>
+                <env-entry-type>java.lang.Double</env-entry-type>
+                <env-entry-value>1</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/Long</env-entry-name>
+                <env-entry-type>java.lang.Long</env-entry-type>
+                <env-entry-value>1</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/Float</env-entry-name>
+                <env-entry-type>java.lang.Float</env-entry-type>
+                <env-entry-value>1</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/Integer</env-entry-name>
+                <env-entry-type>java.lang.Integer</env-entry-type>
+                <env-entry-value>1</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/Short</env-entry-name>
+                <env-entry-type>java.lang.Short</env-entry-type>
+                <env-entry-value>1</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/Byte</env-entry-name>
+                <env-entry-type>java.lang.Byte</env-entry-type>
+                <env-entry-value>1</env-entry-value>
+            </env-entry>
+            <env-entry>
+                <env-entry-name>stateless/references/Character</env-entry-name>
+                <env-entry-type>java.lang.Character</env-entry-type>
+                <env-entry-value>D</env-entry-value>
+            </env-entry>
+            <ejb-ref>
+                <ejb-ref-name>stateless/beanReferences/Enterprise_bean_access</ejb-ref-name>
+                <ejb-ref-type>Session</ejb-ref-type>
+                <home>org.apache.openejb.test.stateful.BasicStatefulHome</home>
+                <remote>org.apache.openejb.test.stateful.BasicStatefulObject</remote>
+                <ejb-link>BasicStatefulBean</ejb-link>
+            </ejb-ref>
+            <ejb-ref>
+                <ejb-ref-name>stateless/beanReferences/bmp_entity</ejb-ref-name>
+                <ejb-ref-type>Entity</ejb-ref-type>
+                <home>org.apache.openejb.test.entity.bmp.BasicBmpHome</home>
+                <remote>org.apache.openejb.test.entity.bmp.BasicBmpObject</remote>
+                <ejb-link>BasicBmpBean</ejb-link>
+            </ejb-ref>
+            <ejb-ref>
+                <ejb-ref-name>stateless/beanReferences/stateful</ejb-ref-name>
+                <ejb-ref-type>Session</ejb-ref-type>
+                <home>org.apache.openejb.test.stateful.BasicStatefulHome</home>
+                <remote>org.apache.openejb.test.stateful.BasicStatefulObject</remote>
+                <ejb-link>BasicStatefulBean</ejb-link>
+            </ejb-ref>
+            <ejb-ref>
+                <ejb-ref-name>stateless/beanReferences/stateless</ejb-ref-name>
+                <ejb-ref-type>Session</ejb-ref-type>
+                <home>org.apache.openejb.test.stateless.BasicStatelessHome</home>
+                <remote>org.apache.openejb.test.stateless.BasicStatelessObject</remote>
+                <ejb-link>BasicStatelessBean</ejb-link>
+            </ejb-ref>
+            <security-role-ref>
+                <role-name>TheMan</role-name>
+                <role-link>Executive</role-link>
+            </security-role-ref>
+            <resource-ref>
+                <res-ref-name>datasource</res-ref-name>
+                <res-type>javax.sql.DataSource</res-type>
+                <res-auth>Container</res-auth>
+            </resource-ref>
+            <persistence-unit-ref>
+		<description>
+		    Persistence unit for testing the functionality.
+		</description>
+		<persistence-unit-ref-name>persistence/TestUnit</persistence-unit-ref-name>
+		<persistence-unit-name>openjpa-test-unit</persistence-unit-name>
+	    </persistence-unit-ref>
+
+        </session>
+
+        <!--
+        ########################################################
         ID:  client/tests/stateless/RMI-over-IIOP/EJBHome
         ########################################################
         -->

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml?view=diff&rev=492736&r1=492735&r2=492736
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml Thu Jan  4 12:58:49 2007
@@ -167,6 +167,9 @@
 	<ejb-deployment ejb-name="ContextLookupStatelessBean" deployment-id="client/tests/stateless/ContextLookupStatelessBean" container-id="Default Stateless Container">
 		<resource-link res-ref-name="datasource" res-id="Default JDBC Database"/>
 	</ejb-deployment>
+	<ejb-deployment ejb-name="ContextLookupStatelessPojoBean" deployment-id="client/tests/stateless/ContextLookupStatelessPojoBean" container-id="Default Stateless Container">
+		<resource-link res-ref-name="datasource" res-id="Default JDBC Database"/>
+	</ejb-deployment>
 	<ejb-deployment ejb-name="Stateless RMI-IIOP Bean" deployment-id="client/tests/stateless/RMI-over-IIOP/EJBHome" container-id="Default Stateless Container"/>
 	<ejb-deployment ejb-name="BasicBmpBean" deployment-id="client/tests/entity/bmp/BasicBmpHome" container-id="Default BMP Container">
 		<resource-link res-ref-name="jdbc/basic/entityDatabase" res-id="Default JDBC Database"/>

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessPojoContextLookupTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessPojoContextLookupTests.java?view=auto&rev=492736
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessPojoContextLookupTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessPojoContextLookupTests.java Thu Jan  4 12:58:49 2007
@@ -0,0 +1,202 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.stateless;
+
+import org.apache.openejb.test.TestManager;
+import org.apache.openejb.test.TestFailureException;
+
+/**
+ * [4] Should be run as the fourth test suite of the EncStatelessTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class StatelessPojoContextLookupTests extends StatelessTestClient{
+
+    protected EncStatelessHome   ejbHome;
+    protected EncStatelessObject ejbObject;
+
+    public StatelessPojoContextLookupTests(){
+        super("JNDI_ENC.");
+    }
+
+    protected void setUp() throws Exception{
+        super.setUp();
+        Object obj = initialContext.lookup("client/tests/stateless/ContextLookupStatelessPojoBean");
+        ejbHome = (EncStatelessHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatelessHome.class);
+        ejbObject = ejbHome.create();
+
+        /*[2] Create database table */
+        TestManager.getDatabase().createEntityTable();
+    }
+
+    /**
+     * Tears down the fixture, for example, close a network connection.
+     * This method is called after a test is executed.
+     */
+    protected void tearDown() throws Exception {
+        try {
+            /*[1] Drop database table */
+            TestManager.getDatabase().dropEntityTable();
+        } catch (Exception e){
+            throw e;
+        } finally {
+            super.tearDown();
+        }
+    }
+
+    public void test01_lookupStringEntry() {
+        try{
+            ejbObject.lookupStringEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test02_lookupDoubleEntry() {
+        try{
+            ejbObject.lookupDoubleEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test03_lookupLongEntry() {
+        try{
+            ejbObject.lookupLongEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test04_lookupFloatEntry() {
+        try{
+            ejbObject.lookupFloatEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test05_lookupIntegerEntry() {
+        try{
+            ejbObject.lookupIntegerEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test06_lookupShortEntry() {
+        try{
+            ejbObject.lookupShortEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test07_lookupBooleanEntry() {
+        try{
+            ejbObject.lookupBooleanEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test08_lookupByteEntry() {
+        try{
+            ejbObject.lookupByteEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test09_lookupCharacterEntry() {
+        try{
+            ejbObject.lookupCharacterEntry();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test10_lookupEntityBean() {
+        try{
+            ejbObject.lookupEntityBean();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test11_lookupStatefulBean() {
+        try{
+            ejbObject.lookupStatefulBean();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test12_lookupStatelessBean() {
+        try{
+            ejbObject.lookupStatelessBean();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test13_lookupResource() {
+        try{
+            ejbObject.lookupResource();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void test14_lookupPersistenceUnit() {
+        try{
+            ejbObject.lookupPersistenceUnit();
+        } catch (TestFailureException e){
+            throw e.error;
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+}

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java?view=diff&rev=492736&r1=492735&r2=492736
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java Thu Jan  4 12:58:49 2007
@@ -55,6 +55,7 @@
         suite.addTest(new StatelessBeanTxTests());
         suite.addTest(new StatelessJndiEncTests());
 //        suite.addTest(new StatelessContextLookupTests());
+        suite.addTest(new StatelessPojoContextLookupTests());
         suite.addTest(new StatelessRmiIiopTests());
         suite.addTest(new MiscEjbTests());
         /* TO DO