Author: gbadner
Date: 2008-11-06 18:21:06 -0500 (Thu, 06 Nov 2008)
New Revision: 15529
Modified:
core/branches/Branch_3_2/test/org/hibernate/junit/UnitTestCase.java
core/branches/Branch_3_2/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java
core/branches/Branch_3_2/test/org/hibernate/test/cascade/BidirectionalOneToManyCascadeTest.java
Log:
Tweak FailureExpected validation to not throw FailureExpectedTestPassedException when a
test is skipped
Modified: core/branches/Branch_3_2/test/org/hibernate/junit/UnitTestCase.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/junit/UnitTestCase.java 2008-11-06
23:11:06 UTC (rev 15528)
+++ core/branches/Branch_3_2/test/org/hibernate/junit/UnitTestCase.java 2008-11-06
23:21:06 UTC (rev 15529)
@@ -32,7 +32,7 @@
try {
log.info( "Starting test [" + fullTestName() + "]" );
super.runBare();
- if ( doValidate ) {
+ if ( !isTestSkipped() && doValidate ) {
throw new FailureExpectedTestPassedException();
}
}
@@ -58,6 +58,18 @@
}
}
+ /**
+ * Is this test skipped?
+ *
+ * TODO: This method should no longer be needed FunctionalTestClassTestSuite.addTest()
is
+ * changed to only include non-skipped tests.
+ *
+ * @return true, if the test is skipped; false, otherwise.
+ */
+ protected boolean isTestSkipped() {
+ return false;
+ }
+
protected void skipExpectedFailure(Throwable error) {
reportSkip( "ignoring *FailuredExpected methods", "Failed with: " +
error.toString() );
}
Modified:
core/branches/Branch_3_2/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java
===================================================================
---
core/branches/Branch_3_2/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java 2008-11-06
23:11:06 UTC (rev 15528)
+++
core/branches/Branch_3_2/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java 2008-11-06
23:21:06 UTC (rev 15529)
@@ -8,10 +8,15 @@
* @author Steve Ebersole
*/
public abstract class DatabaseSpecificFunctionalTestCase extends FunctionalTestCase {
+
public DatabaseSpecificFunctionalTestCase(String string) {
super( string );
}
+ protected boolean isTestSkipped() {
+ return ! appliesTo( getDialect() );
+ }
+
protected void runTest() throws Throwable {
// Note: this protection comes into play when running
// tests individually. The suite as a whole is already
Modified:
core/branches/Branch_3_2/test/org/hibernate/test/cascade/BidirectionalOneToManyCascadeTest.java
===================================================================
---
core/branches/Branch_3_2/test/org/hibernate/test/cascade/BidirectionalOneToManyCascadeTest.java 2008-11-06
23:11:06 UTC (rev 15528)
+++
core/branches/Branch_3_2/test/org/hibernate/test/cascade/BidirectionalOneToManyCascadeTest.java 2008-11-06
23:21:06 UTC (rev 15529)
@@ -8,8 +8,11 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.id.SequenceGenerator;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
/**
* @author Gail Badner (based on annotations test case submitted by Edward Costello)
@@ -20,7 +23,7 @@
* one-to-many collection and the many-to-one side is also cascaded a
* TransientObjectException is thrown.
*/
-public class BidirectionalOneToManyCascadeTest extends FunctionalTestCase {
+public class BidirectionalOneToManyCascadeTest extends DatabaseSpecificFunctionalTestCase
{
public BidirectionalOneToManyCascadeTest(String name) {
super( name );
@@ -34,6 +37,15 @@
};
}
+ public boolean appliesTo(Dialect dialect) {
+ if ( "testSaveOrphanDeleteChildWithParentFailureExpected".equals( getName() )
&&
+ sfi().getEntityPersister( "org.hibernate.test.cascade.Child"
).getIdentifierGenerator() instanceof SequenceGenerator ) {
+ reportSkip( "test is known to pass with ID generated by SequenceGenerator",
"skip FailureExpected test");
+ return false;
+ }
+ return true;
+ }
+
public static Test suite() {
return new FunctionalTestClassTestSuite( BidirectionalOneToManyCascadeTest.class );
}
@@ -119,9 +131,36 @@
* uses cascade="all-delete-orphan" and the many-to-one association uses
* cascade="all"
* <p/>
- * This test is known to fail. See HHH-2269.
+ * Until HHH-2269 is fixed, the Child ID generator has to be a sequence to pass.
*/
+ public void testSaveOrphanDeleteChildWithParent() {
+ // TODO: remove the following check when HHH-2269 is fixed.
+ if ( ! ( sfi().getEntityPersister( "org.hibernate.test.cascade.Child"
).getIdentifierGenerator() instanceof SequenceGenerator ) ) {
+ return;
+ }
+ saveOrphanDeleteChildWithParent();
+ }
+
+ /**
+ * Saves the child object with the parent when the one-to-many association
+ * uses cascade="all-delete-orphan" and the many-to-one association uses
+ * cascade="all"
+ * <p/>
+ * This test is known to fail when the Child ID generator is not a sequence.
+ * See HHH-2269.
+ * <p/>
+ * TODO: When HHH-2269 is fixed, this test should be deleted and
+ * the check for the Child ID generator in testSaveOrphanDeleteChildWithParent()
+ * should be removed.
+ */
public void testSaveOrphanDeleteChildWithParentFailureExpected() {
+ if ( sfi().getEntityPersister( "org.hibernate.test.cascade.Child"
).getIdentifierGenerator() instanceof SequenceGenerator ) {
+ return;
+ }
+ saveOrphanDeleteChildWithParent();
+ }
+
+ private void saveOrphanDeleteChildWithParent() {
Session session = openSession();
Transaction txn = session.beginTransaction();
Parent parent = new Parent();
Show replies by thread