You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by al...@apache.org on 2009/12/25 20:12:35 UTC
svn commit: r893878 -
/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestBadAutoDetachProperty.java
Author: allee8285
Date: Fri Dec 25 19:12:35 2009
New Revision: 893878
URL: http://svn.apache.org/viewvc?rev=893878&view=rev
Log:
Fix test cases adapting to Geronimo Persistence class single/multiple providers behaviors.
Modified:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestBadAutoDetachProperty.java
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestBadAutoDetachProperty.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestBadAutoDetachProperty.java?rev=893878&r1=893877&r2=893878&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestBadAutoDetachProperty.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestBadAutoDetachProperty.java Fri Dec 25 19:12:35 2009
@@ -18,15 +18,17 @@
*/
package org.apache.openjpa.conf;
-import java.util.*;
+import java.util.HashMap;
-import javax.persistence.*;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
import javax.persistence.PersistenceException;
-import junit.framework.*;
+import junit.framework.TestCase;
import org.apache.openjpa.lib.util.ParseException;
-import org.apache.openjpa.persistence.*;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
public class TestBadAutoDetachProperty extends TestCase {
public void testEmptyValue() {
@@ -50,12 +52,20 @@
emf.close();
} catch (PersistenceException e) {
Throwable cause = e.getCause();
- while (cause instanceof PersistenceException)
- cause = ((PersistenceException) cause).getCause();
- if (!(cause instanceof ParseException)) {
- fail("Should have caught PersistenceException whose cause was "
- + "a ParseException. " + "Instead the cause was: "
- + cause);
+ if (cause != null) {
+ // Geronimo Persistence.class single provider semantics
+ while (cause instanceof PersistenceException)
+ cause = ((PersistenceException) cause).getCause();
+ if (!(cause instanceof ParseException)) {
+ fail("Should have caught PersistenceException whose cause was " + "a ParseException. "
+ + "Instead the cause was: " + cause);
+ }
+ } else {
+ // Geronimo Persistence.class multiple providers semantics
+ String msg = e.getMessage();
+ if (msg.indexOf("org.apache.openjpa.lib.util.ParseException") == -1)
+ fail("Should have caught PersistenceException whose cause was " + "a ParseException. "
+ + "Instead the cause was: " + cause);
}
} catch (RuntimeException e) {
fail("Should have caught a PersistenceException, instead caught: "
@@ -74,12 +84,20 @@
emf.close();
} catch (PersistenceException e) {
Throwable cause = e.getCause();
- while (cause instanceof PersistenceException)
- cause = ((PersistenceException) cause).getCause();
- if (!(cause instanceof ParseException)) {
- fail("Should have caught PersistenceException whose cause was "
- + "a ParseException. " + "Instead the cause was: "
- + cause);
+ if (cause != null) {
+ // Geronimo Persistence.class single provider semantics
+ while (cause instanceof PersistenceException)
+ cause = ((PersistenceException) cause).getCause();
+ if (!(cause instanceof ParseException)) {
+ fail("Should have caught PersistenceException whose cause was " + "a ParseException. "
+ + "Instead the cause was: " + cause);
+ }
+ } else {
+ // Geronimo Persistence.class multiple providers semantics
+ String msg = e.getMessage();
+ if (msg.indexOf("org.apache.openjpa.lib.util.ParseException") == -1)
+ fail("Should have caught PersistenceException whose cause was " + "a ParseException. "
+ + "Instead the cause was: " + cause);
}
} catch (RuntimeException e) {
fail("Should have caught a PersistenceException, instead caught: "