|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.springframework.test.ConditionalTestCase
org.springframework.test.AbstractSpringContextTests
org.springframework.test.AbstractSingleSpringContextTests
org.springframework.test.AbstractDependencyInjectionSpringContextTests
org.springframework.test.AbstractTransactionalSpringContextTests
org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests
org.springframework.test.jpa.AbstractJpaTests
public abstract class AbstractJpaTests
Convenient support class for JPA-related tests. Offers the same contract as AbstractTransactionalDataSourceSpringContextTests and equally good performance, even when performing the instrumentation required by the JPA specification.
Exposes an EntityManagerFactory and a shared EntityManager. Requires an EntityManagerFactory to be injected, plus the DataSource and JpaTransactionManager through the superclass.
When using Xerces, make sure a post 2.0.2 version is available on the classpath to avoid a critical bug that leads to StackOverflow. Maven users are likely to encounter this problem since 2.0.2 is used by default.
A workaround is to explicitly specify the Xerces version inside the Maven POM:
<dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.8.1</version> </dependency>
Field Summary | |
---|---|
protected javax.persistence.EntityManagerFactory |
entityManagerFactory
|
protected javax.persistence.EntityManager |
sharedEntityManager
Subclasses can use this in test cases. |
Fields inherited from class org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests |
---|
profileValueSource, simpleJdbcTemplate |
Fields inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests |
---|
jdbcTemplate |
Fields inherited from class org.springframework.test.AbstractTransactionalSpringContextTests |
---|
transactionDefinition, transactionManager, transactionStatus |
Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests |
---|
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NO |
Fields inherited from class org.springframework.test.AbstractSingleSpringContextTests |
---|
applicationContext |
Fields inherited from class org.springframework.test.ConditionalTestCase |
---|
logger |
Constructor Summary | |
---|---|
AbstractJpaTests()
|
Method Summary | |
---|---|
protected java.lang.String |
cacheKeys()
|
protected javax.persistence.EntityManager |
createContainerManagedEntityManager()
Create an EntityManager that will always automatically enlist itself in current transactions, in contrast to an EntityManager returned by EntityManagerFactory.createEntityManager()
(which requires an explicit joinTransaction() call). |
protected java.lang.ClassLoader |
createShadowingClassLoader(java.lang.ClassLoader classLoader)
NB: This method must not have a return type of ShadowingClassLoader as that would cause that class to be loaded eagerly when this test case loads, creating verify errors at runtime. |
protected void |
customizeResourceOverridingShadowingClassLoader(java.lang.ClassLoader shadowingClassLoader)
Customize the shadowing class loader. |
protected java.lang.String |
getActualOrmXmlLocation()
Subclasses can override this to return the real location path for orm.xml or null if they do not wish to find any orm.xml |
void |
runBare()
Overridden to populate transaction definition from annotations. |
void |
setDirty()
Called to say that the "applicationContext" instance variable is dirty and should be reloaded. |
void |
setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
|
protected boolean |
shouldUseShadowLoader()
Subclasses should override this method if they wish to disable shadow class loading. |
Methods inherited from class org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests |
---|
findUniqueProfileValueSourceFromContext, getTestMethod, isDisabledInThisEnvironment, isRollback, setDataSource |
Methods inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests |
---|
countRowsInTable, deleteFromTables, executeSqlScript, getJdbcTemplate, setComplete, setSqlScriptEncoding |
Methods inherited from class org.springframework.test.AbstractTransactionalSpringContextTests |
---|
endTransaction, isDefaultRollback, onSetUp, onSetUpBeforeTransaction, onSetUpInTransaction, onTearDown, onTearDownAfterTransaction, onTearDownInTransaction, preventTransaction, setDefaultRollback, setTransactionDefinition, setTransactionManager, startNewTransaction |
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests |
---|
getAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, prepareTestInstance, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables |
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests |
---|
contextKey, createApplicationContext, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigLocations, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, prepareApplicationContext, setUp, tearDown |
Methods inherited from class org.springframework.test.AbstractSpringContextTests |
---|
addContext, contextKeyString, getContext, hasCachedContext, isContextKeyEmpty, setDirty |
Methods inherited from class org.springframework.test.ConditionalTestCase |
---|
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runTest, setName, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected javax.persistence.EntityManagerFactory entityManagerFactory
protected javax.persistence.EntityManager sharedEntityManager
Constructor Detail |
---|
public AbstractJpaTests()
Method Detail |
---|
public void setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
protected javax.persistence.EntityManager createContainerManagedEntityManager()
EntityManagerFactory.createEntityManager()
(which requires an explicit joinTransaction()
call).
protected boolean shouldUseShadowLoader()
The default implementation deactivates shadow class loading if Spring's InstrumentationSavingAgent has been configured on VM startup.
public void setDirty()
AbstractSingleSpringContextTests
setDirty
in class AbstractSingleSpringContextTests
public void runBare() throws java.lang.Throwable
AbstractAnnotationAwareTransactionalTests
runBare
in class AbstractAnnotationAwareTransactionalTests
java.lang.Throwable
protected java.lang.String cacheKeys()
protected java.lang.ClassLoader createShadowingClassLoader(java.lang.ClassLoader classLoader)
protected void customizeResourceOverridingShadowingClassLoader(java.lang.ClassLoader shadowingClassLoader)
shadowingClassLoader
- this parameter is actually of type
ResourceOverridingShadowingClassLoader, and can safely to be cast to
that type. However, the signature must not be of that type as that
would cause the present class loader to load that type.protected java.lang.String getActualOrmXmlLocation()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |