You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by kw...@apache.org on 2006/10/19 21:07:03 UTC
svn commit: r465733 -
/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java
Author: kwsutter
Date: Thu Oct 19 12:07:02 2006
New Revision: 465733
URL: http://svn.apache.org/viewvc?view=rev&rev=465733
Log:
Modified TestGenerationType testcase to check whether the current
DBDictionary supports AutoAssign(ment) of column values.
Modified:
incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java
Modified: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java?view=diff&rev=465733&r1=465732&r2=465733
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestGenerationType.java Thu Oct 19 12:07:02 2006
@@ -19,14 +19,16 @@
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
import junit.framework.TestCase;
import junit.textui.TestRunner;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
/**
* Simple test case to test the GenerationType for @Id...
@@ -36,13 +38,24 @@
public class TestGenerationType
extends TestCase {
- private EntityManagerFactory emf;
+ private OpenJPAEntityManagerFactory emf;
public void setUp() {
Map props = new HashMap();
props.put("openjpa.MetaDataFactory",
"jpa(Types=" + IdentityGenerationType.class.getName() + ")");
- emf = Persistence.createEntityManagerFactory("test", props);
+ emf = (OpenJPAEntityManagerFactory) Persistence.
+ createEntityManagerFactory("test", props);
+ /*
+ * 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 tearDown() {
@@ -60,6 +73,8 @@
}
public void testCreateEntityManager() {
+ if (emf == null)
+ return;
EntityManager em = emf.createEntityManager();
EntityTransaction t = em.getTransaction();
@@ -77,6 +92,8 @@
}
public void testPersist() {
+ if (emf == null)
+ return;
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(new IdentityGenerationType());
@@ -85,6 +102,8 @@
}
public void testQuery() {
+ if (emf == null)
+ return;
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
IdentityGenerationType igt = new IdentityGenerationType();