Class AttachToDatabase

java.lang.Object
org.junit.rules.TestWatcher
com.atlassian.jira.junit.rules.AttachToDatabase
All Implemented Interfaces:
org.junit.rules.TestRule

public class AttachToDatabase extends org.junit.rules.TestWatcher
Initialises the container pieces you need to attach to a real database when running unit tests.

This rule has the side effect of clearing all tables in the database schema after each test is run. Use DatabaseContainer to activate this rule in your tests.

Note that our current intention is to only run these tests against PostgreSQL. As such these tests will not work with other databases out of the box. Further changes may be required.

Since:
v7.1
See Also:
  • Constructor Details

    • AttachToDatabase

      public AttachToDatabase(MockitoContainer mockitoContainer)
      Instead of instantiating this directly, you probably want to use DatabaseContainer.rule(Object)
      Parameters:
      mockitoContainer - the container to load components into
  • Method Details

    • starting

      protected void starting(org.junit.runner.Description description)
      Overrides:
      starting in class org.junit.rules.TestWatcher
    • succeeded

      protected void succeeded(org.junit.runner.Description description)
      Overrides:
      succeeded in class org.junit.rules.TestWatcher
    • finished

      protected void finished(org.junit.runner.Description description)
      Overrides:
      finished in class org.junit.rules.TestWatcher
    • getQueryDslAccessor

      public QueryDslAccessor getQueryDslAccessor()
    • getOfBizDelegator

      public OfBizDelegator getOfBizDelegator()