com.github.springtestdbunit
Class DbUnitTestExecutionListener

java.lang.Object
  extended by org.springframework.test.context.support.AbstractTestExecutionListener
      extended by com.github.springtestdbunit.DbUnitTestExecutionListener
All Implemented Interfaces:
org.springframework.test.context.TestExecutionListener

public class DbUnitTestExecutionListener
extends org.springframework.test.context.support.AbstractTestExecutionListener

TestExecutionListener which provides support for @DatabaseSetup, @DatabaseTearDown and @ExpectedDatabase annotations.

A bean named "dbUnitDatabaseConnection" or "dataSource" is expected in the ApplicationContext associated with the test. This bean can contain either a IDatabaseConnection or a DataSource . A custom bean name can also be specified using the @DbUnitConfiguration annotation.

Datasets are loaded using the FlatXmlDataSetLoader unless otherwise configured.

If you are running this listener in combination with the TransactionalTestExecutionListener then consider using TransactionDbUnitTestExecutionListener instead.

Author:
Phillip Webb
See Also:
TransactionDbUnitTestExecutionListener

Field Summary
protected static String CONNECTION_ATTRIBUTE
           
protected static String DATA_SET_LOADER_ATTRIBUTE
           
 
Constructor Summary
DbUnitTestExecutionListener()
           
 
Method Summary
 void afterTestMethod(org.springframework.test.context.TestContext testContext)
           
 void beforeTestMethod(org.springframework.test.context.TestContext testContext)
           
 void prepareTestInstance(org.springframework.test.context.TestContext testContext)
           
 
Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestClass, beforeTestClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECTION_ATTRIBUTE

protected static final String CONNECTION_ATTRIBUTE

DATA_SET_LOADER_ATTRIBUTE

protected static final String DATA_SET_LOADER_ATTRIBUTE
Constructor Detail

DbUnitTestExecutionListener

public DbUnitTestExecutionListener()
Method Detail

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

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

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


Copyright © 2012. All Rights Reserved.