You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/03/28 03:21:21 UTC
svn commit: r523133 - in /incubator/openejb/trunk/openejb3:
container/openejb-core/src/main/java/org/apache/openejb/core/cmp/
itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/
itests/openejb-itests-client/src/main/java/org/...
Author: dain
Date: Tue Mar 27 18:21:20 2007
New Revision: 523133
URL: http://svn.apache.org/viewvc?view=rev&rev=523133
Log:
Added Entity home remove tests
Fixed remote client home exception handling
Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/CmpContainer.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbObjectTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbObjectTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbObjectTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbObjectTests.java
incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java
incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java
incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatelessEJBHomeHandler.java
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/CmpContainer.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/CmpContainer.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/CmpContainer.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/CmpContainer.java Tue Mar 27 18:21:20 2007
@@ -630,6 +630,8 @@
// create a new ProxyInfo based on the deployment info and primary key
return new ProxyInfo(deploymentInfo, primaryKey, objectInterface, this);
+ } catch (javax.ejb.FinderException fe) {
+ txPolicy.handleApplicationException(fe, txContext);
} catch (Throwable e) {// handle reflection exception
txPolicy.handleSystemException(e, null, txContext);
} finally {
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbHomeTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbHomeTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbHomeTests.java Tue Mar 27 18:21:20 2007
@@ -17,6 +17,7 @@
package org.apache.openejb.test.entity.bmp;
import javax.ejb.EJBMetaData;
+import javax.ejb.ObjectNotFoundException;
/**
* [3] Should be run as the third test suite of the BasicBmpTestClients
@@ -59,18 +60,68 @@
}
}
- public void test03_remove(){
+ public void test03_removeByPrimaryKey(){
try{
+ // remove the ejb
ejbHome.remove(ejbPrimaryKey);
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
+ ejbObject.businessMethod("Should throw an exception");
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
+ }
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ e.printStackTrace();
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test04_removeByPrimaryHandle(){
+ try{
+ // remove the ejb
+ ejbHome.remove(ejbObject.getHandle());
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
try{
ejbObject.businessMethod("Should throw an exception");
assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
} catch (Exception e){
- assertTrue( true );
- return;
}
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
} catch (Exception e){
+ e.printStackTrace();
fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test05_ejbHomeMethod() {
+ try {
+ assertEquals(8+9, ejbHome.sum(8, 9));
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
//
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbObjectTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbObjectTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/bmp/BmpEjbObjectTests.java Tue Mar 27 18:21:20 2007
@@ -17,6 +17,7 @@
package org.apache.openejb.test.entity.bmp;
import javax.ejb.EJBHome;
+import javax.ejb.ObjectNotFoundException;
/**
* [4] Should be run as the fourth test suite of the BasicBmpTestClients
@@ -89,13 +90,21 @@
public void test05_remove(){
try{
+ // remove the ejb
ejbObject.remove();
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
try{
ejbObject.businessMethod("Should throw an exception");
assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
} catch (Exception e){
- assertTrue( true );
- return;
}
} 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/entity/cmp/CmpEjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbHomeTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbHomeTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbHomeTests.java Tue Mar 27 18:21:20 2007
@@ -17,6 +17,7 @@
package org.apache.openejb.test.entity.cmp;
import javax.ejb.EJBMetaData;
+import javax.ejb.ObjectNotFoundException;
/**
* [3] Should be run as the third test suite of the BasicCmpTestClients
@@ -59,18 +60,67 @@
}
}
- public void test03_remove(){
+ public void test03_removeByPrimaryKey(){
try{
+ // remove the ejb
ejbHome.remove(ejbPrimaryKey);
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
+ ejbObject.businessMethod("Should throw an exception");
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
+ }
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test04_removeByPrimaryHandle(){
+ try{
+ // remove the ejb
+ ejbHome.remove(ejbObject.getHandle());
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
try{
ejbObject.businessMethod("Should throw an exception");
assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
} catch (Exception e){
- assertTrue( true );
- return;
}
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
} catch (Exception e){
+ e.printStackTrace();
fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test05_ejbHomeMethod() {
+ try {
+ assertEquals(8+9, ejbHome.sum(8, 9));
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
//
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbObjectTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbObjectTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpEjbObjectTests.java Tue Mar 27 18:21:20 2007
@@ -17,6 +17,7 @@
package org.apache.openejb.test.entity.cmp;
import javax.ejb.EJBHome;
+import javax.ejb.ObjectNotFoundException;
/**
* [4] Should be run as the fourth test suite of the BasicCmpTestClients
@@ -89,13 +90,21 @@
public void test05_remove(){
try{
+ // remove the ejb
ejbObject.remove();
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
try{
ejbObject.businessMethod("Should throw an exception");
assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
} catch (Exception e){
- assertTrue( true );
- return;
}
} 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/entity/cmp/ComplexEjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java Tue Mar 27 18:21:20 2007
@@ -18,6 +18,7 @@
package org.apache.openejb.test.entity.cmp;
import javax.ejb.EJBMetaData;
+import javax.ejb.ObjectNotFoundException;
import javax.rmi.PortableRemoteObject;
/**
@@ -61,16 +62,66 @@
}
}
- public void test03_remove() {
- try {
+ public void test03_removeByPrimaryKey(){
+ try{
+ // remove the ejb
ejbHome.remove(ejbPrimaryKey);
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test04_removeByPrimaryHandle(){
+ try{
+ // remove the ejb
+ ejbHome.remove(ejbObject.getHandle());
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
+ ejbObject.businessMethod("Should throw an exception");
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
+ }
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ e.printStackTrace();
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test05_ejbHomeMethod() {
+ try {
+ assertEquals(8+9, ejbHome.sum(8, 9));
+ } catch (Throwable e) {
+ e.printStackTrace();
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java Tue Mar 27 18:21:20 2007
@@ -18,6 +18,7 @@
package org.apache.openejb.test.entity.cmp;
import javax.ejb.EJBHome;
+import javax.ejb.ObjectNotFoundException;
import javax.rmi.PortableRemoteObject;
/**
@@ -91,18 +92,27 @@
}
}
- public void test05_remove() {
- try {
+ public void test05_remove(){
+ try{
+ // remove the ejb
ejbObject.remove();
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
- fail("Received Exception " + e.getClass() + " : " + e.getMessage());
- } finally {
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ } finally{
ejbObject = null;
}
}
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java Tue Mar 27 18:21:20 2007
@@ -19,6 +19,7 @@
import javax.rmi.PortableRemoteObject;
import javax.ejb.EJBMetaData;
+import javax.ejb.ObjectNotFoundException;
/**
* [3] Should be run as the third test suite of the UnknownCmpTestClients
@@ -61,16 +62,66 @@
}
}
- public void test03_remove() {
- try {
+ public void test03_removeByPrimaryKey(){
+ try{
+ // remove the ejb
ejbHome.remove(ejbPrimaryKey);
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey(ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test04_removeByPrimaryHandle(){
+ try{
+ // remove the ejb
+ ejbHome.remove(ejbObject.getHandle());
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey(ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
+ ejbObject.businessMethod("Should throw an exception");
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
+ }
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ e.printStackTrace();
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test05_ejbHomeMethod() {
+ try {
+ assertEquals(8+9, ejbHome.sum(8, 9));
+ } catch (Throwable e) {
+ e.printStackTrace();
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java Tue Mar 27 18:21:20 2007
@@ -19,6 +19,7 @@
import javax.rmi.PortableRemoteObject;
import javax.ejb.EJBHome;
+import javax.ejb.ObjectNotFoundException;
/**
* [4] Should be run as the fourth test suite of the UnknownCmpTestClients
@@ -90,18 +91,27 @@
}
}
- public void test05_remove() {
- try {
+ public void test05_remove(){
+ try{
+ // remove the ejb
ejbObject.remove();
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey(ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
- fail("Received Exception " + e.getClass() + " : " + e.getMessage());
- } finally {
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ } finally{
ejbObject = null;
}
}
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java Tue Mar 27 18:21:20 2007
@@ -17,6 +17,7 @@
package org.apache.openejb.test.entity.cmp2;
import javax.ejb.EJBMetaData;
+import javax.ejb.ObjectNotFoundException;
import org.apache.openejb.test.entity.cmp.BasicCmpHome;
@@ -58,21 +59,62 @@
}
}
- public void test03_remove() {
- try {
+ public void test03_removeByPrimaryKey(){
+ try{
+ // remove the ejb
ejbHome.remove(ejbPrimaryKey);
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
- fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test04_removeByPrimaryHandle(){
+ try{
+ // remove the ejb
+ ejbHome.remove(ejbObject.getHandle());
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
+ ejbObject.businessMethod("Should throw an exception");
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
+ }
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ e.printStackTrace();
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
}
}
- public void test04_ejbHomeMethod() {
+ public void test05_ejbHomeMethod() {
try {
assertEquals(8+9, ejbHome.sum(8, 9));
} catch (Throwable e) {
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbObjectTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbObjectTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbObjectTests.java Tue Mar 27 18:21:20 2007
@@ -17,6 +17,7 @@
package org.apache.openejb.test.entity.cmp2;
import javax.ejb.EJBHome;
+import javax.ejb.ObjectNotFoundException;
import org.apache.openejb.test.entity.cmp.BasicCmpHome;
@@ -88,13 +89,21 @@
public void test05_remove() {
try {
+ // remove the ejb
ejbObject.remove();
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey((Integer) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
- return;
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
} 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/entity/cmp2/Complex2EjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java Tue Mar 27 18:21:20 2007
@@ -18,8 +18,10 @@
package org.apache.openejb.test.entity.cmp2;
import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+import org.apache.openejb.test.entity.cmp.ComplexCmpBeanPk;
import javax.ejb.EJBMetaData;
+import javax.ejb.ObjectNotFoundException;
/**
* [3] Should be run as the third test suite of the BasicCmpTestClients
@@ -59,21 +61,62 @@
}
}
- public void test03_remove() {
- try {
+ public void test03_removeByPrimaryKey(){
+ try{
+ // remove the ejb
ejbHome.remove(ejbPrimaryKey);
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
- fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test04_removeByPrimaryHandle(){
+ try{
+ // remove the ejb
+ ejbHome.remove(ejbObject.getHandle());
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
+ ejbObject.businessMethod("Should throw an exception");
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
+ }
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ e.printStackTrace();
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
}
}
- public void test04_ejbHomeMethod() {
+ public void test05_ejbHomeMethod() {
try {
assertEquals(8+9, ejbHome.sum(8, 9));
} catch (Throwable e) {
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java Tue Mar 27 18:21:20 2007
@@ -18,8 +18,10 @@
package org.apache.openejb.test.entity.cmp2;
import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+import org.apache.openejb.test.entity.cmp.ComplexCmpBeanPk;
import javax.ejb.EJBHome;
+import javax.ejb.ObjectNotFoundException;
/**
* [4] Should be run as the fourth test suite of the BasicCmpTestClients
@@ -87,18 +89,27 @@
}
}
- public void test05_remove() {
- try {
+ public void test05_remove(){
+ try{
+ // remove the ejb
ejbObject.remove();
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
- fail("Received Exception " + e.getClass() + " : " + e.getMessage());
- } finally {
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ } finally{
ejbObject = null;
}
}
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbHomeTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbHomeTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbHomeTests.java Tue Mar 27 18:21:20 2007
@@ -20,6 +20,7 @@
import org.apache.openejb.test.entity.cmp.UnknownCmpHome;
import javax.ejb.EJBMetaData;
+import javax.ejb.ObjectNotFoundException;
/**
* [3] Should be run as the third test suite of the BasicCmpTestClients
@@ -59,21 +60,62 @@
}
}
- public void test03_remove() {
- try {
+ public void test03_removeByPrimaryKey(){
+ try{
+ // remove the ejb
ejbHome.remove(ejbPrimaryKey);
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey(ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
- fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ public void test04_removeByPrimaryHandle(){
+ try{
+ // remove the ejb
+ ejbHome.remove(ejbObject.getHandle());
+
+ // verify that the ejb was actually removed
+ try {
+ ejbHome.findByPrimaryKey(ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
+ ejbObject.businessMethod("Should throw an exception");
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
+ }
+
+ // create a new ejb for the next test
+ ejbObject = ejbHome.createObject("Second Bean");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ } catch (Exception e){
+ e.printStackTrace();
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
}
}
- public void test04_ejbHomeMethod() {
+ public void test05_ejbHomeMethod() {
try {
assertEquals(8+9, ejbHome.sum(8, 9));
} catch (Throwable e) {
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbObjectTests.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbObjectTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Unknown2EjbObjectTests.java Tue Mar 27 18:21:20 2007
@@ -20,6 +20,7 @@
import org.apache.openejb.test.entity.cmp.UnknownCmpHome;
import javax.ejb.EJBHome;
+import javax.ejb.ObjectNotFoundException;
/**
* [4] Should be run as the fourth test suite of the BasicCmpTestClients
@@ -87,18 +88,27 @@
}
}
- public void test05_remove() {
- try {
+ public void test05_remove(){
+ try{
+ // remove the ejb
ejbObject.remove();
+
+ // verify that the ejb was actually removed
try {
+ ejbHome.findByPrimaryKey(ejbPrimaryKey);
+ fail("Entity was not actually removed");
+ } catch (ObjectNotFoundException e) {
+ }
+
+ // verify the proxy is dead
+ try{
ejbObject.businessMethod("Should throw an exception");
- assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
- } catch (Exception e) {
- assertTrue(true);
+ assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false );
+ } catch (Exception e){
}
- } catch (Exception e) {
- fail("Received Exception " + e.getClass() + " : " + e.getMessage());
- } finally {
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ } finally{
ejbObject = null;
}
}
Modified: incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java (original)
+++ incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java Tue Mar 27 18:21:20 2007
@@ -144,12 +144,24 @@
return homeMethod(method, args, proxy);
}
- } catch (SystemException se) {
+ } catch (SystemException e) {
invalidateReference();
- throw new RemoteException("Container has suffered a SystemException", se.getCause());
+ throw e.getCause();
+ /*
+ * Application exceptions must be reported dirctly to the client. They
+ * do not impact the viability of the proxy.
+ */
+ } catch (ApplicationException ae) {
+ throw ae.getCause();
+ /*
+ * A system exception would be highly unusual and would indicate a sever
+ * problem with the container system.
+ */
} catch (SystemError se) {
invalidateReference();
throw new RemoteException("Container has suffered a SystemException", se.getCause());
+ } catch (Throwable oe) {
+ throw new RemoteException("Unknown Container Exception", oe.getCause());
}
}
Modified: incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java (original)
+++ incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java Tue Mar 27 18:21:20 2007
@@ -17,6 +17,7 @@
package org.apache.openejb.client;
import java.lang.reflect.Method;
+import java.rmi.RemoteException;
import javax.ejb.RemoveException;
@@ -30,11 +31,11 @@
}
protected Object findX(Method method, Object[] args, Object proxy) throws Throwable {
- throw new UnsupportedOperationException("Stateful beans may not have find methods");
+ throw new SystemException(new UnsupportedOperationException("Stateful beans may not have find methods"));
}
protected Object removeByPrimaryKey(Method method, Object[] args, Object proxy) throws Throwable {
- throw new RemoveException("Session objects are private resources and do not have primary keys");
+ throw new ApplicationException(new RemoveException("Session objects are private resources and do not have primary keys"));
}
protected Object removeWithHandle(Method method, Object[] args, Object proxy) throws Throwable {
@@ -47,7 +48,7 @@
Object primKey = handler.primaryKey;
if (!handler.ejb.deploymentID.equals(this.ejb.deploymentID)) {
- throw new IllegalArgumentException("The handle is not from the same deployment");
+ throw new SystemException(new IllegalArgumentException("The handle is not from the same deployment"));
}
EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_HOME_REMOVE_BY_HANDLE);
@@ -59,12 +60,20 @@
EJBResponse res = request(req);
- if (res.getResponseCode() == ResponseCodes.EJB_ERROR) {
- throw (Throwable) res.getResult();
+ switch (res.getResponseCode()) {
+ case ResponseCodes.EJB_ERROR:
+ throw new SystemError((ThrowableArtifact) res.getResult());
+ case ResponseCodes.EJB_SYS_EXCEPTION:
+ throw new SystemException((ThrowableArtifact) res.getResult());
+ case ResponseCodes.EJB_APP_EXCEPTION:
+ throw new ApplicationException((ThrowableArtifact) res.getResult());
+ case ResponseCodes.EJB_OK:
+ invalidateAllHandlers(handler.getRegistryId());
+ handler.invalidateReference();
+ return null;
+ default:
+ throw new RemoteException("Received invalid response code from server: " + res.getResponseCode());
}
- invalidateAllHandlers(handler.getRegistryId());
- handler.invalidateReference();
- return null;
}
}
Modified: incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatelessEJBHomeHandler.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatelessEJBHomeHandler.java?view=diff&rev=523133&r1=523132&r2=523133
==============================================================================
--- incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatelessEJBHomeHandler.java (original)
+++ incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/StatelessEJBHomeHandler.java Tue Mar 27 18:21:20 2007
@@ -30,11 +30,11 @@
}
protected Object findX(Method method, Object[] args, Object proxy) throws Throwable {
- throw new UnsupportedOperationException("Stateful beans may not have find methods");
+ throw new SystemException(new UnsupportedOperationException("Stateful beans may not have find methods"));
}
protected Object removeByPrimaryKey(Method method, Object[] args, Object proxy) throws Throwable {
- throw new RemoveException("Session objects are private resources and do not have primary keys");
+ throw new ApplicationException(new RemoveException("Session objects are private resources and do not have primary keys"));
}
/*
@@ -50,10 +50,10 @@
if (handle == null) throw new NullPointerException("The handle is null");
- EJBObjectHandler handler = (EJBObjectHandler) handle.ejbObjectProxy.getEJBObjectHandler();
+ EJBObjectHandler handler = handle.ejbObjectProxy.getEJBObjectHandler();
if (!handler.ejb.deploymentID.equals(this.ejb.deploymentID)) {
- throw new IllegalArgumentException("The handle is not from the same deployment");
+ throw new SystemException(new IllegalArgumentException("The handle is not from the same deployment"));
}
handler.invalidateReference();