From d31d40f5110297385b7570e517a7c6a814093be0 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 6 Oct 2008 15:33:57 +0000 Subject: [PATCH] Fix test case db preparation to allow tests to repeat run without taking various runtime exception. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@702180 13f79535-47bb-0310-9956-ffa450edef68 --- .../persistence/jdbc/update/TestParentChild.java | 11 ++++++++--- .../recursive/TestRecursiveRelationships.java | 2 +- .../openjpa/persistence/spring/TestLibService.java | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java index b99cee4ca..bd5a344ca 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java @@ -98,7 +98,7 @@ public class TestParentChild extends CombinatorialPersistenceTestCase { // The last argument tells that this is a runtime option. So the // values are included to generate combinations but are excluded // from generating OpenJPA configuration. - getHelper().addOption("persist-order", PersistOrder.values(), true); + getHelper().addOption(Key_PersistOrder, PersistOrder.values(), true); } public void setUp() { @@ -109,7 +109,7 @@ public class TestParentChild extends CombinatorialPersistenceTestCase { getHelper().addOption(Key_SchemaFactory, Option_SchemaFactory); getHelper().addOption(Key_UpdateManager, Option_UpdateManager); - getHelper().addOption("persist-order", PersistOrder.values(), true); + getHelper().addOption(Key_PersistOrder, PersistOrder.values(), true); sql.clear(); super.setUp(DROP_TABLES, Parent.class, Child.class); @@ -191,7 +191,8 @@ public class TestParentChild extends CombinatorialPersistenceTestCase { */ void assertPostInsertUpdate() { if (getPersistOrder().equals(PersistOrder.CHILD_THEN_PARENT) - && getMappingDefaults().contains("restrict")) { + && getMappingDefaults().contains("restrict") + && getUpdateManagerDefaults().contains("operation-order")) { assertSQL("UPDATE .* SET PARENT_ID .* WHERE .*"); } } @@ -226,6 +227,10 @@ public class TestParentChild extends CombinatorialPersistenceTestCase { return getHelper().getOptionAsString(Key_MappingDefaults); } + String getUpdateManagerDefaults() { + return getHelper().getOptionAsString(Key_UpdateManager); + } + String getSchemaFactory() { return getHelper().getOptionAsString(Key_SchemaFactory); } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/recursive/TestRecursiveRelationships.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/recursive/TestRecursiveRelationships.java index 4db37279a..4a20562e2 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/recursive/TestRecursiveRelationships.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/recursive/TestRecursiveRelationships.java @@ -27,7 +27,7 @@ public class TestRecursiveRelationships extends SingleEMFTestCase { private int _l2Nodes = 3; public void setUp() { - setUp(Node.class); + setUp(DROP_TABLES, Node.class); } public void testRecursiveNodes() { diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/spring/TestLibService.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/spring/TestLibService.java index c197eca7e..341cc1a87 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/spring/TestLibService.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/spring/TestLibService.java @@ -25,12 +25,13 @@ public class TestLibService extends SingleEMFTestCase public void setUp() { // declare the library model classes - super.setUp(Book.class, Borrower.class, Subject.class, Volunteer.class); + super.setUp(DROP_TABLES, Book.class, Borrower.class, Subject.class, + Volunteer.class); // put golden data in database LibTestingService libTestingService = new LibTestingService(); libTestingService.setEntityManager(emf.createEntityManager()); - libTestingService. repopulateDB(); + libTestingService.repopulateDB(); libTestingService.close(); // create the LibService