Class TemporaryDatabaseExecutionListener

  • All Implemented Interfaces:
    org.springframework.core.Ordered, org.springframework.test.context.TestExecutionListener

    public class TemporaryDatabaseExecutionListener
    extends org.springframework.test.context.support.AbstractTestExecutionListener
    This TestExecutionListener creates a temporary database and then registers it as the default datasource inside DataSourceFactory by using DataSourceFactory.setInstance(DataSource). To change the settings for the temporary database, use the JUnitTemporaryDatabase annotation on the test class or method.
    Author:
    Mathew Brozowski
    • Constructor Detail

      • TemporaryDatabaseExecutionListener

        public TemporaryDatabaseExecutionListener()
    • Method Detail

      • afterTestMethod

        public void afterTestMethod​(org.springframework.test.context.TestContext testContext)
                             throws Exception
        Specified by:
        afterTestMethod in interface org.springframework.test.context.TestExecutionListener
        Overrides:
        afterTestMethod in class org.springframework.test.context.support.AbstractTestExecutionListener
        Throws:
        Exception
      • afterTestClass

        public void afterTestClass​(org.springframework.test.context.TestContext testContext)
                            throws Exception
        Specified by:
        afterTestClass in interface org.springframework.test.context.TestExecutionListener
        Overrides:
        afterTestClass in class org.springframework.test.context.support.AbstractTestExecutionListener
        Throws:
        Exception
      • beforeTestMethod

        public void beforeTestMethod​(org.springframework.test.context.TestContext testContext)
                              throws Exception
        Specified by:
        beforeTestMethod in interface org.springframework.test.context.TestExecutionListener
        Overrides:
        beforeTestMethod in class org.springframework.test.context.support.AbstractTestExecutionListener
        Throws:
        Exception
      • getOrderedTestMethods

        public static List<Method> getOrderedTestMethods​(Class<?> testClass)
      • getOrderedTestMethods

        public static void getOrderedTestMethods​(Class<?> testClass,
                                                 List<Method> methods)
      • beforeTestClass

        public void beforeTestClass​(org.springframework.test.context.TestContext testContext)
                             throws Exception
        Specified by:
        beforeTestClass in interface org.springframework.test.context.TestExecutionListener
        Overrides:
        beforeTestClass in class org.springframework.test.context.support.AbstractTestExecutionListener
        Throws:
        Exception
      • prepareTestInstance

        public void prepareTestInstance​(org.springframework.test.context.TestContext testContext)
                                 throws Exception
        Specified by:
        prepareTestInstance in interface org.springframework.test.context.TestExecutionListener
        Overrides:
        prepareTestInstance in class org.springframework.test.context.support.AbstractTestExecutionListener
        Throws:
        Exception