Package net.officefloor.jpa.test
Class AbstractJpaTestCase
java.lang.Object
net.officefloor.jpa.test.AbstractJpaTestCase
Abstract functionality for the JPA testing.
- Author:
- Daniel Sagenschneider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMock section for deleting entity.static classMock section for inserting entity.static classMarker for new thread.static classMock section for reading entity.static classHolder for the result.static classInput parameter carrying the row identifier for the select stress test.static classParameter holding the selected entity for the select stress test.static classTest fixture section for stress insert.static classTest fixture section for stress select.static classMock section for updating entity. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Connectionprotected static Class<? extends IMockEntity>IMockEntityimplementationClass.protected OfficeFloorprotected AutoWireStateManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcleanDatabase(Connection connection) Cleans the database.voidEnsure able to read entry from database with compiled wrappers.voidEnsure able to read entry from database withProxy.voidEnsure able to read entry viaDataSource.voidEnsure able to delete entry viaDataSource.voidEnsure able to delete entry from database with compiled wrappers.voidEnsure able to delete entry from database withProxy.voiddoDeleteTest(boolean isConnection) Ensure able to delete entry from database.voiddoInsertTest(boolean isConnection) Ensure able to insert entry into database.voiddoReadTest(boolean isConnection) Ensure able to read entry from database.voiddoUpdateTest(boolean isConnection) Ensure able to update entry into database.voidUndertake forcing commit with compiled wrappers.voidUndertake forcing commit withProxy.protected Class<? extends JpaManagedObjectSource>Allows overriding theJpaManagedObjectSourceClassfor vendor specific implementations.protected abstract Class<? extends IMockEntity>Obtains theIMockEntityimplementationClass.protected abstract Class<?>protected abstract StringObtains the message ofExceptionwhen no connection available.voidEnsure able to insert entry viaDataSource.voidEnsure able to insert entry into database with compiled wrappers.voidEnsure able to insert entry into database withProxy.protected booleanIndicates if JPA is transactional.protected voidLoads the properties for theDataSourceManagedObjectSource.protected abstract voidLoads the properties for theJpaManagedObjectSource.voidEnsure ifEntityManageris managing theDataSourcethat it is validated on start up.voidsetUp()Sets up the test.voidValidate the specificationvoidstressInsertWithCompiler(org.junit.jupiter.api.TestInfo testInfo) Undertake stress insert test with compiled wrappers.voidstressInsertWithDynamicProxy(org.junit.jupiter.api.TestInfo testInfo) Undertake stress insert test withProxy.voidstressSelectDataSource(org.junit.jupiter.api.TestInfo testInfo) Ensure stress select withDataSource.voidstressSelectWithCompiler(org.junit.jupiter.api.TestInfo testInfo) Ensure stress select with compiled wrappers.voidstressSelectWithDynamicProxy(org.junit.jupiter.api.TestInfo testInfo) Ensure stress select withProxy.voidtearDown()Tears down the test.voidtestStressInsertDataSource(org.junit.jupiter.api.TestInfo testInfo) Undertake stress insert test withDataSource.voidValidate the type.voidValidate the type.voidValidate the type.voidValidate the type.voidEnsure able to update entry viaDataSource.voidEnsure able to update entry into database with compiled wrappers.voidEnsure able to update entry into database withProxy.
-
Field Details
-
mockEntityClass
IMockEntityimplementationClass. -
connection
-
stateManager
-
officeFloor
-
-
Constructor Details
-
AbstractJpaTestCase
public AbstractJpaTestCase()
-
-
Method Details
-
loadJpaProperties
Loads the properties for theJpaManagedObjectSource.- Parameters:
jpa-PropertyConfigurableto receive thePropertyvalues.
-
getMockEntityClass
Obtains theIMockEntityimplementationClass.- Returns:
IMockEntityimplementationClass.
-
getNoConnectionFactoryExceptionClass
-
getNoConnectionFactoryExceptionMessage
Obtains the message ofExceptionwhen no connection available.- Returns:
- Message of
Exceptionwhen no connection available.
-
getJpaManagedObjectSourceClass
Allows overriding theJpaManagedObjectSourceClassfor vendor specific implementations.- Returns:
JpaManagedObjectSourceClassto use in testing.
-
loadDataSourceProperties
Loads the properties for theDataSourceManagedObjectSource.- Parameters:
mos-PropertyConfigurable.
-
cleanDatabase
Cleans the database.- Parameters:
connection-Connection.- Throws:
SQLException- If fails to clean the database.
-
setUp
Sets up the test.- Throws:
Exception- On test failure.
-
tearDown
Tears down the test.- Throws:
Exception- On test failure.
-
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
Ensure ifEntityManageris managing theDataSourcethat it is validated on start up.- Throws:
Throwable- On test failure.
-
connectionReadWithCompiler
Ensure able to read entry from database with compiled wrappers.- Throws:
Throwable- On test failure.
-
connectionReadWithDynamicProxy
Ensure able to read entry from database withProxy.- Throws:
Throwable- On test failure.
-
dataSourceRead
Ensure able to read entry viaDataSource.- Throws:
Throwable- On test failure.
-
doReadTest
Ensure able to read entry from database.- Parameters:
isConnection- Indicates ifConnectionotherwiseDataSource.- Throws:
Throwable- On test failure.
-
insertWithCompiler
Ensure able to insert entry into database with compiled wrappers.- Throws:
Throwable- On test failure.
-
insertWithDynamicProxy
Ensure able to insert entry into database withProxy.- Throws:
Throwable- On test failure.
-
insertDataSource
Ensure able to insert entry viaDataSource.- Throws:
Throwable- On test failure.
-
doInsertTest
Ensure able to insert entry into database.- Parameters:
isConnection- Indicates ifConnectionotherwiseDataSource.- Throws:
Throwable- On test failure.
-
updateWithCompiler
Ensure able to update entry into database with compiled wrappers.- Throws:
Throwable- On test failure.
-
updateWithDynamicProxy
Ensure able to update entry into database withProxy.- Throws:
Throwable- On test failure.
-
updateDataSource
Ensure able to update entry viaDataSource.- Throws:
Throwable- On test failure.
-
doUpdateTest
Ensure able to update entry into database.- Parameters:
isConnection- Indicates ifConnectionotherwiseDataSource.- Throws:
Throwable- On test failure.
-
deleteWithCompiler
Ensure able to delete entry from database with compiled wrappers.- Throws:
Throwable- On test failure.
-
deleteWithDynamicProxy
Ensure able to delete entry from database withProxy.- Throws:
Throwable- On test failure.
-
deleteDataSource
Ensure able to delete entry viaDataSource.- Throws:
Throwable- On test failure.
-
doDeleteTest
Ensure able to delete entry from database.- Parameters:
isConnection- Indicates ifConnectionotherwiseDataSource.- Throws:
Throwable- On test failure.
-
forceCommitWithCompiler
Undertake forcing commit with compiled wrappers.- Throws:
Throwable- On test failure.
-
forceCommitWithDynamicProxy
Undertake forcing commit withProxy.- Throws:
Throwable- On test failure.
-
isTransactional
protected boolean isTransactional()Indicates if JPA is transactional.- Returns:
trueif JPA is transactional.
-
stressInsertWithCompiler
Undertake stress insert test with compiled wrappers.- Parameters:
testInfo-TestInfo.- Throws:
Throwable- On test failure.
-
stressInsertWithDynamicProxy
Undertake stress insert test withProxy.- Parameters:
testInfo-TestInfo.- Throws:
Throwable- On test failure.
-
testStressInsertDataSource
Undertake stress insert test withDataSource.- Parameters:
testInfo-TestInfo.- Throws:
Throwable- On test failure.
-
stressSelectWithCompiler
Ensure stress select with compiled wrappers.- Parameters:
testInfo-TestInfo.- Throws:
Throwable- On test failure.
-
stressSelectWithDynamicProxy
Ensure stress select withProxy.- Parameters:
testInfo-TestInfo.- Throws:
Throwable- On test failure.
-
stressSelectDataSource
Ensure stress select withDataSource.- Parameters:
testInfo-TestInfo.- Throws:
Throwable- On test failure.
-