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: // 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 " + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
+ "with pre-thread 1 committed data. hence causing an " + "with pre-thread 1 committed data. hence causing an "
+ "OptimisticLockException. Disable FinderCache to workaround the " + "OptimisticLockException. Disable FinderCache to workaround the "
@ -1192,7 +1192,7 @@ public class TestJPA2LockManager extends LockManagerTestBase {
} }
// TODO: // 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 " + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
+ "with pre-thread 1 committed data. hence causing an " + "with pre-thread 1 committed data. hence causing an "
+ "OptimisticLockException. Disable FinderCache to workaround the " + "OptimisticLockException. Disable FinderCache to workaround the "

View File

@ -133,7 +133,7 @@ public class TestPessimisticLockManager extends LockManagerTestBase {
} }
// TODO: // 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 " + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
+ "with pre-thread 1 committed data. hence causing an " + "with pre-thread 1 committed data. hence causing an "
+ "OptimisticLockException. Disable FinderCache to workaround the " + "OptimisticLockException. Disable FinderCache to workaround the "
@ -488,7 +488,7 @@ public class TestPessimisticLockManager extends LockManagerTestBase {
} }
// TODO: // 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 " + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
+ "with pre-thread 1 committed data. hence causing an " + "with pre-thread 1 committed data. hence causing an "
+ "OptimisticLockException. Disable FinderCache to workaround the " + "OptimisticLockException. Disable FinderCache to workaround the "
@ -843,7 +843,7 @@ public class TestPessimisticLockManager extends LockManagerTestBase {
} }
// TODO: // 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 " + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
+ "with pre-thread 1 committed data. hence causing an " + "with pre-thread 1 committed data. hence causing an "
+ "OptimisticLockException. Disable FinderCache to workaround the " + "OptimisticLockException. Disable FinderCache to workaround the "
@ -1210,7 +1210,7 @@ public class TestPessimisticLockManager extends LockManagerTestBase {
} }
// TODO: // 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 " + "blocked read on thread 2, once thread-1 commit, thread-2 returns "
+ "with pre-thread 1 committed data. hence causing an " + "with pre-thread 1 committed data. hence causing an "
+ "OptimisticLockException. Disable FinderCache to workaround the " + "OptimisticLockException. Disable FinderCache to workaround the "

View File

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

View File

@ -452,11 +452,11 @@ public abstract class PersistenceTestCase
try { try {
super.runBare(); super.runBare();
} catch (Throwable t) { } catch (Throwable t) {
String allowFailureMsg = getAllowFailureMsg(); AllowFailure allowFailure = getAllowFailure();
if ( allowFailureMsg != null ) { if ( allowFailure != null && allowFailure.value()==true) {
System.err.println("*** FAILED (but ignored): " + this); System.err.println("*** FAILED (but ignored): " + this);
System.err.println("*** Reason : " System.err.println("*** Reason : "
+ allowFailureMsg); + allowFailure.message());
System.err.println("Stacktrace of failure"); System.err.println("Stacktrace of failure");
t.printStackTrace(); t.printStackTrace();
} else { } else {
@ -470,21 +470,18 @@ public abstract class PersistenceTestCase
* @AllowFailure. Method level annotation has higher precedence than Class * @AllowFailure. Method level annotation has higher precedence than Class
* level annotation. * level annotation.
*/ */
protected String getAllowFailureMsg() { protected AllowFailure getAllowFailure() {
try { try {
Method runMethod = getClass().getMethod(getName(), (Class[])null); Method runMethod = getClass().getMethod(getName(), (Class[])null);
AllowFailure anno = runMethod.getAnnotation(AllowFailure.class); AllowFailure anno = runMethod.getAnnotation(AllowFailure.class);
if (anno != null) if (anno != null)
return anno.value() ? anno.msg() : null; return anno;
} catch (SecurityException e) { } catch (SecurityException e) {
//ignore //ignore
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
//ignore //ignore
} }
AllowFailure anno = getClass().getAnnotation(AllowFailure.class); return getClass().getAnnotation(AllowFailure.class);
if (anno != null)
return anno.value() ? anno.msg() : null;
return null;
} }
/** /**