OPENJPA-766: Allow an explanatory message for @AllowFailure tests

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@748185 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2009-02-26 15:47:00 +00:00
parent bf16127d19
commit a9c858b39a
4 changed files with 13 additions and 16 deletions

View File

@ -825,7 +825,7 @@ public class TestJPA2LockManager extends LockManagerTestBase {
}
// 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 @@ public class TestJPA2LockManager extends LockManagerTestBase {
}
// 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 "

View File

@ -133,7 +133,7 @@ public class TestPessimisticLockManager extends LockManagerTestBase {
}
// 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 @@ public class TestPessimisticLockManager extends LockManagerTestBase {
}
// 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 @@ public class TestPessimisticLockManager extends LockManagerTestBase {
}
// 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 @@ public class TestPessimisticLockManager extends LockManagerTestBase {
}
// 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 "

View File

@ -34,5 +34,5 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface AllowFailure {
boolean value() default true;
String msg() default "";
String message() default "";
}

View File

@ -452,11 +452,11 @@ public abstract class PersistenceTestCase
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 @@ public abstract class PersistenceTestCase
* @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);
}
/**