spring-framework / org.springframework.test.context.jdbc

Package org.springframework.test.context.jdbc

Annotations

Sql

class Sql

@Sql is used to annotate a test class or test method to configure SQL #scripts and #statements to be executed against a given database during integration tests.

Method-level declarations override class-level declarations.

Script execution is performed by the SqlScriptsTestExecutionListener, which is enabled by default.

The configuration options provided by this annotation and SqlConfig are equivalent to those supported by org.springframework.jdbc.datasource.init.ScriptUtils and org.springframework.jdbc.datasource.init.ResourceDatabasePopulator but are a superset of those provided by the <jdbc:initialize-database/> XML namespace element. Consult the javadocs of individual attributes in this annotation and SqlConfig for details.

Beginning with Java 8, @Sql can be used as a Repeatable annotation. Otherwise, SqlGroup can be used as an explicit container for declaring multiple instances of @Sql.

This annotation may be used as a meta-annotation to create custom composed annotations with attribute overrides.

SqlGroup

class SqlGroup

Container annotation that aggregates several Sql annotations.

Can be used natively, declaring several nested @Sql annotations. Can also be used in conjunction with Java 8's support for repeatable annotations, where @Sql can simply be declared several times on the same class or method, implicitly generating this container annotation.

This annotation may be used as a meta-annotation to create custom composed annotations.