diff --git a/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java b/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java index 069cb2479..0bda0d5c4 100644 --- a/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java +++ b/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/SimpleEntity.java @@ -57,7 +57,7 @@ public class SimpleEntity implements Serializable { @Id @GeneratedValue - @Column(name = "ID") + @Column(name = "ID",columnDefinition="") private long id; @Basic diff --git a/openjpa-persistence-jdbc/pom.xml b/openjpa-persistence-jdbc/pom.xml index 6df89921d..6b8f92c7b 100644 --- a/openjpa-persistence-jdbc/pom.xml +++ b/openjpa-persistence-jdbc/pom.xml @@ -41,6 +41,7 @@ MaxActive=${dbcp.maxActive},MaxIdle=${dbcp.maxIdle},MinIdle=${dbcp.minIdle},MaxWait=${dbcp.maxWait} 60 5 + ignore @@ -80,6 +81,10 @@ openjpa.ConnectionProperties DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args} + + tests.openjpa.allowfailure + ${tests.openjpa.allowfailure} + @@ -855,6 +860,10 @@ openjpa.ConnectionProperties DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args} + + tests.openjpa.allowfailure + ${tests.openjpa.allowfailure} + diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java index 19824303b..70335248e 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java @@ -66,6 +66,12 @@ public abstract class PersistenceTestCase 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 @@ public abstract class PersistenceTestCase */ @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(); } }