Class TransactionalTests

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public final class TransactionalTests
    extends java.lang.Object
    implements org.junit.rules.TestRule
    A JUnit TestRule that can be used to run the test-methods in transactions.

    To use the rule, create a database and add the following lines to your test:

     @Rule
     public final TransactionalTests transactionalTests = new TransactionalTests(db);
     
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull org.junit.runners.model.Statement apply​(@NotNull org.junit.runners.model.Statement base, @NotNull org.junit.runner.Description description)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TransactionalTests

        public TransactionalTests​(@NotNull
                                  @NotNull org.dalesbred.Database db)
        Constructs a rule that will wrap tests in transactions and use the default rollback-policy (TransactionalTests.RollbackPolicy.ROLLBACK_ON_FAILURE) for rolling back the transaction.
      • TransactionalTests

        public TransactionalTests​(@NotNull
                                  @NotNull org.dalesbred.Database db,
                                  @NotNull
                                  @NotNull TransactionalTests.RollbackPolicy rollbackPolicy)
        Constructs a rule that will wrap tests in transactions and use the specified rollback-policy for rolling back the transaction.
      • TransactionalTests

        public TransactionalTests​(@NotNull
                                  @NotNull javax.inject.Provider<org.dalesbred.Database> db)
        Constructs a rule that will wrap tests in transactions and use the default rollback-policy (TransactionalTests.RollbackPolicy.ROLLBACK_ON_FAILURE) for rolling back the transaction.
      • TransactionalTests

        public TransactionalTests​(@NotNull
                                  @NotNull javax.inject.Provider<org.dalesbred.Database> db,
                                  @NotNull
                                  @NotNull TransactionalTests.RollbackPolicy rollbackPolicy)
        Constructs a rule that will wrap tests in transactions and use the specified rollback-policy for rolling back the transaction.
    • Method Detail

      • apply

        @NotNull
        public @NotNull org.junit.runners.model.Statement apply​(@NotNull
                                                                @NotNull org.junit.runners.model.Statement base,
                                                                @NotNull
                                                                @NotNull org.junit.runner.Description description)
        Specified by:
        apply in interface org.junit.rules.TestRule