Rename SQL script annotations in the TCF
Prior to this commit, SQL script annotations and related classes in the TestContext framework (TCF) were named DatabaseInitializer*. However, these annotations are not used only for initialization and are therefore misleading when used for cleaning up the database. This commit refines the names of annotations and related classes for configuring SQL scripts to be executed for integration tests in the TCF as follows: - @DatabaseInitializer -> @Sql - @DatabaseInitializers -> @SqlGroup - DatabaseInitializerTestExecutionListener -> SqlScriptsTestExecutionListener A special thanks goes out to the following attendees of the Zurich Hackergarten meeting last night for their collective brainstorming: @aalmiray, @atsticks, @ollin, @simkuenzi, @tangresh, @vyazelenko. Issue: SPR-7655
This commit is contained in:
@@ -29,23 +29,24 @@ import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* {@code @DatabaseInitializer} is used to annotate a test class or test method
|
||||
* to configure SQL scripts to be executed against a given database during
|
||||
* integration tests.
|
||||
* {@code @Sql} is used to annotate a test class or test method to configure SQL
|
||||
* scripts to be executed against a given database during integration tests.
|
||||
*
|
||||
* <p>Method-level declarations override class-level declarations.
|
||||
*
|
||||
* <p>Script execution is performed by the {@link DatabaseInitializerTestExecutionListener},
|
||||
* <p>Script execution is performed by the {@link SqlScriptsTestExecutionListener},
|
||||
* which is enabled by default.
|
||||
*
|
||||
* <p>The configuration options provided by this annotation are a superset of
|
||||
* those provided by the {@code <jdbc:initialize-database />} XML namespace
|
||||
* element. Consult the Javadoc of individual attributes for details.
|
||||
* <p>The configuration options provided by this annotation are equivalent to
|
||||
* those supported by {@link ScriptUtils} and {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
|
||||
* ResourceDatabasePopulator} but are a superset of those provided by the
|
||||
* {@code <jdbc:initialize-database />} XML namespace element. Consult the
|
||||
* Javadoc of individual attributes in this annotation for details.
|
||||
*
|
||||
* <p>Beginning with Java 8, {@code @DatabaseInitializer} can be used as a
|
||||
* <p>Beginning with Java 8, {@code @Sql} can be used as a
|
||||
* <em>{@linkplain Repeatable repeatable}</em> annotation. Otherwise,
|
||||
* {@link DatabaseInitializers @DatabaseInitializers} can be used as an explicit
|
||||
* container for declaring multiple instances of {@code @DatabaseInitializer}.
|
||||
* {@link SqlGroup @SqlGroup} can be used as an explicit container for declaring
|
||||
* multiple instances of {@code @Sql}.
|
||||
*
|
||||
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
|
||||
* <em>composed annotations</em>; however, attribute overrides are not currently
|
||||
@@ -55,8 +56,8 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @author Sam Brannen
|
||||
* @author Tadaya Tsuyukubo
|
||||
* @since 4.1
|
||||
* @see DatabaseInitializers
|
||||
* @see DatabaseInitializerTestExecutionListener
|
||||
* @see SqlGroup
|
||||
* @see SqlScriptsTestExecutionListener
|
||||
* @see org.springframework.transaction.annotation.Transactional
|
||||
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
|
||||
* @see org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
|
||||
@@ -66,8 +67,8 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
@Inherited
|
||||
@Retention(RUNTIME)
|
||||
@Target({ TYPE, METHOD })
|
||||
@Repeatable(DatabaseInitializers.class)
|
||||
public @interface DatabaseInitializer {
|
||||
@Repeatable(SqlGroup.class)
|
||||
public @interface Sql {
|
||||
|
||||
/**
|
||||
* Enumeration of <em>phases</em> that dictate when SQL scripts are executed.
|
||||
@@ -25,28 +25,26 @@ import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* Container annotation that aggregates several {@link DatabaseInitializer}
|
||||
* annotations.
|
||||
* Container annotation that aggregates several {@link Sql @Sql} annotations.
|
||||
*
|
||||
* <p>Can be used natively, declaring several nested {@link DatabaseInitializer}
|
||||
* annotations. Can also be used in conjunction with Java 8's support for
|
||||
* repeatable annotations, where {@code @DatabaseInitializer} can simply be
|
||||
* declared several times on the same class or method, implicitly generating
|
||||
* this container annotation.
|
||||
* <p>Can be used natively, declaring several nested {@code @Sql} annotations.
|
||||
* Can also be used in conjunction with Java 8's support for repeatable
|
||||
* annotations, where {@code @Sql} can simply be declared several times on the
|
||||
* same class or method, implicitly generating this container annotation.
|
||||
*
|
||||
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
|
||||
* <em>composed annotations</em>.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 4.1
|
||||
* @see DatabaseInitializer
|
||||
* @see Sql
|
||||
*/
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RUNTIME)
|
||||
@Target({ TYPE, METHOD })
|
||||
public @interface DatabaseInitializers {
|
||||
public @interface SqlGroup {
|
||||
|
||||
DatabaseInitializer[] value();
|
||||
Sql[] value();
|
||||
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.test.context.TestContext;
|
||||
import org.springframework.test.context.jdbc.DatabaseInitializer.ExecutionPhase;
|
||||
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
|
||||
import org.springframework.test.context.support.AbstractTestExecutionListener;
|
||||
import org.springframework.test.context.transaction.TestContextTransactionUtils;
|
||||
import org.springframework.test.context.util.TestContextResourceUtils;
|
||||
@@ -45,17 +45,20 @@ import org.springframework.util.ResourceUtils;
|
||||
|
||||
/**
|
||||
* {@code TestExecutionListener} that provides support for executing SQL scripts
|
||||
* configured via the {@link DatabaseInitializer @DatabaseInitializer} annotation.
|
||||
* configured via the {@link Sql @Sql} annotation.
|
||||
*
|
||||
* <p>SQL scripts will be executed {@linkplain #beforeTestMethod(TestContext) before}
|
||||
* <p>Scripts will be executed {@linkplain #beforeTestMethod(TestContext) before}
|
||||
* or {@linkplain #afterTestMethod(TestContext) after} execution of the corresponding
|
||||
* {@linkplain java.lang.reflect.Method test method}, depending on the configured
|
||||
* value of the {@link DatabaseInitializer#requireNewTransaction requireNewTransaction}
|
||||
* flag.
|
||||
* value of the {@link Sql#executionPhase executionPhase} flag.
|
||||
*
|
||||
* <p>Scripts will be executed either within an existing Spring-managed transaction
|
||||
* or within a new, isolated transaction, depending on the configured value of the
|
||||
* {@link Sql#requireNewTransaction requireNewTransaction} flag.
|
||||
*
|
||||
* <h3>Script Resources</h3>
|
||||
* <p>For details on default script detection and how explicit script locations
|
||||
* are interpreted, see {@link DatabaseInitializer#scripts}.
|
||||
* are interpreted, see {@link Sql#scripts}.
|
||||
*
|
||||
* <h3>Required Spring Beans</h3>
|
||||
* <p>A {@link DataSource} and {@link PlatformTransactionManager} must be defined
|
||||
@@ -66,106 +69,105 @@ import org.springframework.util.ResourceUtils;
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 4.1
|
||||
* @see DatabaseInitializer
|
||||
* @see DatabaseInitializers
|
||||
* @see Sql
|
||||
* @see SqlGroup
|
||||
* @see org.springframework.test.context.transaction.TestContextTransactionUtils
|
||||
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
|
||||
* @see org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
|
||||
* @see org.springframework.jdbc.datasource.init.ScriptUtils
|
||||
*/
|
||||
public class DatabaseInitializerTestExecutionListener extends AbstractTestExecutionListener {
|
||||
public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListener {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(DatabaseInitializerTestExecutionListener.class);
|
||||
private static final Log logger = LogFactory.getLog(SqlScriptsTestExecutionListener.class);
|
||||
|
||||
|
||||
/**
|
||||
* Execute SQL scripts configured via {@link DatabaseInitializer @DatabaseInitializer}
|
||||
* for the supplied {@link TestContext} <em>before</em> the current test method.
|
||||
* Execute SQL scripts configured via {@link Sql @Sql} for the supplied
|
||||
* {@link TestContext} <em>before</em> the current test method.
|
||||
*/
|
||||
@Override
|
||||
public void beforeTestMethod(TestContext testContext) throws Exception {
|
||||
executeDatabaseInitializers(testContext, ExecutionPhase.BEFORE_TEST_METHOD);
|
||||
executeSqlScripts(testContext, ExecutionPhase.BEFORE_TEST_METHOD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute SQL scripts configured via {@link DatabaseInitializer @DatabaseInitializer}
|
||||
* for the supplied {@link TestContext} <em>after</em> the current test method.
|
||||
* Execute SQL scripts configured via {@link Sql @Sql} for the supplied
|
||||
* {@link TestContext} <em>after</em> the current test method.
|
||||
*/
|
||||
@Override
|
||||
public void afterTestMethod(TestContext testContext) throws Exception {
|
||||
executeDatabaseInitializers(testContext, ExecutionPhase.AFTER_TEST_METHOD);
|
||||
executeSqlScripts(testContext, ExecutionPhase.AFTER_TEST_METHOD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute SQL scripts configured via {@link DatabaseInitializer @DatabaseInitializer}
|
||||
* for the supplied {@link TestContext} and {@link ExecutionPhase}.
|
||||
* Execute SQL scripts configured via {@link Sql @Sql} for the supplied
|
||||
* {@link TestContext} and {@link ExecutionPhase}.
|
||||
*/
|
||||
private void executeDatabaseInitializers(TestContext testContext, ExecutionPhase executionPhase) throws Exception {
|
||||
private void executeSqlScripts(TestContext testContext, ExecutionPhase executionPhase) throws Exception {
|
||||
boolean classLevel = false;
|
||||
|
||||
Set<DatabaseInitializer> databaseInitializers = AnnotationUtils.getRepeatableAnnotation(
|
||||
testContext.getTestMethod(), DatabaseInitializers.class, DatabaseInitializer.class);
|
||||
if (databaseInitializers.isEmpty()) {
|
||||
databaseInitializers = AnnotationUtils.getRepeatableAnnotation(testContext.getTestClass(),
|
||||
DatabaseInitializers.class, DatabaseInitializer.class);
|
||||
if (!databaseInitializers.isEmpty()) {
|
||||
Set<Sql> sqlAnnotations = AnnotationUtils.getRepeatableAnnotation(testContext.getTestMethod(), SqlGroup.class,
|
||||
Sql.class);
|
||||
if (sqlAnnotations.isEmpty()) {
|
||||
sqlAnnotations = AnnotationUtils.getRepeatableAnnotation(testContext.getTestClass(), SqlGroup.class,
|
||||
Sql.class);
|
||||
if (!sqlAnnotations.isEmpty()) {
|
||||
classLevel = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (DatabaseInitializer databaseInitializer : databaseInitializers) {
|
||||
executeDatabaseInitializer(databaseInitializer, executionPhase, testContext, classLevel);
|
||||
for (Sql sql : sqlAnnotations) {
|
||||
executeSqlScripts(sql, executionPhase, testContext, classLevel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the SQL scripts configured via the supplied
|
||||
* {@link DatabaseInitializer @DatabaseInitializer} for the given
|
||||
* {@link ExecutionPhase} and {@link TestContext}.
|
||||
* Execute the SQL scripts configured via the supplied {@link Sql @Sql}
|
||||
* annotation for the given {@link ExecutionPhase} and {@link TestContext}.
|
||||
*
|
||||
* <p>Special care must be taken in order to properly support the
|
||||
* {@link DatabaseInitializer#requireNewTransaction requireNewTransaction}
|
||||
* {@link Sql#requireNewTransaction requireNewTransaction}
|
||||
* flag.
|
||||
*
|
||||
* @param databaseInitializer the {@code @DatabaseInitializer} to parse
|
||||
* @param sql the {@code @Sql} annotation to parse
|
||||
* @param executionPhase the current execution phase
|
||||
* @param testContext the current {@code TestContext}
|
||||
* @param classLevel {@code true} if {@link DatabaseInitializer @DatabaseInitializer}
|
||||
* was declared at the class level
|
||||
* @param classLevel {@code true} if {@link Sql @Sql} was declared at the
|
||||
* class level
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private void executeDatabaseInitializer(DatabaseInitializer databaseInitializer, ExecutionPhase executionPhase,
|
||||
TestContext testContext, boolean classLevel) throws Exception {
|
||||
private void executeSqlScripts(Sql sql, ExecutionPhase executionPhase, TestContext testContext, boolean classLevel)
|
||||
throws Exception {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("Processing %s for execution phase [%s] and test context %s.",
|
||||
databaseInitializer, executionPhase, testContext));
|
||||
logger.debug(String.format("Processing %s for execution phase [%s] and test context %s.", sql,
|
||||
executionPhase, testContext));
|
||||
}
|
||||
|
||||
if (executionPhase != databaseInitializer.executionPhase()) {
|
||||
if (executionPhase != sql.executionPhase()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
|
||||
populator.setSqlScriptEncoding(databaseInitializer.encoding());
|
||||
populator.setSeparator(databaseInitializer.separator());
|
||||
populator.setCommentPrefix(databaseInitializer.commentPrefix());
|
||||
populator.setBlockCommentStartDelimiter(databaseInitializer.blockCommentStartDelimiter());
|
||||
populator.setBlockCommentEndDelimiter(databaseInitializer.blockCommentEndDelimiter());
|
||||
populator.setContinueOnError(databaseInitializer.continueOnError());
|
||||
populator.setIgnoreFailedDrops(databaseInitializer.ignoreFailedDrops());
|
||||
populator.setSqlScriptEncoding(sql.encoding());
|
||||
populator.setSeparator(sql.separator());
|
||||
populator.setCommentPrefix(sql.commentPrefix());
|
||||
populator.setBlockCommentStartDelimiter(sql.blockCommentStartDelimiter());
|
||||
populator.setBlockCommentEndDelimiter(sql.blockCommentEndDelimiter());
|
||||
populator.setContinueOnError(sql.continueOnError());
|
||||
populator.setIgnoreFailedDrops(sql.ignoreFailedDrops());
|
||||
|
||||
String[] scripts = getScripts(databaseInitializer, testContext, classLevel);
|
||||
String[] scripts = getScripts(sql, testContext, classLevel);
|
||||
scripts = TestContextResourceUtils.convertToClasspathResourcePaths(testContext.getTestClass(), scripts);
|
||||
populator.setScripts(TestContextResourceUtils.convertToResources(testContext.getApplicationContext(), scripts));
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Executing SQL scripts: " + ObjectUtils.nullSafeToString(scripts));
|
||||
}
|
||||
|
||||
final DataSource dataSource = TestContextTransactionUtils.retrieveDataSource(testContext,
|
||||
databaseInitializer.dataSource());
|
||||
final DataSource dataSource = TestContextTransactionUtils.retrieveDataSource(testContext, sql.dataSource());
|
||||
final PlatformTransactionManager transactionManager = TestContextTransactionUtils.retrieveTransactionManager(
|
||||
testContext, databaseInitializer.transactionManager());
|
||||
testContext, sql.transactionManager());
|
||||
|
||||
int propagation = databaseInitializer.requireNewTransaction() ? TransactionDefinition.PROPAGATION_REQUIRES_NEW
|
||||
int propagation = sql.requireNewTransaction() ? TransactionDefinition.PROPAGATION_REQUIRES_NEW
|
||||
: TransactionDefinition.PROPAGATION_REQUIRED;
|
||||
|
||||
TransactionAttribute transactionAttribute = TestContextTransactionUtils.createDelegatingTransactionAttribute(
|
||||
@@ -180,9 +182,9 @@ public class DatabaseInitializerTestExecutionListener extends AbstractTestExecut
|
||||
});
|
||||
}
|
||||
|
||||
private String[] getScripts(DatabaseInitializer databaseInitializer, TestContext testContext, boolean classLevel) {
|
||||
String[] scripts = databaseInitializer.scripts();
|
||||
String[] value = databaseInitializer.value();
|
||||
private String[] getScripts(Sql sql, TestContext testContext, boolean classLevel) {
|
||||
String[] scripts = sql.scripts();
|
||||
String[] value = sql.value();
|
||||
boolean scriptsDeclared = !ObjectUtils.isEmpty(scripts);
|
||||
boolean valueDeclared = !ObjectUtils.isEmpty(value);
|
||||
|
||||
@@ -190,9 +192,9 @@ public class DatabaseInitializerTestExecutionListener extends AbstractTestExecut
|
||||
String elementType = (classLevel ? "class" : "method");
|
||||
String elementName = (classLevel ? testContext.getTestClass().getName()
|
||||
: testContext.getTestMethod().toString());
|
||||
String msg = String.format("Test %s [%s] has been configured with @DatabaseInitializer's 'value' [%s] "
|
||||
String msg = String.format("Test %s [%s] has been configured with @Sql's 'value' [%s] "
|
||||
+ "and 'scripts' [%s] attributes. Only one declaration of SQL script "
|
||||
+ "paths is permitted per @DatabaseInitializer annotation.", elementType, elementName,
|
||||
+ "paths is permitted per @Sql annotation.", elementType, elementName,
|
||||
ObjectUtils.nullSafeToString(value), ObjectUtils.nullSafeToString(scripts));
|
||||
logger.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
@@ -208,7 +210,7 @@ public class DatabaseInitializerTestExecutionListener extends AbstractTestExecut
|
||||
|
||||
/**
|
||||
* Detect a default SQL script by implementing the algorithm defined in
|
||||
* {@link DatabaseInitializer#scripts}.
|
||||
* {@link Sql#scripts}.
|
||||
*/
|
||||
private String detectDefaultScript(TestContext testContext, boolean classLevel) {
|
||||
Class<?> clazz = testContext.getTestClass();
|
||||
@@ -234,7 +236,7 @@ public class DatabaseInitializerTestExecutionListener extends AbstractTestExecut
|
||||
}
|
||||
else {
|
||||
String msg = String.format("Could not detect default SQL script for test %s [%s]: "
|
||||
+ "%s does not exist. Either declare scripts via @DatabaseInitializer or make the "
|
||||
+ "%s does not exist. Either declare scripts via @Sql or make the "
|
||||
+ "default SQL script available.", elementType, elementName, classPathResource);
|
||||
logger.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
@@ -26,7 +26,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.jdbc.DatabaseInitializerTestExecutionListener;
|
||||
import org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener;
|
||||
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
@@ -64,7 +64,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.TestExecutionListeners
|
||||
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
|
||||
* @see org.springframework.test.context.jdbc.DatabaseInitializerTestExecutionListener
|
||||
* @see org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener
|
||||
* @see org.springframework.test.context.transaction.TransactionConfiguration
|
||||
* @see org.springframework.transaction.annotation.Transactional
|
||||
* @see org.springframework.test.annotation.Rollback
|
||||
@@ -73,7 +73,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @see org.springframework.test.jdbc.JdbcTestUtils
|
||||
* @see org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests
|
||||
*/
|
||||
@TestExecutionListeners({ TransactionalTestExecutionListener.class, DatabaseInitializerTestExecutionListener.class })
|
||||
@TestExecutionListeners({ TransactionalTestExecutionListener.class, SqlScriptsTestExecutionListener.class })
|
||||
@Transactional
|
||||
public abstract class AbstractTransactionalJUnit4SpringContextTests extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.test.context.TestExecutionListener;
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.transaction.TransactionalTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.jdbc.DatabaseInitializerTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener}
|
||||
* </ol>
|
||||
* <li>Uses {@link DelegatingSmartContextLoader} as the default {@link ContextLoader}.
|
||||
* <li>Builds a standard {@link MergedContextConfiguration}.
|
||||
@@ -53,7 +53,7 @@ public class DefaultTestContextBootstrapper extends AbstractTestContextBootstrap
|
||||
"org.springframework.test.context.support.DependencyInjectionTestExecutionListener",
|
||||
"org.springframework.test.context.support.DirtiesContextTestExecutionListener",
|
||||
"org.springframework.test.context.transaction.TransactionalTestExecutionListener",
|
||||
"org.springframework.test.context.jdbc.DatabaseInitializerTestExecutionListener"));
|
||||
"org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener"));
|
||||
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class DefaultTestContextBootstrapper extends AbstractTestContextBootstrap
|
||||
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.transaction.TransactionalTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.jdbc.DatabaseInitializerTestExecutionListener}
|
||||
* <li>{@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener}
|
||||
* </ol>
|
||||
*/
|
||||
protected List<String> getDefaultTestExecutionListenerClassNames() {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.jdbc.DatabaseInitializerTestExecutionListener;
|
||||
import org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener;
|
||||
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
@@ -55,7 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.TestExecutionListeners
|
||||
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
|
||||
* @see org.springframework.test.context.jdbc.DatabaseInitializerTestExecutionListener
|
||||
* @see org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener
|
||||
* @see org.springframework.test.context.transaction.TransactionConfiguration
|
||||
* @see org.springframework.transaction.annotation.Transactional
|
||||
* @see org.springframework.test.annotation.Rollback
|
||||
@@ -64,7 +64,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @see org.springframework.test.jdbc.JdbcTestUtils
|
||||
* @see org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests
|
||||
*/
|
||||
@TestExecutionListeners({ TransactionalTestExecutionListener.class, DatabaseInitializerTestExecutionListener.class })
|
||||
@TestExecutionListeners({ TransactionalTestExecutionListener.class, SqlScriptsTestExecutionListener.class })
|
||||
@Transactional
|
||||
public abstract class AbstractTransactionalTestNGSpringContextTests extends AbstractTestNGSpringContextTests {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user