You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pp...@apache.org on 2009/02/26 16:47:02 UTC

svn commit: r748185 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence: lockmgr/TestJPA2LockManager.java lockmgr/TestPessimisticLockManager.java test/AllowFailure.java test/PersistenceTestCase.java

Author: ppoddar
Date: Thu Feb 26 15:47:00 2009
New Revision: 748185

URL: http://svn.apache.org/viewvc?rev=748185&view=rev
Log:
OPENJPA-766: Allow an explanatory message for @AllowFailure tests

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestJPA2LockManager.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestPessimisticLockManager.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AllowFailure.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestJPA2LockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestJPA2LockManager.java?rev=748185&r1=748184&r2=748185&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestJPA2LockManager.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestJPA2LockManager.java Thu Feb 26 15:47:00 2009
@@ -825,7 +825,7 @@
     }
         
     // TODO:
-    @AllowFailure(msg="OPENJPA-924 is preventing RR behavior: pessimistic lock "
+    @AllowFailure(message="OPENJPA-924 is preventing RR behavior: pessimistic lock "
         + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
         + "with pre-thread 1 committed data. hence causing an "
         + "OptimisticLockException. Disable FinderCache to workaround the " 
@@ -1192,7 +1192,7 @@
     }
 
     // TODO:
-    @AllowFailure(msg="OPENJPA-924 is preventing RR behavior: pessimistic lock "
+    @AllowFailure(message="OPENJPA-924 is preventing RR behavior: pessimistic lock "
         + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
         + "with pre-thread 1 committed data. hence causing an "
         + "OptimisticLockException. Disable FinderCache to workaround the " 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestPessimisticLockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestPessimisticLockManager.java?rev=748185&r1=748184&r2=748185&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestPessimisticLockManager.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestPessimisticLockManager.java Thu Feb 26 15:47:00 2009
@@ -133,7 +133,7 @@
     }
     
     // TODO:
-    @AllowFailure(msg="OPENJPA-924 is preventing RR behavior: pessimistic lock "
+    @AllowFailure(message="OPENJPA-924 is preventing RR behavior: pessimistic lock "
         + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
         + "with pre-thread 1 committed data. hence causing an "
         + "OptimisticLockException. Disable FinderCache to workaround the " 
@@ -488,7 +488,7 @@
     }
         
     // TODO:
-    @AllowFailure(msg="OPENJPA-924 is preventing RR behavior: pessimistic lock "
+    @AllowFailure(message="OPENJPA-924 is preventing RR behavior: pessimistic lock "
         + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
         + "with pre-thread 1 committed data. hence causing an "
         + "OptimisticLockException. Disable FinderCache to workaround the " 
@@ -843,7 +843,7 @@
     }
         
     // TODO:
-    @AllowFailure(msg="OPENJPA-924 is preventing RR behavior: pessimistic lock "
+    @AllowFailure(message="OPENJPA-924 is preventing RR behavior: pessimistic lock "
         + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
         + "with pre-thread 1 committed data. hence causing an "
         + "OptimisticLockException. Disable FinderCache to workaround the " 
@@ -1210,7 +1210,7 @@
     }
 
     // TODO:
-    @AllowFailure(msg="OPENJPA-924 is preventing RR behavior: pessimistic lock "
+    @AllowFailure(message="OPENJPA-924 is preventing RR behavior: pessimistic lock "
         + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
         + "with pre-thread 1 committed data. hence causing an "
         + "OptimisticLockException. Disable FinderCache to workaround the " 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AllowFailure.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AllowFailure.java?rev=748185&r1=748184&r2=748185&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AllowFailure.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AllowFailure.java Thu Feb 26 15:47:00 2009
@@ -34,5 +34,5 @@
 @Retention(RUNTIME)
 public @interface AllowFailure {
     boolean value() default true;
-    String msg() default "";
+    String message() default "";
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java?rev=748185&r1=748184&r2=748185&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java Thu Feb 26 15:47:00 2009
@@ -452,11 +452,11 @@
         try {
             super.runBare();
         } catch (Throwable t) {
-            String allowFailureMsg = getAllowFailureMsg(); 
-            if ( allowFailureMsg != null ) {
+            AllowFailure allowFailure = getAllowFailure();
+            if ( allowFailure != null && allowFailure.value()==true) {
                 System.err.println("*** FAILED (but ignored): " + this);
                 System.err.println("***              Reason : " 
-                    + allowFailureMsg);
+                    + allowFailure.message());
                 System.err.println("Stacktrace of failure");
                 t.printStackTrace();
             } else {
@@ -470,21 +470,18 @@
      * @AllowFailure. Method level annotation has higher precedence than Class
      * level annotation.
      */
-    protected String getAllowFailureMsg() {
+    protected AllowFailure getAllowFailure() {
 		try {
             Method runMethod = getClass().getMethod(getName(), (Class[])null);
             AllowFailure anno = runMethod.getAnnotation(AllowFailure.class);
 	    	if (anno != null)
-	    		return anno.value() ? anno.msg() : null;
+	    		return anno;
 		} catch (SecurityException e) {
 			//ignore
 		} catch (NoSuchMethodException e) {
 			//ignore
 		}
-		AllowFailure anno = getClass().getAnnotation(AllowFailure.class);
-    	if (anno != null) 
-            return anno.value() ? anno.msg() : null;
-    	return null;
+		return getClass().getAnnotation(AllowFailure.class);
     }
     
     /**