You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by al...@apache.org on 2009/05/24 00:50:37 UTC
svn commit: r778055 - in
/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa:
enhance/ jdbc/kernel/ persistence/datacache/ persistence/enhance/identity/
persistence/identity/ persistence/jdbc/query/cache/ persistence/relations/
Author: allee8285
Date: Sat May 23 22:50:37 2009
New Revision: 778055
URL: http://svn.apache.org/viewvc?rev=778055&view=rev
Log:
OPENJPA-1090 - Commit contribution by Tim McConnell.
Modified:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestDataCachingAndUnenhancedPropertyAccess.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestNoForeignKeyViolation.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestAutoIncrementAndDataCaching.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMappedById.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestGenerationType.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/cache/TestQueryTimestampEviction.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestInverseEagerSQL.java
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestDataCachingAndUnenhancedPropertyAccess.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestDataCachingAndUnenhancedPropertyAccess.java?rev=778055&r1=778054&r2=778055&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestDataCachingAndUnenhancedPropertyAccess.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestDataCachingAndUnenhancedPropertyAccess.java Sat May 23 22:50:37 2009
@@ -21,6 +21,7 @@
import java.util.List;
import javax.persistence.EntityManager;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
@@ -35,6 +36,11 @@
}
public void testSimpleDataCacheOperation() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(new UnenhancedIdentityIdPropertyAccess());
@@ -43,6 +49,12 @@
}
public void testAccessIdBeforeCommit() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
+
OpenJPAEntityManager em = emf.createEntityManager();
em.getTransaction().begin();
UnenhancedIdentityIdPropertyAccess o =
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestNoForeignKeyViolation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestNoForeignKeyViolation.java?rev=778055&r1=778054&r2=778055&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestNoForeignKeyViolation.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestNoForeignKeyViolation.java Sat May 23 22:50:37 2009
@@ -22,6 +22,7 @@
import java.util.List;
import javax.persistence.EntityManager;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
/**
@@ -41,11 +42,15 @@
public void setUp() {
setUp(EntityA.class, EntityB.class, EntityC.class, EntityD.class,
EntityE.class, EntityF.class, EntityG.class);
-
createTestData();
}
private void createTestData() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
entityA = new EntityA();
entityB = new EntityB();
entityC = new EntityC();
@@ -60,6 +65,11 @@
}
public void testSqlOrder() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
@@ -91,8 +101,13 @@
em.close();
}
}
-
+
public void testSimpleCycle() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
@@ -106,8 +121,13 @@
em.close();
}
}
-
+
public void testComplexCycle() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
try {
EntityE entityE = new EntityE();
@@ -119,7 +139,7 @@
entityD.setEntityA(entityA);
em.persist(entityA);
em.getTransaction().commit();
-
+
em.getTransaction().begin();
em.remove(entityE);
em.remove(entityA);
@@ -133,6 +153,11 @@
}
public void testComplexTwoCycles() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
try {
EntityE entityE = new EntityE();
@@ -145,7 +170,7 @@
entityD.setEntityB(entityB);
em.persist(entityA);
em.getTransaction().commit();
-
+
em.getTransaction().begin();
em.remove(entityE);
em.remove(entityA);
@@ -157,8 +182,13 @@
em.close();
}
}
-
+
public void testForeignKeyCascade() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
try {
EntityF f = new EntityF();
@@ -169,7 +199,7 @@
g1.setId(1);
listG.add(g1);
g1.setEntityF(f);
-
+
EntityG g2 = new EntityG();
g2.setId(2);
listG.add(g2);
@@ -184,7 +214,7 @@
g4.setId(4);
listG.add(g4);
g4.setEntityF(f);
-
+
f.setListG(listG);
em.getTransaction().begin();
em.persist(f);
@@ -207,5 +237,4 @@
em.close();
}
}
-
}
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestAutoIncrementAndDataCaching.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestAutoIncrementAndDataCaching.java?rev=778055&r1=778054&r2=778055&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestAutoIncrementAndDataCaching.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestAutoIncrementAndDataCaching.java Sat May 23 22:50:37 2009
@@ -20,6 +20,7 @@
import javax.persistence.EntityManager;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
@@ -34,6 +35,11 @@
}
public void testSimpleDataCacheOperation() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(new IdentityIdClass());
@@ -42,6 +48,11 @@
}
public void testAccessIdBeforeCommit() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
OpenJPAEntityManager em = emf.createEntityManager();
em.getTransaction().begin();
IdentityIdClass o = new IdentityIdClass();
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMappedById.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMappedById.java?rev=778055&r1=778054&r2=778055&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMappedById.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMappedById.java Sat May 23 22:50:37 2009
@@ -28,6 +28,7 @@
import javax.persistence.Query;
import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.kernel.StateManagerImpl;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
import org.apache.openjpa.util.ObjectId;
@@ -119,6 +120,11 @@
* This is a variation of spec 2.4.1.2 Example 4, case(b) with generated key
*/
public void testMappedById4() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
createObj4();
queryObj4();
}
@@ -129,6 +135,11 @@
* classes use generated key
*/
public void testMappedById5() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
createObj5();
findObj5();
queryObj5();
@@ -659,6 +670,11 @@
* Derived Identity with IdClass and generatedKey
*/
public void testPersistDerivedIdentityUsingIdClassAndGeneratedKey() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
EntityTransaction tran = em.getTransaction();
for (int i = 0; i < numEmployees; i++)
@@ -673,6 +689,11 @@
* Derived Identity with IdClass and generatedKey
*/
public void testMergeDerivedIdentityUsingIdClassAndGeneratedKey() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
EntityTransaction tran = em.getTransaction();
for (int i = 0; i < numEmployees; i++)
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestGenerationType.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestGenerationType.java?rev=778055&r1=778054&r2=778055&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestGenerationType.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestGenerationType.java Sat May 23 22:50:37 2009
@@ -39,22 +39,14 @@
public void setUp() {
setUp(IdentityGenerationType.class);
-
- /*
- * If the DBDictionary doesn't support AutoAssign(ment) of column
- * values, then null out the emf instance to prevent the rest of
- * the tests from executing.
- */
- JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
- if (!conf.getDBDictionaryInstance().supportsAutoAssign) {
- emf = null;
- }
-
}
public void testCreateEntityManager() {
- if (emf == null)
- return;
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
EntityTransaction t = em.getTransaction();
@@ -72,8 +64,11 @@
}
public void testPersist() {
- if (emf == null)
- return;
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(new IdentityGenerationType());
@@ -82,8 +77,11 @@
}
public void testQuery() {
- if (emf == null)
- return;
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
IdentityGenerationType igt = new IdentityGenerationType();
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/cache/TestQueryTimestampEviction.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/cache/TestQueryTimestampEviction.java?rev=778055&r1=778054&r2=778055&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/cache/TestQueryTimestampEviction.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/cache/TestQueryTimestampEviction.java Sat May 23 22:50:37 2009
@@ -22,6 +22,7 @@
import javax.persistence.Query;
import org.apache.openjpa.datacache.ConcurrentQueryCache;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
import org.apache.openjpa.persistence.OpenJPAPersistence;
import org.apache.openjpa.persistence.QueryResultCacheImpl;
@@ -29,6 +30,10 @@
import org.apache.openjpa.util.CacheMap;
public class TestQueryTimestampEviction extends SingleEMFTestCase {
+
+ private boolean deleteData = false;
+ private boolean recreateData = true;
+
public void setUp() throws Exception {
super.setUp(Part.class, PartBase.class, PartComposite.class,
Supplier.class, Usage.class,
@@ -37,7 +42,9 @@
"CacheSize=1000, EvictPolicy='timestamp'",
"openjpa.RemoteCommitProvider", "sjvm");
- if (recreateData) {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign && recreateData) {
// deletes any data leftover data in the database due to the failed
// last run of this testcase
deleteAllData();
@@ -45,11 +52,12 @@
}
}
- private boolean deleteData = false;
- private boolean recreateData = true;
-
public void testLoadQueries() {
-
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
loadQueryCache();
int cacheSizeBeforeUpdate = queryCacheGet();
updateAnEntity();
@@ -63,6 +71,11 @@
}
public void testEviction() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
loadQueryCache();
try {
Thread.sleep(20);
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestInverseEagerSQL.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestInverseEagerSQL.java?rev=778055&r1=778054&r2=778055&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestInverseEagerSQL.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestInverseEagerSQL.java Sat May 23 22:50:37 2009
@@ -27,6 +27,8 @@
import javax.persistence.Query;
import junit.textui.TestRunner;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.OpenJPAQuery;
import org.apache.openjpa.persistence.query.Magazine;
@@ -46,7 +48,12 @@
EntityA2InverseEager.class, EntityBInverseEager.class,
EntityCInverseEager.class, EntityDInverseEager.class,
Publisher.class, Magazine.class, DROP_TABLES);
-
+
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
@@ -55,7 +62,7 @@
c.setCid(ck);
c.setName("customer1");
em.persist(c);
-
+
for (int i = 0; i < numOrdersPerCustomer; i++) {
Order order = new Order();
order.setCustomer(c);
@@ -67,7 +74,7 @@
EntityA1InverseEager a1 = new EntityA1InverseEager("a1");
em.persist(a1);
-
+
EntityA2InverseEager a2 = new EntityA2InverseEager("a2");
em.persist(a2);
@@ -77,7 +84,7 @@
b.setA(a);
em.persist(b);
}
-
+
for (int i = 4; i < 8; i++) {
EntityBInverseEager b = new EntityBInverseEager("b" + i);
a1.addB(b);
@@ -91,7 +98,7 @@
b.setA(a2);
em.persist(b);
}
-
+
for (int i = 0; i < 4; i++) {
EntityCInverseEager c1 = new EntityCInverseEager("c"+i, i, i);
em.persist(c1);
@@ -107,7 +114,7 @@
Publisher p1 = new Publisher();
p1.setName("publisher1");
em.persist(p1);
-
+
for (int i = 0; i < 4; i++) {
Magazine magazine = new Magazine();
magazine.setIdPublisher(p1);
@@ -118,7 +125,7 @@
Publisher p2 = new Publisher();
p2.setName("publisher2");
em.persist(p2);
-
+
for (int i = 0; i < 4; i++) {
Magazine magazine = new Magazine();
magazine.setIdPublisher(p2);
@@ -132,6 +139,11 @@
}
public void testOneToManyInverseEagerQuery() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
sql.clear();
OpenJPAEntityManager em = emf.createEntityManager();
@@ -148,12 +160,17 @@
assertEquals(order.getCustomer(), c);
}
}
-
+
assertEquals(2, sql.size());
em.close();
}
public void testOneToOneInverseEagerQuery() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
sql.clear();
OpenJPAEntityManager em = emf.createEntityManager();
@@ -173,6 +190,11 @@
}
public void testOneToManyInheritanceQuery() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
sql.clear();
OpenJPAEntityManager em = emf.createEntityManager();
@@ -209,7 +231,7 @@
}
assertEquals(3, sql.size());
sql.clear();
-
+
query = "select a FROM EntityAInverseEager a";
q = em.createQuery(query);
list = q.getResultList();
@@ -224,12 +246,17 @@
assertEquals(a0, a);
}
}
-
+
assertEquals(2, sql.size());
em.close();
}
public void testOneToManyEagerInverseLazyQuery() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
sql.clear();
OpenJPAEntityManager em = emf.createEntityManager();
@@ -257,6 +284,11 @@
}
public void testTargetOrphanRemoval() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
OpenJPAEntityManager em = emf.createEntityManager();
int count = count(Order.class);
assertEquals(numOrdersPerCustomer * numCustomers, count);
@@ -301,8 +333,13 @@
assertEquals(0, orders.size());
em.close();
}
-
+
public void testSourceOrphanRemoval() {
+ // Not all databases support GenerationType.IDENTITY column(s)
+ if (!((JDBCConfiguration) emf.getConfiguration()).
+ getDBDictionaryInstance().supportsAutoAssign) {
+ return;
+ }
OpenJPAEntityManager em = emf.createEntityManager();
// OrphanRemoval: remove source
Customer.CustomerKey ck = new Customer.CustomerKey("USA", 1);
@@ -312,7 +349,7 @@
em.flush();
em.getTransaction().commit();
em.clear();
-
+
int count = count(Order.class);
assertEquals(numOrdersPerCustomer * (numCustomers - 1), count);
em.close();