Class FlywayTestExecutionListener

java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
org.flywaydb.test.FlywayTestExecutionListener
org.flywaydb.test.junit.FlywayTestExecutionListener
All Implemented Interfaces:
org.springframework.core.Ordered, org.springframework.test.context.TestExecutionListener

public class FlywayTestExecutionListener extends FlywayTestExecutionListener
Deprecated.
Spring test execution listener to get annotation FlywayTest up and running

If the annotation FlywayTest used on class level a clean , init , migrate cycle is done during class load.
If the annotation FlywayTest used on test method level a clean , init , migrate cycle is done before test execution.

Important if the annotation FlywayTest are used the system properties for jdbc.url, jdbc.driver, jdbc.username, and jdbc.password should be set.

Also the test application context should contains code like this:
 
 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="location" value="dbc.properties"/>
   <property name="ignoreResourceNotFound" value="true"/>
 </bean>

 <bean id="flyway" class="org.flywaydb.core.Flyway" depends-on="data.source.id">
   <property name="dataSource" ref="data.source.id"/>
   <property name="locations" value="oracle"/>
 </bean>

     <!-- H2 Setup
     -Djdbc.driver=org.h2.Driver
  -Djdbc.url=jdbc:h2:./db/testCaseDb
  -Djdbc.username=OC_MORE_TEST
  -Djdbc.password=OC_MORE_TEST
      -->
  <bean id="dataSourceRef" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName"><value>$jdbc.driver</value></property>
        <property name="url"><value>$jdbc.url</value></property>
        <property name="username"><value>$jdbc.username</value></property>
        <property name="password"><value>$jdbc.password</value></property>
  </bean>
 
 
If this setup is used exist the possibility to run test again different database such as H2 or Oracle.

Usage inside the test class

 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations={"/context/simple_applicationContext.xml"})
 @TestExecutionListeners({DependencyInjectionTestExecutionListener.class,
    FlywayTestExecutionListener.class})
 @FlywayTest
 public class SimpleLoadTest
 

Notes:
  • If you using spring framework version lower than 3.x the annotation FlywayTest wont work at class level.
  • For spring framework version 2.5.6 use simple_applicationContext_spring256.xml as application context example
  • If you using the annotation FlywayTest more than one time in test classes than do not use parallel execution in surefire plugin.
    With this option you will setup your database in more than one thread parallel!

Version:
2011-12-10, 1.7
Author:
Florian, EddĂș MelĂ©ndez
  • Constructor Details

    • FlywayTestExecutionListener

      public FlywayTestExecutionListener()
      Deprecated.
      Allocates new AbstractDbSpringContextTests instance.