mirror of https://github.com/apache/openjpa.git
minor testcase helper tweaks
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1006029 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1c13b8e59e
commit
8a17669161
|
@ -46,6 +46,7 @@ import org.apache.openjpa.kernel.Broker;
|
|||
import org.apache.openjpa.meta.ClassMetaData;
|
||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
|
||||
/**
|
||||
* Base class for Persistence TestCases. This class contains utility methods but does not maintain an EntityManager or
|
||||
|
@ -119,6 +120,27 @@ public abstract class AbstractPersistenceTestCase extends TestCase {
|
|||
return oemf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an entity manager factory for persistence unit <code>pu</code>. Put {@link #CLEAR_TABLES} in this list to
|
||||
* tell the test framework to delete all table contents before running the tests.
|
||||
*
|
||||
* @param props
|
||||
* list of persistent types used in testing and/or configuration values in the form
|
||||
* key,value,key,value...
|
||||
*/
|
||||
protected OpenJPAEntityManagerFactorySPI createNamedOpenJPAEMF(final String pu,
|
||||
String res, Map<String,Object> props) {
|
||||
OpenJPAEntityManagerFactorySPI oemf = null;
|
||||
Map<Object, Object> config = new HashMap<Object, Object>(System.getProperties());
|
||||
config.putAll(props);
|
||||
oemf = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory(pu, res, props);
|
||||
if (oemf == null) {
|
||||
throw new NullPointerException("Expected an OpenJPA entity manager factory " +
|
||||
"for the persistence unit named: \"" + pu + "\"");
|
||||
}
|
||||
return oemf;
|
||||
}
|
||||
|
||||
protected Map<String, Object> getPropertiesMap(Object... props) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("openjpa.DynamicEnhancementAgent", "false");
|
||||
|
|
|
@ -106,16 +106,21 @@ public abstract class SingleEMTestCase
|
|||
* @return false if the EntityManager was already closed.
|
||||
*/
|
||||
protected boolean close() {
|
||||
boolean brc = false;
|
||||
if (em == null)
|
||||
return false;
|
||||
return brc;
|
||||
|
||||
rollback();
|
||||
try {
|
||||
rollback();
|
||||
|
||||
if (!em.isOpen())
|
||||
return false;
|
||||
|
||||
em.close();
|
||||
return !em.isOpen();
|
||||
if (!em.isOpen())
|
||||
return brc;
|
||||
} finally {
|
||||
em.close();
|
||||
brc = em.isOpen();
|
||||
em = null;
|
||||
}
|
||||
return !brc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue