mirror of https://github.com/apache/openjpa.git
OPENJPA-1234:
AllowFailure checks for system property before running or logging exceptions from test methods. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@802587 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3ec9136da7
commit
fb2a45a739
|
@ -57,7 +57,7 @@ public class SimpleEntity implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
@Column(name = "ID")
|
@Column(name = "ID",columnDefinition="")
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
<dbcp.args>MaxActive=${dbcp.maxActive},MaxIdle=${dbcp.maxIdle},MinIdle=${dbcp.minIdle},MaxWait=${dbcp.maxWait}</dbcp.args>
|
<dbcp.args>MaxActive=${dbcp.maxActive},MaxIdle=${dbcp.maxIdle},MinIdle=${dbcp.minIdle},MaxWait=${dbcp.maxWait}</dbcp.args>
|
||||||
<derby.locks.waitTimeout>60</derby.locks.waitTimeout>
|
<derby.locks.waitTimeout>60</derby.locks.waitTimeout>
|
||||||
<derby.locks.deadlockTimeout>5</derby.locks.deadlockTimeout>
|
<derby.locks.deadlockTimeout>5</derby.locks.deadlockTimeout>
|
||||||
|
<tests.openjpa.allowfailure>ignore</tests.openjpa.allowfailure>
|
||||||
</properties>
|
</properties>
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
||||||
|
@ -80,6 +81,10 @@
|
||||||
<name>openjpa.ConnectionProperties</name>
|
<name>openjpa.ConnectionProperties</name>
|
||||||
<value>DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args}</value>
|
<value>DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args}</value>
|
||||||
</property>
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>tests.openjpa.allowfailure</name>
|
||||||
|
<value>${tests.openjpa.allowfailure}</value>
|
||||||
|
</property>
|
||||||
</systemProperties>
|
</systemProperties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -855,6 +860,10 @@
|
||||||
<name>openjpa.ConnectionProperties</name>
|
<name>openjpa.ConnectionProperties</name>
|
||||||
<value>DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args}</value>
|
<value>DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args}</value>
|
||||||
</property>
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>tests.openjpa.allowfailure</name>
|
||||||
|
<value>${tests.openjpa.allowfailure}</value>
|
||||||
|
</property>
|
||||||
</systemProperties>
|
</systemProperties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -66,6 +66,12 @@ public abstract class PersistenceTestCase
|
||||||
public static final String RETAIN_DATA = "Retain data after test run";
|
public static final String RETAIN_DATA = "Retain data after test run";
|
||||||
private boolean retainDataOnTearDown;
|
private boolean retainDataOnTearDown;
|
||||||
protected boolean _fresh = false;
|
protected boolean _fresh = false;
|
||||||
|
|
||||||
|
public static String ALLOW_FAILURE_LOG = "log";
|
||||||
|
public static String ALLOW_FAILURE_IGNORE = "ignore";
|
||||||
|
public static String ALLOW_FAILURE_SYS_PROP= "tests.openjpa.allowfailure";
|
||||||
|
|
||||||
|
private static String allowFailureConfig = System.getProperty(ALLOW_FAILURE_SYS_PROP, ALLOW_FAILURE_IGNORE);
|
||||||
/**
|
/**
|
||||||
* Marker object you pass to {@link #setUp} to indicate that the
|
* Marker object you pass to {@link #setUp} to indicate that the
|
||||||
* database table rows should be cleared.
|
* database table rows should be cleared.
|
||||||
|
@ -469,21 +475,35 @@ public abstract class PersistenceTestCase
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void runBare() throws Throwable {
|
public void runBare() throws Throwable {
|
||||||
if (!isRunsOnCurrentPlatform())
|
if (!isRunsOnCurrentPlatform()) {
|
||||||
return;
|
return;
|
||||||
try {
|
}
|
||||||
super.runBare();
|
runBare(getAllowFailure());
|
||||||
} catch (Throwable t) {
|
}
|
||||||
AllowFailure allowFailure = getAllowFailure();
|
|
||||||
if ( allowFailure != null && allowFailure.value()==true) {
|
protected void runBare(AllowFailure allowFailureAnnotation) throws Throwable {
|
||||||
System.err.println("*** FAILED (but ignored): " + this);
|
boolean allowFailureValue = allowFailureAnnotation == null ? false : allowFailureAnnotation.value();
|
||||||
System.err.println("*** Reason : "
|
|
||||||
+ allowFailure.message());
|
if(allowFailureValue) {
|
||||||
System.err.println("Stacktrace of failure");
|
if(ALLOW_FAILURE_IGNORE.equalsIgnoreCase(allowFailureConfig)){
|
||||||
t.printStackTrace();
|
return; // skip this test
|
||||||
} else {
|
|
||||||
throw t;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
super.runBare();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
if (ALLOW_FAILURE_LOG.equalsIgnoreCase(allowFailureConfig)) {
|
||||||
|
System.err.println("*** FAILED (but ignored): " + this);
|
||||||
|
System.err.println("*** Reason : " + allowFailureAnnotation.message());
|
||||||
|
System.err.println("Stacktrace of failure");
|
||||||
|
t.printStackTrace();
|
||||||
|
} else {
|
||||||
|
throw t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
super.runBare();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue