mirror of https://github.com/apache/openjpa.git
OPENJPA-652: Formatting to be published base TestCases
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@673855 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
13e4897173
commit
2a588d6a2b
|
@ -43,10 +43,15 @@ public abstract class PersistenceTestCase
|
||||||
extends TestCase {
|
extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marker object you an pass to {@link #setUp} to indicate that the
|
* Marker object you pass to {@link #setUp} to indicate that the
|
||||||
* database tables should be cleared.
|
* database table rows should be cleared.
|
||||||
*/
|
*/
|
||||||
protected static final Object CLEAR_TABLES = new Object();
|
protected static final Object CLEAR_TABLES = new Object();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marker object you pass to {@link #setUp} to indicate that the
|
||||||
|
* database table should be dropped and then recreated.
|
||||||
|
*/
|
||||||
protected static final Object DROP_TABLES = new Object();
|
protected static final Object DROP_TABLES = new Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,7 +157,8 @@ public abstract class PersistenceTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes all open entity managers after first rolling back any open transactions
|
* Closes all open entity managers after first rolling back any open
|
||||||
|
* transactions.
|
||||||
*/
|
*/
|
||||||
protected void closeAllOpenEMs(EntityManagerFactory emf) {
|
protected void closeAllOpenEMs(EntityManagerFactory emf) {
|
||||||
if (emf == null || !emf.isOpen())
|
if (emf == null || !emf.isOpen())
|
||||||
|
@ -196,15 +202,17 @@ public abstract class PersistenceTestCase
|
||||||
protected void clear(EntityManagerFactory emf) {
|
protected void clear(EntityManagerFactory emf) {
|
||||||
if (emf == null)
|
if (emf == null)
|
||||||
return;
|
return;
|
||||||
clear(emf, true, ((OpenJPAEntityManagerFactorySPI) emf).getConfiguration().
|
clear(emf, true, ((OpenJPAEntityManagerFactorySPI) emf)
|
||||||
getMetaDataRepositoryInstance().getMetaDatas());
|
.getConfiguration()
|
||||||
|
.getMetaDataRepositoryInstance().getMetaDatas());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all instances of the given types using bulk delete queries.
|
* Delete all instances of the given types using bulk delete queries.
|
||||||
* @param closeEMs TODO
|
* @param closeEMs TODO
|
||||||
*/
|
*/
|
||||||
private void clear(EntityManagerFactory emf, boolean closeEMs, ClassMetaData... types) {
|
private void clear(EntityManagerFactory emf, boolean closeEMs,
|
||||||
|
ClassMetaData... types) {
|
||||||
if (emf == null || types.length == 0)
|
if (emf == null || types.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,17 @@ package org.apache.openjpa.persistence.test;
|
||||||
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for OpenJPA-specific Test Case.
|
||||||
|
* Provides utilities for configuration setup and persistent entity
|
||||||
|
* registration during setUp() method.
|
||||||
|
* Derived classes can access protected EntityManagerFactory to create
|
||||||
|
* EntityManager. The protected EntityManagerFactory is declared to be
|
||||||
|
* OpenJPA-extended SPI interface <code>OpenJPAEntityManagerFactorySPI</code>
|
||||||
|
* so that derived classes can access internal mapping/metadata/configuration
|
||||||
|
* and other structures.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public abstract class SingleEMFTestCase
|
public abstract class SingleEMFTestCase
|
||||||
extends PersistenceTestCase {
|
extends PersistenceTestCase {
|
||||||
|
|
||||||
|
@ -71,8 +82,7 @@ public abstract class SingleEMFTestCase
|
||||||
/**
|
/**
|
||||||
* Get the class mapping for a given entity
|
* Get the class mapping for a given entity
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name The Entity's name.
|
||||||
* The Entity's name.
|
|
||||||
*
|
*
|
||||||
* @return If the entity is a known type the ClassMapping for the Entity
|
* @return If the entity is a known type the ClassMapping for the Entity
|
||||||
* will be returned. Otherwise null
|
* will be returned. Otherwise null
|
||||||
|
|
Loading…
Reference in New Issue