|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -65,12 +65,122 @@ import static java.lang.annotation.RetentionPolicy.*; |
|
|
|
@Target(TYPE) |
|
|
|
@Target(TYPE) |
|
|
|
public @interface SqlConfig { |
|
|
|
public @interface SqlConfig { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The bean name of the {@link javax.sql.DataSource} against which the |
|
|
|
|
|
|
|
* scripts should be executed. |
|
|
|
|
|
|
|
* <p>The name is only required if there is more than one bean of type |
|
|
|
|
|
|
|
* {@code DataSource} in the test's {@code ApplicationContext}. If there |
|
|
|
|
|
|
|
* is only one such bean, it is not necessary to specify a bean name. |
|
|
|
|
|
|
|
* <p>Defaults to an empty string, requiring that one of the following is |
|
|
|
|
|
|
|
* true: |
|
|
|
|
|
|
|
* <ol> |
|
|
|
|
|
|
|
* <li>An explicit bean name is defined in a global declaration of |
|
|
|
|
|
|
|
* {@code @SqlConfig}. |
|
|
|
|
|
|
|
* <li>The data source can be retrieved from the transaction manager |
|
|
|
|
|
|
|
* by using reflection to invoke a public method named |
|
|
|
|
|
|
|
* {@code getDataSource()} on the transaction manager. |
|
|
|
|
|
|
|
* <li>There is only one bean of type {@code DataSource} in the test's |
|
|
|
|
|
|
|
* {@code ApplicationContext}.</li> |
|
|
|
|
|
|
|
* <li>The {@code DataSource} to use is named {@code "dataSource"}.</li> |
|
|
|
|
|
|
|
* </ol> |
|
|
|
|
|
|
|
* @see org.springframework.test.context.transaction.TestContextTransactionUtils#retrieveDataSource |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String dataSource() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The bean name of the {@link org.springframework.transaction.PlatformTransactionManager |
|
|
|
|
|
|
|
* PlatformTransactionManager} that should be used to drive transactions. |
|
|
|
|
|
|
|
* <p>The name is only used if there is more than one bean of type |
|
|
|
|
|
|
|
* {@code PlatformTransactionManager} in the test's {@code ApplicationContext}. |
|
|
|
|
|
|
|
* If there is only one such bean, it is not necessary to specify a bean name. |
|
|
|
|
|
|
|
* <p>Defaults to an empty string, requiring that one of the following is |
|
|
|
|
|
|
|
* true: |
|
|
|
|
|
|
|
* <ol> |
|
|
|
|
|
|
|
* <li>An explicit bean name is defined in a global declaration of |
|
|
|
|
|
|
|
* {@code @SqlConfig}. |
|
|
|
|
|
|
|
* <li>There is only one bean of type {@code PlatformTransactionManager} in |
|
|
|
|
|
|
|
* the test's {@code ApplicationContext}.</li> |
|
|
|
|
|
|
|
* <li>{@link org.springframework.transaction.annotation.TransactionManagementConfigurer |
|
|
|
|
|
|
|
* TransactionManagementConfigurer} has been implemented to specify which |
|
|
|
|
|
|
|
* {@code PlatformTransactionManager} bean should be used for annotation-driven |
|
|
|
|
|
|
|
* transaction management.</li> |
|
|
|
|
|
|
|
* <li>The {@code PlatformTransactionManager} to use is named |
|
|
|
|
|
|
|
* {@code "transactionManager"}.</li> |
|
|
|
|
|
|
|
* </ol> |
|
|
|
|
|
|
|
* @see org.springframework.test.context.transaction.TestContextTransactionUtils#retrieveTransactionManager |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String transactionManager() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The <em>mode</em> to use when determining whether SQL scripts should be |
|
|
|
|
|
|
|
* executed within a transaction. |
|
|
|
|
|
|
|
* <p>Defaults to {@link TransactionMode#DEFAULT DEFAULT}. |
|
|
|
|
|
|
|
* <p>Can be set to {@link TransactionMode#ISOLATED} to ensure that the SQL |
|
|
|
|
|
|
|
* scripts are executed in a new, isolated transaction that will be immediately |
|
|
|
|
|
|
|
* committed. |
|
|
|
|
|
|
|
* @see TransactionMode |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
TransactionMode transactionMode() default TransactionMode.DEFAULT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The encoding for the supplied SQL scripts, if different from the platform |
|
|
|
|
|
|
|
* encoding. |
|
|
|
|
|
|
|
* <p>An empty string denotes that the platform encoding should be used. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String encoding() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The character string used to separate individual statements within the |
|
|
|
|
|
|
|
* SQL scripts. |
|
|
|
|
|
|
|
* <p>Implicitly defaults to {@code ";"} if not specified and falls back to |
|
|
|
|
|
|
|
* {@code "\n"} as a last resort. |
|
|
|
|
|
|
|
* <p>May be set to |
|
|
|
|
|
|
|
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#EOF_STATEMENT_SEPARATOR} |
|
|
|
|
|
|
|
* to signal that each script contains a single statement without a |
|
|
|
|
|
|
|
* separator. |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_STATEMENT_SEPARATOR |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#EOF_STATEMENT_SEPARATOR |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String separator() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The prefix that identifies single-line comments within the SQL scripts. |
|
|
|
|
|
|
|
* <p>Implicitly defaults to {@code "--"}. |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_COMMENT_PREFIX |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String commentPrefix() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The start delimiter that identifies block comments within the SQL scripts. |
|
|
|
|
|
|
|
* <p>Implicitly defaults to {@code "/*"}. |
|
|
|
|
|
|
|
* @see #blockCommentEndDelimiter |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_BLOCK_COMMENT_START_DELIMITER |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String blockCommentStartDelimiter() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The end delimiter that identifies block comments within the SQL scripts. |
|
|
|
|
|
|
|
* <p>Implicitly defaults to <code>"*/"</code>. |
|
|
|
|
|
|
|
* @see #blockCommentStartDelimiter |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_BLOCK_COMMENT_END_DELIMITER |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String blockCommentEndDelimiter() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The <em>mode</em> to use when an error is encountered while executing an |
|
|
|
|
|
|
|
* SQL statement. |
|
|
|
|
|
|
|
* <p>Defaults to {@link ErrorMode#DEFAULT DEFAULT}. |
|
|
|
|
|
|
|
* @see ErrorMode |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
ErrorMode errorMode() default ErrorMode.DEFAULT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Enumeration of <em>modes</em> that dictate whether SQL scripts should be |
|
|
|
* Enumeration of <em>modes</em> that dictate whether SQL scripts should be |
|
|
|
* executed within a transaction and what the transaction propagation behavior |
|
|
|
* executed within a transaction and what the transaction propagation behavior |
|
|
|
* should be. |
|
|
|
* should be. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static enum TransactionMode { |
|
|
|
enum TransactionMode { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Indicates that the <em>default</em> transaction mode should be used. |
|
|
|
* Indicates that the <em>default</em> transaction mode should be used. |
|
|
|
@ -137,11 +247,12 @@ public @interface SqlConfig { |
|
|
|
ISOLATED |
|
|
|
ISOLATED |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Enumeration of <em>modes</em> that dictate how errors are handled while |
|
|
|
* Enumeration of <em>modes</em> that dictate how errors are handled while |
|
|
|
* executing SQL statements. |
|
|
|
* executing SQL statements. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static enum ErrorMode { |
|
|
|
enum ErrorMode { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Indicates that the <em>default</em> error mode should be used. |
|
|
|
* Indicates that the <em>default</em> error mode should be used. |
|
|
|
@ -188,114 +299,4 @@ public @interface SqlConfig { |
|
|
|
IGNORE_FAILED_DROPS |
|
|
|
IGNORE_FAILED_DROPS |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The bean name of the {@link javax.sql.DataSource} against which the |
|
|
|
|
|
|
|
* scripts should be executed. |
|
|
|
|
|
|
|
* <p>The name is only required if there is more than one bean of type |
|
|
|
|
|
|
|
* {@code DataSource} in the test's {@code ApplicationContext}. If there |
|
|
|
|
|
|
|
* is only one such bean, it is not necessary to specify a bean name. |
|
|
|
|
|
|
|
* <p>Defaults to an empty string, requiring that one of the following is |
|
|
|
|
|
|
|
* true: |
|
|
|
|
|
|
|
* <ol> |
|
|
|
|
|
|
|
* <li>An explicit bean name is defined in a global declaration of |
|
|
|
|
|
|
|
* {@code @SqlConfig}. |
|
|
|
|
|
|
|
* <li>The data source can be retrieved from the transaction manager |
|
|
|
|
|
|
|
* by using reflection to invoke a public method named |
|
|
|
|
|
|
|
* {@code getDataSource()} on the transaction manager. |
|
|
|
|
|
|
|
* <li>There is only one bean of type {@code DataSource} in the test's |
|
|
|
|
|
|
|
* {@code ApplicationContext}.</li> |
|
|
|
|
|
|
|
* <li>The {@code DataSource} to use is named {@code "dataSource"}.</li> |
|
|
|
|
|
|
|
* </ol> |
|
|
|
|
|
|
|
* @see org.springframework.test.context.transaction.TestContextTransactionUtils#retrieveDataSource |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String dataSource() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The bean name of the {@link org.springframework.transaction.PlatformTransactionManager |
|
|
|
|
|
|
|
* PlatformTransactionManager} that should be used to drive transactions. |
|
|
|
|
|
|
|
* <p>The name is only used if there is more than one bean of type |
|
|
|
|
|
|
|
* {@code PlatformTransactionManager} in the test's {@code ApplicationContext}. |
|
|
|
|
|
|
|
* If there is only one such bean, it is not necessary to specify a bean name. |
|
|
|
|
|
|
|
* <p>Defaults to an empty string, requiring that one of the following is |
|
|
|
|
|
|
|
* true: |
|
|
|
|
|
|
|
* <ol> |
|
|
|
|
|
|
|
* <li>An explicit bean name is defined in a global declaration of |
|
|
|
|
|
|
|
* {@code @SqlConfig}. |
|
|
|
|
|
|
|
* <li>There is only one bean of type {@code PlatformTransactionManager} in |
|
|
|
|
|
|
|
* the test's {@code ApplicationContext}.</li> |
|
|
|
|
|
|
|
* <li>{@link org.springframework.transaction.annotation.TransactionManagementConfigurer |
|
|
|
|
|
|
|
* TransactionManagementConfigurer} has been implemented to specify which |
|
|
|
|
|
|
|
* {@code PlatformTransactionManager} bean should be used for annotation-driven |
|
|
|
|
|
|
|
* transaction management.</li> |
|
|
|
|
|
|
|
* <li>The {@code PlatformTransactionManager} to use is named |
|
|
|
|
|
|
|
* {@code "transactionManager"}.</li> |
|
|
|
|
|
|
|
* </ol> |
|
|
|
|
|
|
|
* @see org.springframework.test.context.transaction.TestContextTransactionUtils#retrieveTransactionManager |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String transactionManager() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The <em>mode</em> to use when determining whether SQL scripts should be |
|
|
|
|
|
|
|
* executed within a transaction. |
|
|
|
|
|
|
|
* <p>Defaults to {@link TransactionMode#DEFAULT DEFAULT}. |
|
|
|
|
|
|
|
* <p>Can be set to {@link TransactionMode#ISOLATED} to ensure that the SQL |
|
|
|
|
|
|
|
* scripts are executed in a new, isolated transaction that will be immediately |
|
|
|
|
|
|
|
* committed. |
|
|
|
|
|
|
|
* @see TransactionMode |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
TransactionMode transactionMode() default TransactionMode.DEFAULT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The encoding for the supplied SQL scripts, if different from the platform |
|
|
|
|
|
|
|
* encoding. |
|
|
|
|
|
|
|
* <p>An empty string denotes that the platform encoding should be used. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String encoding() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The character string used to separate individual statements within the |
|
|
|
|
|
|
|
* SQL scripts. |
|
|
|
|
|
|
|
* <p>Implicitly defaults to {@code ";"} if not specified and falls back to |
|
|
|
|
|
|
|
* {@code "\n"} as a last resort. |
|
|
|
|
|
|
|
* <p>May be set to |
|
|
|
|
|
|
|
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#EOF_STATEMENT_SEPARATOR} |
|
|
|
|
|
|
|
* to signal that each script contains a single statement without a |
|
|
|
|
|
|
|
* separator. |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_STATEMENT_SEPARATOR |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#EOF_STATEMENT_SEPARATOR |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String separator() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The prefix that identifies single-line comments within the SQL scripts. |
|
|
|
|
|
|
|
* <p>Implicitly defaults to {@code "--"}. |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_COMMENT_PREFIX |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String commentPrefix() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The start delimiter that identifies block comments within the SQL scripts. |
|
|
|
|
|
|
|
* <p>Implicitly defaults to {@code "/*"}. |
|
|
|
|
|
|
|
* @see #blockCommentEndDelimiter |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_BLOCK_COMMENT_START_DELIMITER |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String blockCommentStartDelimiter() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The end delimiter that identifies block comments within the SQL scripts. |
|
|
|
|
|
|
|
* <p>Implicitly defaults to <code>"*/"</code>. |
|
|
|
|
|
|
|
* @see #blockCommentStartDelimiter |
|
|
|
|
|
|
|
* @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_BLOCK_COMMENT_END_DELIMITER |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
String blockCommentEndDelimiter() default ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The <em>mode</em> to use when an error is encountered while executing an |
|
|
|
|
|
|
|
* SQL statement. |
|
|
|
|
|
|
|
* <p>Defaults to {@link ErrorMode#DEFAULT DEFAULT}. |
|
|
|
|
|
|
|
* @see ErrorMode |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
ErrorMode errorMode() default ErrorMode.DEFAULT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|