Package org.nuiton.topia.junit
Class AbstractDatabaseResource<PersistenceContext extends TopiaPersistenceContext,ApplicationContext extends AbstractTopiaApplicationContext<PersistenceContext>>
java.lang.Object
org.junit.rules.TestWatcher
org.nuiton.topia.junit.AbstractDatabaseResource<PersistenceContext,ApplicationContext>
- All Implemented Interfaces:
org.junit.rules.TestRule
public abstract class AbstractDatabaseResource<PersistenceContext extends TopiaPersistenceContext,ApplicationContext extends AbstractTopiaApplicationContext<PersistenceContext>>
extends org.junit.rules.TestWatcher
Put this class as a Rule in test to obtain a new isolated db for each test.
Here is a simple example of usage :
public class MyTest {
\@Rule
public final TopiaDatabase db = new TopiaDatabase();
\@Test
public void testMethod() throws TopiaException {
TopiaContext tx = db.beginTransaction();
...
}
The db created will be unique for each test method (and for each build also).
You don't need to close any transaction, it will be done for you and the end
of each method test.
Created on 11/22/13.- Since:
- 3.0
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ApplicationContextcreateApplicationContext(TopiaConfiguration topiaConfiguration) voidfinished(org.junit.runner.Description description) protected voidstarting(org.junit.runner.Description description) Methods inherited from class org.junit.rules.TestWatcher
apply, failed, skipped, skipped, succeeded
-
Field Details
-
applicationContext
protected ApplicationContext extends AbstractTopiaApplicationContext<PersistenceContext> applicationContext -
topiaConfiguration
-
-
Constructor Details
-
AbstractDatabaseResource
public AbstractDatabaseResource()
-
-
Method Details
-
createApplicationContext
protected abstract ApplicationContext createApplicationContext(TopiaConfiguration topiaConfiguration) -
starting
protected void starting(org.junit.runner.Description description) - Overrides:
startingin classorg.junit.rules.TestWatcher
-
finished
public void finished(org.junit.runner.Description description) - Overrides:
finishedin classorg.junit.rules.TestWatcher
-
getApplicationContext
-
newPersistenceContext
-
getTopiaConfiguration
-