Package org.nuiton.topia
Class TopiaDatabase
java.lang.Object
org.junit.rules.TestWatcher
org.nuiton.topia.TopiaDatabase
- All Implemented Interfaces:
org.junit.rules.TestRule
public class TopiaDatabase
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.- Since:
- 2.6.8
- Author:
- tchemit <chemit@codelutin.com>
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringTIMESTAMPA time-stamp, allow to make multiple build and keep the tests data. -
Constructor Summary
Constructors Constructor Description TopiaDatabase()TopiaDatabase(java.lang.String configurationPath) -
Method Summary
Modifier and Type Method Description org.nuiton.topia.TopiaContextbeginTransaction()voidfinished(org.junit.runner.Description description)java.util.PropertiesgetDbConfiguration()org.nuiton.topia.TopiaContextgetRootCtxt()java.io.FilegetTestBasedir()static java.io.FilegetTestSpecificDirectory(java.lang.Class<?> testClassName, java.lang.String methodName)protected voidonDbConfigurationCreate(java.util.Properties configuration, java.io.File testDir, java.lang.String dbPath)protected voidstarting(org.junit.runner.Description description)
-
Field Details
-
TIMESTAMP
public static final java.lang.String TIMESTAMPA time-stamp, allow to make multiple build and keep the tests data.
-
-
Constructor Details
-
TopiaDatabase
public TopiaDatabase() -
TopiaDatabase
public TopiaDatabase(java.lang.String configurationPath)
-
-
Method Details
-
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
-
getTestBasedir
public java.io.File getTestBasedir() -
getRootCtxt
public org.nuiton.topia.TopiaContext getRootCtxt() -
getDbConfiguration
public java.util.Properties getDbConfiguration() -
beginTransaction
public org.nuiton.topia.TopiaContext beginTransaction() throws org.nuiton.topia.TopiaException- Throws:
org.nuiton.topia.TopiaException
-
onDbConfigurationCreate
protected void onDbConfigurationCreate(java.util.Properties configuration, java.io.File testDir, java.lang.String dbPath) -
getTestSpecificDirectory
public static java.io.File getTestSpecificDirectory(java.lang.Class<?> testClassName, java.lang.String methodName)
-