Package net.officefloor.jpa.test
Class AbstractJpaTestCase
- java.lang.Object
-
- net.officefloor.jpa.test.AbstractJpaTestCase
-
public abstract class AbstractJpaTestCase extends java.lang.Object
Abstract functionality for the JPA testing.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractJpaTestCase.DeleteSection
Mock section for deleting entity.static class
AbstractJpaTestCase.InsertSection
Mock section for inserting entity.static class
AbstractJpaTestCase.NewThread
static class
AbstractJpaTestCase.ReadSection
Mock section for reading entity.static class
AbstractJpaTestCase.Result
Holder for the result.static class
AbstractJpaTestCase.SelectInput
static class
AbstractJpaTestCase.SelectParameter
static class
AbstractJpaTestCase.StressInsertSection
static class
AbstractJpaTestCase.StressSelectSection
static class
AbstractJpaTestCase.UpdateSection
Mock section for updating entity.
-
Field Summary
Fields Modifier and Type Field Description protected java.sql.Connection
connection
Connection
.protected static java.lang.Class<? extends IMockEntity>
mockEntityClass
IMockEntity
implementationClass
.protected OfficeFloor
officeFloor
protected AutoWireStateManager
stateManager
-
Constructor Summary
Constructors Constructor Description AbstractJpaTestCase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
cleanDatabase(java.sql.Connection connection)
Cleans the database.void
connectionReadWithCompiler()
Ensure able to read entry from database with compiled wrappers.void
connectionReadWithDynamicProxy()
Ensure able to read entry from database withProxy
.void
dataSourceRead()
Ensure able to read entry viaDataSource
.void
deleteDataSource()
Ensure able to delete entry viaDataSource
.void
deleteWithCompiler()
Ensure able to delete entry from database with compiled wrappers.void
deleteWithDynamicProxy()
Ensure able to delete entry from database withProxy
.void
doDeleteTest(boolean isConnection)
Ensure able to delete entry from database.void
doInsertTest(boolean isConnection)
Ensure able to insert entry into database.void
doReadTest(boolean isConnection)
Ensure able to read entry from database.void
doUpdateTest(boolean isConnection)
Ensure able to update entry into database.void
forceCommitWithCompiler()
Undertake forcing commit with compiled wrappers.void
forceCommitWithDynamicProxy()
Undertake forcing commit withProxy
.protected java.lang.Class<? extends JpaManagedObjectSource>
getJpaManagedObjectSourceClass()
Allows overriding theJpaManagedObjectSource
Class
for vendor specific implementations.protected abstract java.lang.Class<? extends IMockEntity>
getMockEntityClass()
Obtains theIMockEntity
implementationClass
.void
insertDataSource()
Ensure able to insert entry viaDataSource
.void
insertWithCompiler()
Ensure able to insert entry into database with compiled wrappers.void
insertWithDynamicProxy()
Ensure able to insert entry into database withProxy
.protected boolean
isTransactional()
Indicates if JPA is transactional.protected void
loadDataSourceProperties(PropertyConfigurable mos)
Loads the properties for theDataSourceManagedObjectSource
.protected abstract void
loadJpaProperties(PropertyConfigurable jpa)
Loads the properties for theJpaManagedObjectSource
.void
managedConnectivity()
Ensure ifEntityManager
is managing theDataSource
that it is validated on start up.void
setUp()
void
specification()
Validate the specificationvoid
stressInsertWithCompiler(org.junit.jupiter.api.TestInfo testInfo)
Undertake stress insert test with compiled wrappers.void
stressInsertWithDynamicProxy(org.junit.jupiter.api.TestInfo testInfo)
Undertake stress insert test withProxy
.void
stressSelectDataSource(org.junit.jupiter.api.TestInfo testInfo)
Ensure stress select withDataSource
.void
stressSelectWithCompiler(org.junit.jupiter.api.TestInfo testInfo)
Ensure stress select with compiled wrappers.void
stressSelectWithDynamicProxy(org.junit.jupiter.api.TestInfo testInfo)
Ensure stress select withProxy
.void
tearDown()
void
testStressInsertDataSource(org.junit.jupiter.api.TestInfo testInfo)
Undertake stress insert test withDataSource
.void
type_Connection()
Validate the type.void
type_DataSource()
Validate the type.void
type_Default()
Validate the type.void
type_Managed()
Validate the type.void
updateDataSource()
Ensure able to update entry viaDataSource
.void
updateWithCompiler()
Ensure able to update entry into database with compiled wrappers.void
updateWithDynamicProxy()
Ensure able to update entry into database withProxy
.
-
-
-
Field Detail
-
mockEntityClass
protected static java.lang.Class<? extends IMockEntity> mockEntityClass
IMockEntity
implementationClass
.
-
connection
protected java.sql.Connection connection
Connection
.
-
stateManager
protected AutoWireStateManager stateManager
-
officeFloor
protected OfficeFloor officeFloor
-
-
Method Detail
-
loadJpaProperties
protected abstract void loadJpaProperties(PropertyConfigurable jpa)
Loads the properties for theJpaManagedObjectSource
.- Parameters:
jpa
-PropertyConfigurable
to receive theProperty
values.
-
getMockEntityClass
protected abstract java.lang.Class<? extends IMockEntity> getMockEntityClass()
Obtains theIMockEntity
implementationClass
.- Returns:
IMockEntity
implementationClass
.
-
getJpaManagedObjectSourceClass
protected java.lang.Class<? extends JpaManagedObjectSource> getJpaManagedObjectSourceClass()
Allows overriding theJpaManagedObjectSource
Class
for vendor specific implementations.- Returns:
JpaManagedObjectSource
Class
to use in testing.
-
loadDataSourceProperties
protected void loadDataSourceProperties(PropertyConfigurable mos)
Loads the properties for theDataSourceManagedObjectSource
.- Parameters:
mos
-PropertyConfigurable
.
-
cleanDatabase
protected void cleanDatabase(java.sql.Connection connection) throws java.sql.SQLException
Cleans the database.- Parameters:
connection
-Connection
.- Throws:
java.sql.SQLException
- If fails to clean the database.
-
setUp
@BeforeEach public void setUp() throws java.lang.Exception
- Throws:
java.lang.Exception
-
tearDown
@AfterEach public void tearDown() throws java.lang.Exception
- Throws:
java.lang.Exception
-
specification
@Test public void specification()
Validate the specification
-
type_Connection
@Test public void type_Connection()
Validate the type.
-
type_DataSource
@Test public void type_DataSource()
Validate the type.
-
type_Managed
@Test public void type_Managed()
Validate the type.
-
type_Default
@Test public void type_Default()
Validate the type.
-
managedConnectivity
@Test public void managedConnectivity() throws java.lang.Throwable
Ensure ifEntityManager
is managing theDataSource
that it is validated on start up.- Throws:
java.lang.Throwable
- On test failure.
-
connectionReadWithCompiler
@Test public void connectionReadWithCompiler() throws java.lang.Throwable
Ensure able to read entry from database with compiled wrappers.- Throws:
java.lang.Throwable
-
connectionReadWithDynamicProxy
@Test public void connectionReadWithDynamicProxy() throws java.lang.Throwable
Ensure able to read entry from database withProxy
.- Throws:
java.lang.Throwable
- On test failure.
-
dataSourceRead
@Test public void dataSourceRead() throws java.lang.Throwable
Ensure able to read entry viaDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
doReadTest
public void doReadTest(boolean isConnection) throws java.lang.Throwable
Ensure able to read entry from database.- Parameters:
isConnection
- Indicates ifConnection
otherwiseDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
insertWithCompiler
@Test public void insertWithCompiler() throws java.lang.Throwable
Ensure able to insert entry into database with compiled wrappers.- Throws:
java.lang.Throwable
- On test failure.
-
insertWithDynamicProxy
@Test public void insertWithDynamicProxy() throws java.lang.Throwable
Ensure able to insert entry into database withProxy
.- Throws:
java.lang.Throwable
- On test failure.
-
insertDataSource
@Test public void insertDataSource() throws java.lang.Throwable
Ensure able to insert entry viaDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
doInsertTest
public void doInsertTest(boolean isConnection) throws java.lang.Throwable
Ensure able to insert entry into database.- Parameters:
isConnection
- Indicates ifConnection
otherwiseDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
updateWithCompiler
@Test public void updateWithCompiler() throws java.lang.Throwable
Ensure able to update entry into database with compiled wrappers.- Throws:
java.lang.Throwable
- On test failure.
-
updateWithDynamicProxy
@Test public void updateWithDynamicProxy() throws java.lang.Throwable
Ensure able to update entry into database withProxy
.- Throws:
java.lang.Throwable
- On test failure.
-
updateDataSource
@Test public void updateDataSource() throws java.lang.Throwable
Ensure able to update entry viaDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
doUpdateTest
public void doUpdateTest(boolean isConnection) throws java.lang.Throwable
Ensure able to update entry into database.- Parameters:
isConnection
- Indicates ifConnection
otherwiseDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
deleteWithCompiler
@Test public void deleteWithCompiler() throws java.lang.Throwable
Ensure able to delete entry from database with compiled wrappers.- Throws:
java.lang.Throwable
- On test failure.
-
deleteWithDynamicProxy
@Test public void deleteWithDynamicProxy() throws java.lang.Throwable
Ensure able to delete entry from database withProxy
.- Throws:
java.lang.Throwable
- On test failure.
-
deleteDataSource
@Test public void deleteDataSource() throws java.lang.Throwable
Ensure able to delete entry viaDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
doDeleteTest
public void doDeleteTest(boolean isConnection) throws java.lang.Throwable
Ensure able to delete entry from database.- Parameters:
isConnection
- Indicates ifConnection
otherwiseDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
forceCommitWithCompiler
@Test public void forceCommitWithCompiler() throws java.lang.Throwable
Undertake forcing commit with compiled wrappers.- Throws:
java.lang.Throwable
- On test failure.
-
forceCommitWithDynamicProxy
@Test public void forceCommitWithDynamicProxy() throws java.lang.Throwable
Undertake forcing commit withProxy
.- Throws:
java.lang.Throwable
- On test failure.
-
isTransactional
protected boolean isTransactional()
Indicates if JPA is transactional.- Returns:
true
if JPA is transactional.
-
stressInsertWithCompiler
public void stressInsertWithCompiler(org.junit.jupiter.api.TestInfo testInfo) throws java.lang.Throwable
Undertake stress insert test with compiled wrappers.- Throws:
java.lang.Throwable
- On test failure.
-
stressInsertWithDynamicProxy
public void stressInsertWithDynamicProxy(org.junit.jupiter.api.TestInfo testInfo) throws java.lang.Throwable
Undertake stress insert test withProxy
.- Throws:
java.lang.Throwable
- On test failure.
-
testStressInsertDataSource
public void testStressInsertDataSource(org.junit.jupiter.api.TestInfo testInfo) throws java.lang.Throwable
Undertake stress insert test withDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
stressSelectWithCompiler
public void stressSelectWithCompiler(org.junit.jupiter.api.TestInfo testInfo) throws java.lang.Throwable
Ensure stress select with compiled wrappers.- Throws:
java.lang.Throwable
- On test failure.
-
stressSelectWithDynamicProxy
public void stressSelectWithDynamicProxy(org.junit.jupiter.api.TestInfo testInfo) throws java.lang.Throwable
Ensure stress select withProxy
.- Throws:
java.lang.Throwable
- On test failure.
-
stressSelectDataSource
public void stressSelectDataSource(org.junit.jupiter.api.TestInfo testInfo) throws java.lang.Throwable
Ensure stress select withDataSource
.- Throws:
java.lang.Throwable
- On test failure.
-
-