You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2009/08/09 22:38:58 UTC
svn commit: r802587 - in /openjpa/trunk:
openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/
openjpa-persistence-jdbc/
openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/
Author: mikedd
Date: Sun Aug 9 20:38:58 2009
New Revision: 802587
URL: http://svn.apache.org/viewvc?rev=802587&view=rev
Log:
OPENJPA-1234:
AllowFailure checks for system property before running or logging exceptions from test methods.
Modified:
openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java
openjpa/trunk/openjpa-persistence-jdbc/pom.xml
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
Modified: openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java?rev=802587&r1=802586&r2=802587&view=diff
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java (original)
+++ openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java Sun Aug 9 20:38:58 2009
@@ -57,7 +57,7 @@
@Id
@GeneratedValue
- @Column(name = "ID")
+ @Column(name = "ID",columnDefinition="")
private long id;
@Basic
Modified: openjpa/trunk/openjpa-persistence-jdbc/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/pom.xml?rev=802587&r1=802586&r2=802587&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/pom.xml (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/pom.xml Sun Aug 9 20:38:58 2009
@@ -41,6 +41,7 @@
<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.deadlockTimeout>5</derby.locks.deadlockTimeout>
+ <tests.openjpa.allowfailure>ignore</tests.openjpa.allowfailure>
</properties>
<profiles>
@@ -80,6 +81,10 @@
<name>openjpa.ConnectionProperties</name>
<value>DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args}</value>
</property>
+ <property>
+ <name>tests.openjpa.allowfailure</name>
+ <value>${tests.openjpa.allowfailure}</value>
+ </property>
</systemProperties>
</configuration>
</plugin>
@@ -855,6 +860,10 @@
<name>openjpa.ConnectionProperties</name>
<value>DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args}</value>
</property>
+ <property>
+ <name>tests.openjpa.allowfailure</name>
+ <value>${tests.openjpa.allowfailure}</value>
+ </property>
</systemProperties>
</configuration>
</plugin>
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=802587&r1=802586&r2=802587&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 Sun Aug 9 20:38:58 2009
@@ -66,6 +66,12 @@
public static final String RETAIN_DATA = "Retain data after test run";
private boolean retainDataOnTearDown;
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
* database table rows should be cleared.
@@ -469,21 +475,35 @@
*/
@Override
public void runBare() throws Throwable {
- if (!isRunsOnCurrentPlatform())
+ if (!isRunsOnCurrentPlatform()) {
return;
- try {
- super.runBare();
- } catch (Throwable t) {
- AllowFailure allowFailure = getAllowFailure();
- if ( allowFailure != null && allowFailure.value()==true) {
- System.err.println("*** FAILED (but ignored): " + this);
- System.err.println("*** Reason : "
- + allowFailure.message());
- System.err.println("Stacktrace of failure");
- t.printStackTrace();
- } else {
- throw t;
+ }
+ runBare(getAllowFailure());
+ }
+
+ protected void runBare(AllowFailure allowFailureAnnotation) throws Throwable {
+ boolean allowFailureValue = allowFailureAnnotation == null ? false : allowFailureAnnotation.value();
+
+ if(allowFailureValue) {
+ if(ALLOW_FAILURE_IGNORE.equalsIgnoreCase(allowFailureConfig)){
+ return; // skip this test
}
+ 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();
}
}