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 2006/12/07 11:43:46 UTC

svn commit: r483409 [1/2] - in /incubator/openejb/trunk/openejb3/itests: openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/bmp/ openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ openejb-itests-beans/src/main/java/or...

Author: dblevins
Date: Thu Dec  7 02:43:45 2006
New Revision: 483409

URL: http://svn.apache.org/viewvc?view=rev&rev=483409
Log:
Added tests for EJBContext.lookup.  Should help Mohammad do OPENEJB-368

Added:
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/bmp/ContextLookupBmpBean.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ContextLookupCmpBean.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpContextLookupTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpContextLookupTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/StatefulContextLookupTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessContextLookupTests.java
Modified:
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/cmp.mapping.xml
    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/jpa.mapping.xml
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/bmp/ContextLookupBmpBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/bmp/ContextLookupBmpBean.java?view=auto&rev=483409
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/bmp/ContextLookupBmpBean.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/bmp/ContextLookupBmpBean.java Thu Dec  7 02:43:45 2006
@@ -0,0 +1,384 @@
+/**
+ * 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.entity.bmp;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+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.stateless.BasicStatelessHome;
+import org.apache.openejb.test.stateless.BasicStatelessObject;
+
+import javax.ejb.EJBException;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+import javax.sql.DataSource;
+import java.rmi.RemoteException;
+
+/**
+ * @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 ContextLookupBmpBean implements javax.ejb.EntityBean {
+
+    private int primaryKey;
+    private String firstName;
+    private String lastName;
+    private EntityContext ejbContext;
+
+    //=============================
+    // Home interface methods
+    //
+
+    /**
+     * Maps to EncBmpHome.findEmptyCollection
+     *
+     * @return
+     * @throws javax.ejb.FinderException
+     * @see EncBmpHome#findEmptyCollection()
+     */
+    public java.util.Collection ejbFindEmptyCollection()
+            throws javax.ejb.FinderException, java.rmi.RemoteException {
+        return new java.util.Vector();
+    }
+
+    /**
+     * Maps to EncBmpHome.findByPrimaryKey
+     *
+     * @param primaryKey
+     * @return
+     * @throws javax.ejb.FinderException
+     * @see EncBmpHome#findByPrimaryKey(Integer)
+     */
+    public Integer ejbFindByPrimaryKey(Integer primaryKey)
+            throws javax.ejb.FinderException {
+        return new Integer(-1);
+    }
+
+    /**
+     * Maps to EncBmpHome.create
+     *
+     * @param name
+     * @return
+     * @throws javax.ejb.CreateException
+     * @see EncBmpHome#create
+     */
+    public Integer ejbCreate(String name)
+            throws javax.ejb.CreateException {
+        return new Integer(-1);
+    }
+
+    public void ejbPostCreate(String name)
+            throws javax.ejb.CreateException {
+    }
+
+    //
+    // Home interface methods
+    //=============================
+
+    //=============================
+    // Remote interface methods
+    //
+
+
+    public void lookupEntityBean() throws TestFailureException {
+        try {
+            try {
+                BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("entity/bmp/beanReferences/bmp_entity");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicBmpObject object = home.create("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("entity/bmp/beanReferences/stateful");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicStatefulObject object = home.create("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("entity/bmp/beanReferences/stateless");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicStatelessObject object = home.create();
+                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("entity/bmp/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("entity/bmp/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("entity/bmp/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("entity/bmp/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("entity/bmp/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("entity/bmp/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("entity/bmp/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("entity/bmp/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("entity/bmp/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);
+        }
+    }
+    //
+    // Remote interface methods
+    //=============================
+
+    //================================
+    // EntityBean interface methods
+    //
+
+    /**
+     * A container invokes this method to instruct the
+     * instance to synchronize its state by loading it state from the
+     * underlying database.
+     */
+    public void ejbLoad() throws EJBException, RemoteException {
+    }
+
+    /**
+     * Set the associated entity context. The container invokes this method
+     * on an instance after the instance has been created.
+     */
+    public void setEntityContext(EntityContext ctx) throws EJBException, RemoteException {
+        ejbContext = ctx;
+    }
+
+    /**
+     * Unset the associated entity context. The container calls this method
+     * before removing the instance.
+     */
+    public void unsetEntityContext() throws EJBException, RemoteException {
+    }
+
+    /**
+     * A container invokes this method to instruct the
+     * instance to synchronize its state by storing it to the underlying
+     * database.
+     */
+    public void ejbStore() throws EJBException, RemoteException {
+    }
+
+    /**
+     * A container invokes this method before it removes the EJB object
+     * that is currently associated with the instance. This method
+     * is invoked when a client invokes a remove operation on the
+     * enterprise Bean's home interface or the EJB object's remote interface.
+     * This method transitions the instance from the ready state to the pool
+     * of available instances.
+     */
+    public void ejbRemove() throws RemoveException, EJBException, RemoteException {
+    }
+
+    /**
+     * A container invokes this method when the instance
+     * is taken out of the pool of available instances to become associated
+     * with a specific EJB object. This method transitions the instance to
+     * the ready state.
+     */
+    public void ejbActivate() throws EJBException, RemoteException {
+    }
+
+    /**
+     * A container invokes this method on an instance before the instance
+     * becomes disassociated with a specific EJB object. After this method
+     * completes, the container will place the instance into the pool of
+     * available instances.
+     */
+    public void ejbPassivate() throws EJBException, RemoteException {
+    }
+    //
+    // EntityBean interface methods
+    //================================
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ContextLookupCmpBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ContextLookupCmpBean.java?view=auto&rev=483409
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ContextLookupCmpBean.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ContextLookupCmpBean.java Thu Dec  7 02:43:45 2006
@@ -0,0 +1,365 @@
+/**
+ * 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.entity.cmp;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+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.stateless.BasicStatelessHome;
+import org.apache.openejb.test.stateless.BasicStatelessObject;
+
+import javax.ejb.EJBException;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+import javax.sql.DataSource;
+import java.rmi.RemoteException;
+import java.util.StringTokenizer;
+
+/**
+ * @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 ContextLookupCmpBean implements javax.ejb.EntityBean {
+
+    public static int key = 20;
+
+    public int primaryKey;
+    public String firstName;
+    public String lastName;
+    public EntityContext ejbContext;
+
+    //=============================
+    // Home interface methods
+    //
+
+    /**
+     * Maps to EncCmpHome.create
+     *
+     * @param name
+     * @return
+     * @throws javax.ejb.CreateException
+     * @see EncCmpHome#create
+     */
+    public Integer ejbCreate(String name)
+            throws javax.ejb.CreateException {
+        StringTokenizer st = new StringTokenizer(name, " ");
+        firstName = st.nextToken();
+        lastName = st.nextToken();
+        this.primaryKey = ContextLookupCmpBean.key++;
+        return null;
+    }
+
+    public void ejbPostCreate(String name)
+            throws javax.ejb.CreateException {
+    }
+
+    //
+    // Home interface methods
+    //=============================
+
+    //=============================
+    // Remote interface methods
+    //
+
+
+    public void lookupEntityBean() throws TestFailureException {
+        try {
+            try {
+                BasicCmpHome home = (BasicCmpHome) ejbContext.lookup("entity/cmp/beanReferences/cmp_entity");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicCmpObject object = home.create("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("entity/cmp/beanReferences/stateful");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicStatefulObject object = home.create("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("entity/cmp/beanReferences/stateless");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicStatelessObject object = home.create();
+                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("entity/cmp/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("entity/cmp/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("entity/cmp/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("entity/cmp/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("entity/cmp/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("entity/cmp/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("entity/cmp/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("entity/cmp/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("entity/cmp/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);
+        }
+    }
+    //
+    // Remote interface methods
+    //=============================
+
+    //================================
+    // EntityBean interface methods
+    //
+
+    /**
+     * A container invokes this method to instruct the
+     * instance to synchronize its state by loading it state from the
+     * underlying database.
+     */
+    public void ejbLoad() throws EJBException, RemoteException {
+    }
+
+    /**
+     * Set the associated entity context. The container invokes this method
+     * on an instance after the instance has been created.
+     */
+    public void setEntityContext(EntityContext ctx) throws EJBException, RemoteException {
+        ejbContext = ctx;
+    }
+
+    /**
+     * Unset the associated entity context. The container calls this method
+     * before removing the instance.
+     */
+    public void unsetEntityContext() throws EJBException, RemoteException {
+    }
+
+    /**
+     * A container invokes this method to instruct the
+     * instance to synchronize its state by storing it to the underlying
+     * database.
+     */
+    public void ejbStore() throws EJBException, RemoteException {
+    }
+
+    /**
+     * A container invokes this method before it removes the EJB object
+     * that is currently associated with the instance. This method
+     * is invoked when a client invokes a remove operation on the
+     * enterprise Bean's home interface or the EJB object's remote interface.
+     * This method transitions the instance from the ready state to the pool
+     * of available instances.
+     */
+    public void ejbRemove() throws RemoveException, EJBException, RemoteException {
+    }
+
+    /**
+     * A container invokes this method when the instance
+     * is taken out of the pool of available instances to become associated
+     * with a specific EJB object. This method transitions the instance to
+     * the ready state.
+     */
+    public void ejbActivate() throws EJBException, RemoteException {
+    }
+
+    /**
+     * A container invokes this method on an instance before the instance
+     * becomes disassociated with a specific EJB object. After this method
+     * completes, the container will place the instance into the pool of
+     * available instances.
+     */
+    public void ejbPassivate() throws EJBException, RemoteException {
+    }
+    //
+    // EntityBean interface methods
+    //================================
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java?view=auto&rev=483409
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java Thu Dec  7 02:43:45 2006
@@ -0,0 +1,355 @@
+/**
+ * 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.stateful;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import org.apache.openejb.test.TestFailureException;
+import org.apache.openejb.test.entity.bmp.BasicBmpHome;
+import org.apache.openejb.test.entity.bmp.BasicBmpObject;
+import org.apache.openejb.test.stateless.BasicStatelessHome;
+import org.apache.openejb.test.stateless.BasicStatelessObject;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionContext;
+import javax.ejb.SessionSynchronization;
+import javax.sql.DataSource;
+import java.rmi.RemoteException;
+
+/**
+ * @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 ContextLookupStatefulBean implements javax.ejb.SessionBean, SessionSynchronization {
+
+
+    private String name;
+    private SessionContext ejbContext;
+
+    //=============================
+    // Home interface methods
+    //
+
+    /**
+     * Maps to EncStatefulHome.create
+     *
+     * @param name
+     * @throws javax.ejb.CreateException
+     * @see EncStatefulHome#create
+     */
+    public void ejbCreate(String name)
+            throws javax.ejb.CreateException {
+        this.name = name;
+    }
+    //
+    // Home interface methods
+    //=============================
+
+    //=============================
+    // Remote interface methods
+    //
+
+    public void lookupEntityBean() throws TestFailureException {
+        try {
+            try {
+                BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateful/beanReferences/bmp_entity");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicBmpObject object = home.create("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("stateful/beanReferences/stateful");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicStatefulObject object = home.create("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("stateful/beanReferences/stateless");
+                Assert.assertNotNull("The EJBHome looked up is null", home);
+
+                BasicStatelessObject object = home.create();
+                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("stateful/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("stateful/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("stateful/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("stateful/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("stateful/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("stateful/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("stateful/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("stateful/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("stateful/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);
+        }
+    }
+    //
+    // Remote interface methods
+    //=============================
+
+    //=================================
+    // SessionBean interface methods
+    //
+
+    /**
+     * Set the associated session context. The container calls this method
+     * after the instance creation.
+     */
+    public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException {
+        ejbContext = ctx;
+    }
+
+    /**
+     * A container invokes this method before it ends the life of the session
+     * object. This happens as a result of a client's invoking a remove
+     * operation, or when a container decides to terminate the session object
+     * after a timeout.
+     */
+    public void ejbRemove() throws EJBException, RemoteException {
+    }
+
+    /**
+     * The activate method is called when the instance is activated
+     * from its "passive" state. The instance should acquire any resource
+     * that it has released earlier in the ejbPassivate() method.
+     */
+    public void ejbActivate() throws EJBException, RemoteException {
+    }
+
+    /**
+     * The passivate method is called before the instance enters
+     * the "passive" state. The instance should release any resources that
+     * it can re-acquire later in the ejbActivate() method.
+     */
+    public void ejbPassivate() throws EJBException, RemoteException {
+    }
+    //
+    // SessionBean interface methods
+    //==================================
+
+    //============================================
+    // SessionSynchronization interface methods
+    //
+
+    /**
+     * The afterBegin method notifies a session Bean instance that a new
+     * transaction has started, and that the subsequent business methods on the
+     * instance will be invoked in the context of the transaction.
+     */
+    public void afterBegin() throws EJBException, RemoteException {
+    }
+
+    /**
+     * The beforeCompletion method notifies a session Bean instance that
+     * a transaction is about to be committed. The instance can use this
+     * method, for example, to write any cached data to a database.
+     */
+    public void beforeCompletion() throws EJBException, RemoteException {
+    }
+
+    /**
+     * The afterCompletion method notifies a session Bean instance that a
+     * transaction commit protocol has completed, and tells the instance
+     * whether the transaction has been committed or rolled back.
+     */
+    public void afterCompletion(boolean committed) throws EJBException, RemoteException {
+    }
+    //
+    // SessionSynchronization interface methods
+    //============================================
+
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java?view=auto&rev=483409
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java Thu Dec  7 02:43:45 2006
@@ -0,0 +1,320 @@
+/**
+ * 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 junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import org.apache.openejb.test.TestFailureException;
+import org.apache.openejb.test.entity.bmp.BasicBmpHome;
+import org.apache.openejb.test.entity.bmp.BasicBmpObject;
+import org.apache.openejb.test.stateful.BasicStatefulHome;
+import org.apache.openejb.test.stateful.BasicStatefulObject;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionContext;
+import javax.sql.DataSource;
+import java.rmi.RemoteException;
+
+/**
+ * @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 ContextLookupStatelessBean implements javax.ejb.SessionBean {
+
+    private String name;
+    private SessionContext ejbContext;
+
+    //=============================
+    // Home interface methods
+    //
+    //
+    // Home interface methods
+    //=============================
+
+
+    //=============================
+    // Remote interface methods
+    //
+    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.create("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.create("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.create();
+                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);
+        }
+    }
+
+    //
+    // Remote interface methods
+    //=============================
+
+    //================================
+    // SessionBean interface methods
+    //
+
+    /**
+     * Set the associated session context. The container calls this method
+     * after the instance creation.
+     */
+    public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException {
+        ejbContext = ctx;
+    }
+
+    /**
+     * @throws javax.ejb.CreateException
+     */
+    public void ejbCreate() throws javax.ejb.CreateException {
+        this.name = "nameless automaton";
+    }
+
+    /**
+     * A container invokes this method before it ends the life of the session
+     * object. This happens as a result of a client's invoking a remove
+     * operation, or when a container decides to terminate the session object
+     * after a timeout.
+     */
+    public void ejbRemove() throws EJBException, RemoteException {
+    }
+
+    /**
+     * The activate method is called when the instance is activated
+     * from its "passive" state. The instance should acquire any resource
+     * that it has released earlier in the ejbPassivate() method.
+     */
+    public void ejbActivate() throws EJBException, RemoteException {
+        // Should never called.
+    }
+
+    /**
+     * The passivate method is called before the instance enters
+     * the "passive" state. The instance should release any resources that
+     * it can re-acquire later in the ejbActivate() method.
+     */
+    public void ejbPassivate() throws EJBException, RemoteException {
+        // Should never called.
+    }
+
+    //
+    // SessionBean interface methods
+    //================================
+}

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/cmp.mapping.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/cmp.mapping.xml?view=diff&rev=483409&r1=483408&r2=483409
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/cmp.mapping.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/cmp.mapping.xml Thu Dec  7 02:43:45 2006
@@ -114,6 +114,27 @@
   
   </class>
 
+  <class name="org.apache.openejb.test.entity.cmp.ContextLookupCmpBean"
+         identity="primaryKey">
+    <description>Simple Entity Bean</description>
+
+    <map-to table="entity" />
+
+    <field name="primaryKey" type="integer" direct="true" >
+      <sql name="id" type="integer"/>
+    </field>
+
+    <field name="firstName" type="string" direct="true" >
+      <sql name="first_name" type="char" dirty="check" />
+    </field>
+
+    <field name="lastName" type="string" direct="true" >
+      <sql name="last_name" type="char" dirty="check" />
+    </field>
+
+
+  </class>
+
 
   <class name="org.apache.openejb.test.entity.cmp.RmiIiopCmpBean"
          identity="primaryKey">