From 5a0b97302ba89edbc08b90954805ad26ce6b1f3a Mon Sep 17 00:00:00 2001 From: Donald Woods Date: Wed, 20 Jan 2010 22:53:02 +0000 Subject: [PATCH] OPENJPA-1374 The @DatabasePlatform no longer works, as Derby will always be on the classpath. Switching 3 junits over to use setSupportedDatabases() in their setUp() routines instead.... git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@901419 13f79535-47bb-0310-9956-ffa450edef68 --- .../lib/conf/TestEquivalentConfiguration.java | 11 +++++-- .../identity/TestCompundIdWithNull.java | 31 ++++++++++++------- .../jdbc/oracle/TestAutoIncrement.java | 12 +++++-- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestEquivalentConfiguration.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestEquivalentConfiguration.java index a407edd18..c928e9227 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestEquivalentConfiguration.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestEquivalentConfiguration.java @@ -27,6 +27,7 @@ import javax.persistence.Persistence; import org.apache.openjpa.conf.OpenJPAConfiguration; import org.apache.openjpa.enhance.TestEnhancementWithMultiplePUs; import org.apache.openjpa.jdbc.schema.DataSourceFactory; +import org.apache.openjpa.jdbc.sql.DerbyDictionary; import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; import org.apache.openjpa.persistence.OpenJPAPersistence; import org.apache.openjpa.persistence.common.utils.AbstractTestCase; @@ -49,10 +50,7 @@ import junit.framework.TestCase; * */ -// Specifies that the test runs only if the driver is available in the -// execution classpath @DatabasePlatform("org.apache.derby.jdbc.EmbeddedDriver") - public class TestEquivalentConfiguration extends SingleEMFTestCase { private EntityManagerFactory emf; @@ -97,6 +95,13 @@ public class TestEquivalentConfiguration extends SingleEMFTestCase { */ @Override public void setUp() throws Exception { + // Only run on Derby + setSupportedDatabases( + org.apache.openjpa.jdbc.sql.DerbyDictionary.class); + if (isTestsDisabled()) { + return; + } + _system = backup(); clear(_system); } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestCompundIdWithNull.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestCompundIdWithNull.java index 1bede666a..cbbaba739 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestCompundIdWithNull.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestCompundIdWithNull.java @@ -23,6 +23,7 @@ import java.util.List; import javax.persistence.EntityManager; +import org.apache.openjpa.jdbc.sql.DerbyDictionary; import org.apache.openjpa.persistence.OpenJPAEntityManager; import org.apache.openjpa.persistence.OpenJPAPersistence; import org.apache.openjpa.persistence.test.AllowFailure; @@ -43,22 +44,28 @@ import org.apache.openjpa.persistence.test.SingleEMFTestCase; * @author Pinaki Poddar * @author Michael Vorburger */ -// Because we use DDL specific to Derby -@DatabasePlatform("org.apache.derby.jdbc.EmbeddedDriver") +@DatabasePlatform("org.apache.derby.jdbc.EmbeddedDriver") public class TestCompundIdWithNull extends SingleEMFTestCase { private static boolean tablesCreated = false; - public void setUp() throws Exception { - // do not use CLEAR_TABLES or DROP_TABLES - super.setUp(SimpleCompoundIdTestEntity.class, ComplexCompoundIdTestEntity.class, TypeEntity.class); - if (!tablesCreated) { - createTables(emf.createEntityManager()); - tablesCreated = true; - } - - } + + public void setUp() throws Exception { + // Only run on Derby because we use DDL specific to Derby + setSupportedDatabases( + org.apache.openjpa.jdbc.sql.DerbyDictionary.class); + if (isTestsDisabled()) { + return; + } + + // do not use CLEAR_TABLES or DROP_TABLES + super.setUp(SimpleCompoundIdTestEntity.class, ComplexCompoundIdTestEntity.class, TypeEntity.class); + if (!tablesCreated) { + createTables(emf.createEntityManager()); + tablesCreated = true; + } + } - public void testSimpleCompoundIdTestEntity() throws Exception { + public void testSimpleCompoundIdTestEntity() throws Exception { EntityManager em = emf.createEntityManager(); String jpql = "SELECT o FROM SimpleCompoundIdTestEntity o ORDER BY o.secondId"; List list = em.createQuery(jpql,SimpleCompoundIdTestEntity.class) diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java index 0ad240188..0a153dd92 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/oracle/TestAutoIncrement.java @@ -22,6 +22,7 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceException; import javax.persistence.Query; +import org.apache.openjpa.jdbc.sql.OracleDictionary; import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI; import org.apache.openjpa.persistence.test.DatabasePlatform; @@ -46,7 +47,14 @@ import org.apache.openjpa.persistence.test.SingleEMFTestCase; @DatabasePlatform("oracle.jdbc.driver.OracleDriver") public class TestAutoIncrement extends SingleEMFTestCase { - public void setUp() throws Exception { + public void setUp() throws Exception { + // Only run on Oracle + setSupportedDatabases( + org.apache.openjpa.jdbc.sql.OracleDictionary.class); + if (isTestsDisabled()) { + return; + } + if ("testAutoIncrementIdentityWithNamedSequence".equals(getName())) { String sequence = "autoIncrementSequence"; createSequence(sequence); @@ -58,7 +66,7 @@ public class TestAutoIncrement extends SingleEMFTestCase { "openjpa.jdbc.DBDictionary", "oracle(UseTriggersForAutoAssign=true)"); } - } + } public void testAutoIncrementIdentityWithNamedSequence() { EntityManager em = emf.createEntityManager();