Removing the XML types from the default test runs to reduce complexity of unit test executions and to speed up overall test execution time.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@597041 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2007-11-21 11:42:01 +00:00
parent c231cc814f
commit fad6f35201
4 changed files with 68 additions and 16 deletions

View File

@ -56,7 +56,15 @@ public abstract class PersistenceTestCase
* 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 @@ public abstract class PersistenceTestCase
+ "SchemaAction='add,deleteTableContents')");
} else if (props[i] instanceof Class)
types.add((Class) props[i]);
else
else if (props[i] != null)
prop = true;
}

View File

@ -25,7 +25,11 @@ public class TestSimpleXmlEntity
extends SingleEMTestCase {
public void setUp() {
setUp(SimpleXmlEntity.class);
setUp(CLEAR_TABLES);
}
protected String getPersistenceUnitName() {
return "xml-persistence-unit";
}
public void testId() {

View File

@ -20,16 +20,51 @@ package org.apache.openjpa.persistence.xml;
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));
}
/**

View File

@ -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