Class DBControllerSpec

All Implemented Interfaces:
JSpecSupport

public class DBControllerSpec extends ControllerSpec
Super class for controllers requiring a DB connection to the test DB. Connection is opened before a test, closed after a test and a transaction is rolled back.
Author:
Igor Polevoy
  • Constructor Details

    • DBControllerSpec

      public DBControllerSpec()
  • 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). This method will set the autocommit = !rollback on all connections found on this thread.

      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.
    • initDBConfig

      @BeforeAll public static void initDBConfig()
    • open

      @BeforeEach public final void open()
    • close

      @AfterEach public final void close()
    • clearConnectionConfigs

      @AfterAll public static void clearConnectionConfigs()