Package org.javalite.activejdbc.test
Class DBSpec
java.lang.Object
org.javalite.activejdbc.connection_config.DBConfiguration
org.javalite.activejdbc.test.DBSpec
- All Implemented Interfaces:
JSpecSupport
Super class for tests that need to use a DB connection. The connection is configured in
database.properties
file. Test connection transactions work in the following manner:
- A connection is opened, and the autocommit is set to
false
- The test method picks the connection from teh current thread, uses it to read/write data to the DB
- Once the test method exits, the framework rolls back transaction and closes the connection
- Author:
- igor on 12/2/16.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
static void
void
boolean
rollback()
Current state of 'rollback' flag.void
setRollback(boolean rollback)
Set to true in order to rollback a transaction at the end of the test (default is true)..Methods inherited from class org.javalite.activejdbc.connection_config.DBConfiguration
addConnectionConfig, addConnectionConfig, clearConnectionConfigs, clearConnectionConfigs, closeTestConnections, getConnectionConfigs, getConnectionConfigsExceptTesting, getConnectionConfigsForCurrentEnv, getTestConnectionConfigs, loadConfiguration, openTestConnections, resetConnectionConfigs
-
Constructor Details
-
DBSpec
public DBSpec()
-
-
Method Details
-
rollback
public boolean rollback()Current state of 'rollback' flag.- Returns:
- Current state of 'rollback' flag.
-
setRollback
public void setRollback(boolean rollback)Set to true in order to rollback a transaction at the end of the test (default is true)..WARNING: if you set this value to false inside your test, the framework will not clean any remaining data you insert into your test database. Basically, this is a "manual mode" where you are responsible for cleaning after yourself.
- Parameters:
rollback
- true to rollback transactions at the end of the test, false to not rollback.
-
openConnections
@BeforeEach public final void openConnections() -
closeConnections
@AfterEach public final void closeConnections() -
initDBConfig
@BeforeAll public static void initDBConfig()
-