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
    • Field Summary

      • Fields inherited from interface org.springframework.core.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterTestClass​(org.springframework.test.context.TestContext testContext)  
      void afterTestMethod​(org.springframework.test.context.TestContext testContext)  
      void beforeTestClass​(org.springframework.test.context.TestContext testContext)  
      void beforeTestMethod​(org.springframework.test.context.TestContext testContext)  
      static java.util.List<java.lang.reflect.Method> getOrderedTestMethods​(java.lang.Class<?> testClass)  
      static void getOrderedTestMethods​(java.lang.Class<?> testClass, java.util.List<java.lang.reflect.Method> methods)  
      void prepareTestInstance​(org.springframework.test.context.TestContext testContext)  
      • Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener

        getOrder
      • Methods inherited from class java.lang.Object

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

      • TemporaryDatabaseExecutionListener

        public TemporaryDatabaseExecutionListener()
    • Method Detail

      • afterTestMethod

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

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

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

        public static java.util.List<java.lang.reflect.Method> getOrderedTestMethods​(java.lang.Class<?> testClass)
      • getOrderedTestMethods

        public static void getOrderedTestMethods​(java.lang.Class<?> testClass,
                                                 java.util.List<java.lang.reflect.Method> methods)
      • beforeTestClass

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

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