gdamour 2005/03/02 06:43:21
Modified: modules/itests/src/java/org/openejb/test/entity/cmp
BasicCmp2Bean.java BasicCmpBean.java
BasicCmpHome.java
Added: modules/itests/src/java/org/openejb/test/entity/cmp
SessionFacadeBean.java SessionFacadeHome.java
SessionFacadeObject.java
Log:
GERONIMO-580
o add an itests test verifying the correct behavior of the implementation.
GERONIMO-598
o add the flush-cache-before-query optional element, which identifies if
the transactional cache should be flushed before the execution of the
associated finder or select operation; and
o update the various XValuedFinder and XValuedSelect in order to flush
the transaction cache if required.
Revision Changes Path
1.4 +16 -2
openejb/modules/itests/src/java/org/openejb/test/entity/cmp/BasicCmp2Bean.java
Index: BasicCmp2Bean.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/itests/src/java/org/openejb/test/entity/cmp/BasicCmp2Bean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BasicCmp2Bean.java 16 Sep 2004 15:33:28 -0000 1.3
+++ BasicCmp2Bean.java 2 Mar 2005 11:43:20 -0000 1.4
@@ -47,6 +47,7 @@
import java.util.Hashtable;
import java.util.Properties;
import java.util.StringTokenizer;
+
import javax.ejb.CreateException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
@@ -87,7 +88,7 @@
}
/**
- * Maps to BasicCmpHome.create
+ * Maps to BasicCmpHome.create(String name)
*/
public Integer ejbCreate(String name) throws CreateException {
StringTokenizer st = new StringTokenizer(name, " ");
@@ -99,7 +100,20 @@
public void ejbPostCreate(String name) {
}
+
+ /**
+ * Maps to BasicCmpHome.create(Integer primarykey, String name)
+ */
+ public Integer ejbCreate(Integer primarykey, String name) throws
CreateException {
+ StringTokenizer st = new StringTokenizer(name, " ");
+ setFirstName(st.nextToken());
+ setLastName(st.nextToken());
+ setId(primarykey);
+ return null;
+ }
+ public void ejbPostCreate(Integer primarykey, String name) throws
CreateException {
+ }
//
// Home interface methods
//=============================
1.6 +16 -3
openejb/modules/itests/src/java/org/openejb/test/entity/cmp/BasicCmpBean.java
Index: BasicCmpBean.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/itests/src/java/org/openejb/test/entity/cmp/BasicCmpBean.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BasicCmpBean.java 13 Oct 2004 18:53:27 -0000 1.5
+++ BasicCmpBean.java 2 Mar 2005 11:43:21 -0000 1.6
@@ -98,7 +98,7 @@
}
/**
- * Maps to BasicCmpHome.create
+ * Maps to BasicCmpHome.create(String name)
*/
public Integer ejbCreate(String name) throws CreateException {
StringTokenizer st = new StringTokenizer(name, " ");
@@ -110,7 +110,20 @@
public void ejbPostCreate(String name) throws CreateException {
}
-
+
+ /**
+ * Maps to BasicCmpHome.create(Integer primarykey, String name)
+ */
+ public Integer ejbCreate(Integer primarykey, String name) throws
CreateException {
+ StringTokenizer st = new StringTokenizer(name, " ");
+ firstName = st.nextToken();
+ lastName = st.nextToken();
+ this.id = primarykey;
+ return null;
+ }
+
+ public void ejbPostCreate(Integer primarykey, String name) throws
CreateException {
+ }
//
// Home interface methods
//=============================
1.5 +3 -1
openejb/modules/itests/src/java/org/openejb/test/entity/cmp/BasicCmpHome.java
Index: BasicCmpHome.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/itests/src/java/org/openejb/test/entity/cmp/BasicCmpHome.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BasicCmpHome.java 13 Oct 2004 18:53:27 -0000 1.4
+++ BasicCmpHome.java 2 Mar 2005 11:43:21 -0000 1.5
@@ -51,6 +51,8 @@
public interface BasicCmpHome extends javax.ejb.EJBHome {
+ public BasicCmpObject create(Integer primarykey, String name) throws
CreateException, RemoteException;
+
public BasicCmpObject create(String name) throws CreateException,
RemoteException;
public BasicCmpObject findByPrimaryKey(Integer primarykey) throws
FinderException, RemoteException;
1.1
openejb/modules/itests/src/java/org/openejb/test/entity/cmp/SessionFacadeBean.java
Index: SessionFacadeBean.java
===================================================================
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: SessionFacadeBean.java,v 1.1 2005/03/02 11:43:21 gdamour Exp $
*/
package org.openejb.test.entity.cmp;
import java.rmi.RemoteException;
import java.util.Collection;
import javax.ejb.CreateException;
import javax.ejb.DuplicateKeyException;
import javax.ejb.EJBException;
import javax.ejb.ObjectNotFoundException;
import javax.ejb.SessionContext;
import javax.naming.InitialContext;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
import org.openejb.test.TestFailureException;
/**
*
*/
public class SessionFacadeBean implements javax.ejb.SessionBean {
private SessionContext ejbContext;
private InitialContext jndiContext;
//=============================
// Home interface methods
//
//
// Home interface methods
//=============================
//=============================
// Remote interface methods
//
/**
* execute a create-remove-create of the same CMP within a single TX.
*/
public void invokeCreateRemoveCreateSameCMP() throws TestFailureException
{
try {
try {
BasicCmpHome home = (BasicCmpHome)
javax.rmi.PortableRemoteObject.narrow(jndiContext.lookup("java:comp/env/ejb/BasicCmpBeanExplicitPK"),
BasicCmpHome.class);
Integer pk = new Integer(20);
BasicCmpObject object = home.create(pk, "Same Bean");
object.remove();
home.create(pk, "Same Bean");
} catch (Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " +
e.getMessage());
}
} catch (AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
/**
* execute a create-create of the same CMP within a single TX.
*/
public void invokeCreateCreateSameCMP() throws TestFailureException {
try {
try {
BasicCmpHome home = (BasicCmpHome)
javax.rmi.PortableRemoteObject.narrow(jndiContext.lookup("java:comp/env/ejb/BasicCmpBeanExplicitPK"),
BasicCmpHome.class);
Integer pk = new Integer(20);
home.create(pk, "Same Bean");
home.create(pk, "Same Bean");
Assert.fail("Should have thrown DuplicateKeyException");
} catch (DuplicateKeyException e) {
} catch (Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " +
e.getMessage());
}
} catch (AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
/**
* execute a create-find with force cache flush before find.
*/
public void invokeCreateFindNoForceCacheFlush() throws
TestFailureException {
try {
try {
BasicCmpHome home = (BasicCmpHome)
javax.rmi.PortableRemoteObject.narrow(jndiContext.lookup("java:comp/env/ejb/BasicCmpBeanExplicitPK"),
BasicCmpHome.class);
Integer pk = new Integer(20);
home.create(pk, "Same Bean");
home.findByPrimaryKey(pk);
} catch (ObjectNotFoundException e) {
} catch (Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " +
e.getMessage());
}
} catch (AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
/**
* execute a create-find without force cache flush before find.
*/
public void invokeCreateFindForceCacheFlush() throws TestFailureException
{
try {
try {
BasicCmpHome home = (BasicCmpHome)
javax.rmi.PortableRemoteObject.narrow(jndiContext.lookup("java:comp/env/ejb/BasicCmpBeanExplicitPK"),
BasicCmpHome.class);
Integer pk = new Integer(20);
home.create(pk, "Same Bean");
Collection objects = home.findByLastName("Bean");
Assert.assertEquals(1, objects.size());
BasicCmpObject object = (BasicCmpObject)
objects.iterator().next();
Assert.assertEquals(pk, object.getPrimaryKey());
} catch (Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " +
e.getMessage());
}
} catch (AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
//
// Remote interface methods
//=============================
//=================================
// SessionBean interface methods
//
public void ejbCreate() throws javax.ejb.CreateException{
try {
jndiContext = new InitialContext();
} catch (Exception e){
throw new CreateException("Can not get the initial context:
"+e.getMessage());
}
}
public void setSessionContext(SessionContext ctx) throws
EJBException,RemoteException {
ejbContext = ctx;
}
public void ejbRemove() throws EJBException,RemoteException {
}
public void ejbActivate() throws EJBException,RemoteException {
}
public void ejbPassivate() throws EJBException,RemoteException {
}
//
// SessionBean interface methods
//==================================
}
1.1
openejb/modules/itests/src/java/org/openejb/test/entity/cmp/SessionFacadeHome.java
Index: SessionFacadeHome.java
===================================================================
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: SessionFacadeHome.java,v 1.1 2005/03/02 11:43:21 gdamour Exp $
*/
package org.openejb.test.entity.cmp;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
/**
*
*/
public interface SessionFacadeHome extends javax.ejb.EJBHome {
public SessionFacadeObject create() throws CreateException,
RemoteException;
}
1.1
openejb/modules/itests/src/java/org/openejb/test/entity/cmp/SessionFacadeObject.java
Index: SessionFacadeObject.java
===================================================================
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: SessionFacadeObject.java,v 1.1 2005/03/02 11:43:21 gdamour Exp $
*/
package org.openejb.test.entity.cmp;
import java.rmi.RemoteException;
import org.openejb.test.TestFailureException;
/**
*
*/
public interface SessionFacadeObject extends javax.ejb.EJBObject{
public void invokeCreateRemoveCreateSameCMP() throws RemoteException,
TestFailureException;
public void invokeCreateCreateSameCMP() throws RemoteException,
TestFailureException;
public void invokeCreateFindNoForceCacheFlush() throws
TestFailureException;
public void invokeCreateFindForceCacheFlush() throws TestFailureException;
}