openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r597041 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test: java/org/apache/openjpa/persistence/test/ java/org/apache/openjpa/persistence/xml/ resources/META-INF/
Date Wed, 21 Nov 2007 11:42:03 GMT
Author: pcl
Date: Wed Nov 21 03:42:01 2007
New Revision: 597041

URL: http://svn.apache.org/viewvc?rev=597041&view=rev
Log:
Removing the XML types from the default test runs to reduce complexity of unit test executions
and to speed up overall test execution time.

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java?rev=597041&r1=597040&r2=597041&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
Wed Nov 21 03:42:01 2007
@@ -56,7 +56,15 @@
      * configuration values in the form key,value,key,value...
      */
     protected OpenJPAEntityManagerFactorySPI createEMF(Object... props) {
-        return createNamedEMF("test", props);
+        return createNamedEMF(getPersistenceUnitName(), props);
+    }
+
+    /**
+     * The name of the persistence unit that this test class should use
+     * by default. This defaults to "test".
+     */
+    protected String getPersistenceUnitName() {
+        return "test";
     }
 
     /**
@@ -83,7 +91,7 @@
                     + "SchemaAction='add,deleteTableContents')");
             } else if (props[i] instanceof Class)
                 types.add((Class) props[i]);
-            else
+            else if (props[i] != null)
                 prop = true;
         }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java?rev=597041&r1=597040&r2=597041&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java
Wed Nov 21 03:42:01 2007
@@ -25,7 +25,11 @@
     extends SingleEMTestCase {
 
     public void setUp() {
-        setUp(SimpleXmlEntity.class);
+        setUp(CLEAR_TABLES);
+    }
+
+    protected String getPersistenceUnitName() {
+        return "xml-persistence-unit";
     }
 
     public void testId() {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java?rev=597041&r1=597040&r2=597041&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java
Wed Nov 21 03:42:01 2007
@@ -20,16 +20,51 @@
 
 import javax.persistence.EntityManager;
 
+import org.apache.openjpa.enhance.PCRegistry;
+import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.jdbc.schema.Column;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.MetaDataRepository;
 import org.apache.openjpa.persistence.InvalidStateException;
+import org.apache.openjpa.persistence.JPAFacadeHelper;
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 public class TestXmlOverrideEntity extends SingleEMFTestCase {
 
-    public void setUp() {
-        setUp(XmlOverrideEntity.class);
+    public void setUp() throws ClassNotFoundException {
+        setUp(CLEAR_TABLES);
+
+        // make sure that XmlOverrideEntity is registered for our metadata tests
+        Class.forName(XmlOverrideEntity.class.getName(), true,
+            XmlOverrideEntity.class.getClassLoader());
+    }
+
+    protected String getPersistenceUnitName() {
+        return "xml-persistence-unit";
+    }
+
+    public void testOverrideHappenedDuringEnhancement()
+        throws ClassNotFoundException {
+        // this mostly tests our test harness. Since XmlOverrideEntity
+        // has annotation-based metadata, it is important that the first
+        // PU in which it gets scanned-and-enhanced knows about overriding.
+        assertTrue(PersistenceCapable.class.isAssignableFrom(
+            XmlOverrideEntity.class));
+        assertEquals("XmlOverride",
+            PCRegistry.getTypeAlias(XmlOverrideEntity.class));
+    }
+
+    public void testOverriddenEntityName() {
+        ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
+            XmlOverrideEntity.class);
+        assertEquals("XmlOverride", meta.getTypeAlias());
+        emf.createEntityManager().close();
+        MetaDataRepository repo = emf.getConfiguration()
+            .getMetaDataRepositoryInstance();
+        assertEquals(meta, repo.getMetaData("XmlOverride",
+            XmlOverrideEntity.class.getClassLoader(), true));
     }
 
     /**

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml?rev=597041&r1=597040&r2=597041&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml Wed
Nov 21 03:42:01 2007
@@ -21,26 +21,31 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     version="1.0">
 
-    <persistence-unit name="test">
-        <!-- 
-        <provider>
-            org.apache.openjpa.persistence.PersistenceProviderImpl
-        </provider>
-        -->
-        <!--
+    <persistence-unit name="xml-persistence-unit">
+        <description>
             This needs to be listed because the OpenJPA test framework
             does not provide any other means to incrementally enhance classes
             for particular test cases, and the XML data must be available at
             enhance time for XML data to get incorporated into PCRegistry.
-        -->
-        <mapping-file>org/apache/openjpa/persistence/xml/orm.xml</mapping-file>
-        <!--
+
             In general, for persistent types that use annotations, you should
             not list the persistent types here, but rather use the
             PersistenceTestCase.setUp(Object...) method in your test case's
             setUp() method, passing the Class objects for your persistent types
             to that method.
-        -->
+
+            This PU needs to be first because XmlOverrideEntity overrides the
+            entity name, and that data is stored statically in the enhanced
+            class.
+        </description>
+        <mapping-file>org/apache/openjpa/persistence/xml/orm.xml</mapping-file>
+        <properties>
+            <property name="openjpa.jdbc.SynchronizeMappings"
+                value="buildSchema(ForeignKeys=true)"/>
+        </properties>
+    </persistence-unit>
+
+    <persistence-unit name="test">
         <properties>
             <!--
             These properties are instead passed via System properties



Mime
View raw message