|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2016 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
65 | 65 | @Target(TYPE)
|
66 | 66 | public @interface SqlConfig {
|
67 | 67 |
|
| 68 | + /** |
| 69 | + * The bean name of the {@link javax.sql.DataSource} against which the |
| 70 | + * scripts should be executed. |
| 71 | + * <p>The name is only required if there is more than one bean of type |
| 72 | + * {@code DataSource} in the test's {@code ApplicationContext}. If there |
| 73 | + * is only one such bean, it is not necessary to specify a bean name. |
| 74 | + * <p>Defaults to an empty string, requiring that one of the following is |
| 75 | + * true: |
| 76 | + * <ol> |
| 77 | + * <li>An explicit bean name is defined in a global declaration of |
| 78 | + * {@code @SqlConfig}. |
| 79 | + * <li>The data source can be retrieved from the transaction manager |
| 80 | + * by using reflection to invoke a public method named |
| 81 | + * {@code getDataSource()} on the transaction manager. |
| 82 | + * <li>There is only one bean of type {@code DataSource} in the test's |
| 83 | + * {@code ApplicationContext}.</li> |
| 84 | + * <li>The {@code DataSource} to use is named {@code "dataSource"}.</li> |
| 85 | + * </ol> |
| 86 | + * @see org.springframework.test.context.transaction.TestContextTransactionUtils#retrieveDataSource |
| 87 | + */ |
| 88 | + String dataSource() default ""; |
| 89 | + |
| 90 | + /** |
| 91 | + * The bean name of the {@link org.springframework.transaction.PlatformTransactionManager |
| 92 | + * PlatformTransactionManager} that should be used to drive transactions. |
| 93 | + * <p>The name is only used if there is more than one bean of type |
| 94 | + * {@code PlatformTransactionManager} in the test's {@code ApplicationContext}. |
| 95 | + * If there is only one such bean, it is not necessary to specify a bean name. |
| 96 | + * <p>Defaults to an empty string, requiring that one of the following is |
| 97 | + * true: |
| 98 | + * <ol> |
| 99 | + * <li>An explicit bean name is defined in a global declaration of |
| 100 | + * {@code @SqlConfig}. |
| 101 | + * <li>There is only one bean of type {@code PlatformTransactionManager} in |
| 102 | + * the test's {@code ApplicationContext}.</li> |
| 103 | + * <li>{@link org.springframework.transaction.annotation.TransactionManagementConfigurer |
| 104 | + * TransactionManagementConfigurer} has been implemented to specify which |
| 105 | + * {@code PlatformTransactionManager} bean should be used for annotation-driven |
| 106 | + * transaction management.</li> |
| 107 | + * <li>The {@code PlatformTransactionManager} to use is named |
| 108 | + * {@code "transactionManager"}.</li> |
| 109 | + * </ol> |
| 110 | + * @see org.springframework.test.context.transaction.TestContextTransactionUtils#retrieveTransactionManager |
| 111 | + */ |
| 112 | + String transactionManager() default ""; |
| 113 | + |
| 114 | + /** |
| 115 | + * The <em>mode</em> to use when determining whether SQL scripts should be |
| 116 | + * executed within a transaction. |
| 117 | + * <p>Defaults to {@link TransactionMode#DEFAULT DEFAULT}. |
| 118 | + * <p>Can be set to {@link TransactionMode#ISOLATED} to ensure that the SQL |
| 119 | + * scripts are executed in a new, isolated transaction that will be immediately |
| 120 | + * committed. |
| 121 | + * @see TransactionMode |
| 122 | + */ |
| 123 | + TransactionMode transactionMode() default TransactionMode.DEFAULT; |
| 124 | + |
| 125 | + /** |
| 126 | + * The encoding for the supplied SQL scripts, if different from the platform |
| 127 | + * encoding. |
| 128 | + * <p>An empty string denotes that the platform encoding should be used. |
| 129 | + */ |
| 130 | + String encoding() default ""; |
| 131 | + |
| 132 | + /** |
| 133 | + * The character string used to separate individual statements within the |
| 134 | + * SQL scripts. |
| 135 | + * <p>Implicitly defaults to {@code ";"} if not specified and falls back to |
| 136 | + * {@code "\n"} as a last resort. |
| 137 | + * <p>May be set to |
| 138 | + * {@link org.springframework.jdbc.datasource.init.ScriptUtils#EOF_STATEMENT_SEPARATOR} |
| 139 | + * to signal that each script contains a single statement without a |
| 140 | + * separator. |
| 141 | + * @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_STATEMENT_SEPARATOR |
| 142 | + * @see org.springframework.jdbc.datasource.init.ScriptUtils#EOF_STATEMENT_SEPARATOR |
| 143 | + */ |
| 144 | + String separator() default ""; |
| 145 | + |
| 146 | + /** |
| 147 | + * The prefix that identifies single-line comments within the SQL scripts. |
| 148 | + * <p>Implicitly defaults to {@code "--"}. |
| 149 | + * @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_COMMENT_PREFIX |
| 150 | + */ |
| 151 | + String commentPrefix() default ""; |
| 152 | + |
| 153 | + /** |
| 154 | + * The start delimiter that identifies block comments within the SQL scripts. |
| 155 | + * <p>Implicitly defaults to {@code "/*"}. |
| 156 | + * @see #blockCommentEndDelimiter |
| 157 | + * @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_BLOCK_COMMENT_START_DELIMITER |
| 158 | + */ |
| 159 | + String blockCommentStartDelimiter() default ""; |
| 160 | + |
| 161 | + /** |
| 162 | + * The end delimiter that identifies block comments within the SQL scripts. |
| 163 | + * <p>Implicitly defaults to <code>"*/"</code>. |
| 164 | + * @see #blockCommentStartDelimiter |
| 165 | + * @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_BLOCK_COMMENT_END_DELIMITER |
| 166 | + */ |
| 167 | + String blockCommentEndDelimiter() default ""; |
| 168 | + |
| 169 | + /** |
| 170 | + * The <em>mode</em> to use when an error is encountered while executing an |
| 171 | + * SQL statement. |
| 172 | + * <p>Defaults to {@link ErrorMode#DEFAULT DEFAULT}. |
| 173 | + * @see ErrorMode |
| 174 | + */ |
| 175 | + ErrorMode errorMode() default ErrorMode.DEFAULT; |
| 176 | + |
| 177 | + |
68 | 178 | /**
|
69 | 179 | * Enumeration of <em>modes</em> that dictate whether SQL scripts should be
|
70 | 180 | * executed within a transaction and what the transaction propagation behavior
|
71 | 181 | * should be.
|
72 | 182 | */
|
73 |
| - static enum TransactionMode { |
| 183 | + enum TransactionMode { |
74 | 184 |
|
75 | 185 | /**
|
76 | 186 | * Indicates that the <em>default</em> transaction mode should be used.
|
@@ -137,11 +247,12 @@ static enum TransactionMode {
|
137 | 247 | ISOLATED
|
138 | 248 | }
|
139 | 249 |
|
| 250 | + |
140 | 251 | /**
|
141 | 252 | * Enumeration of <em>modes</em> that dictate how errors are handled while
|
142 | 253 | * executing SQL statements.
|
143 | 254 | */
|
144 |
| - static enum ErrorMode { |
| 255 | + enum ErrorMode { |
145 | 256 |
|
146 | 257 | /**
|
147 | 258 | * Indicates that the <em>default</em> error mode should be used.
|
@@ -188,114 +299,4 @@ static enum ErrorMode {
|
188 | 299 | IGNORE_FAILED_DROPS
|
189 | 300 | }
|
190 | 301 |
|
191 |
| - |
192 |
| - /** |
193 |
| - * The bean name of the {@link javax.sql.DataSource} against which the |
194 |
| - * scripts should be executed. |
195 |
| - * <p>The name is only required if there is more than one bean of type |
196 |
| - * {@code DataSource} in the test's {@code ApplicationContext}. If there |
197 |
| - * is only one such bean, it is not necessary to specify a bean name. |
198 |
| - * <p>Defaults to an empty string, requiring that one of the following is |
199 |
| - * true: |
200 |
| - * <ol> |
201 |
| - * <li>An explicit bean name is defined in a global declaration of |
202 |
| - * {@code @SqlConfig}. |
203 |
| - * <li>The data source can be retrieved from the transaction manager |
204 |
| - * by using reflection to invoke a public method named |
205 |
| - * {@code getDataSource()} on the transaction manager. |
206 |
| - * <li>There is only one bean of type {@code DataSource} in the test's |
207 |
| - * {@code ApplicationContext}.</li> |
208 |
| - * <li>The {@code DataSource} to use is named {@code "dataSource"}.</li> |
209 |
| - * </ol> |
210 |
| - * @see org.springframework.test.context.transaction.TestContextTransactionUtils#retrieveDataSource |
211 |
| - */ |
212 |
| - String dataSource() default ""; |
213 |
| - |
214 |
| - /** |
215 |
| - * The bean name of the {@link org.springframework.transaction.PlatformTransactionManager |
216 |
| - * PlatformTransactionManager} that should be used to drive transactions. |
217 |
| - * <p>The name is only used if there is more than one bean of type |
218 |
| - * {@code PlatformTransactionManager} in the test's {@code ApplicationContext}. |
219 |
| - * If there is only one such bean, it is not necessary to specify a bean name. |
220 |
| - * <p>Defaults to an empty string, requiring that one of the following is |
221 |
| - * true: |
222 |
| - * <ol> |
223 |
| - * <li>An explicit bean name is defined in a global declaration of |
224 |
| - * {@code @SqlConfig}. |
225 |
| - * <li>There is only one bean of type {@code PlatformTransactionManager} in |
226 |
| - * the test's {@code ApplicationContext}.</li> |
227 |
| - * <li>{@link org.springframework.transaction.annotation.TransactionManagementConfigurer |
228 |
| - * TransactionManagementConfigurer} has been implemented to specify which |
229 |
| - * {@code PlatformTransactionManager} bean should be used for annotation-driven |
230 |
| - * transaction management.</li> |
231 |
| - * <li>The {@code PlatformTransactionManager} to use is named |
232 |
| - * {@code "transactionManager"}.</li> |
233 |
| - * </ol> |
234 |
| - * @see org.springframework.test.context.transaction.TestContextTransactionUtils#retrieveTransactionManager |
235 |
| - */ |
236 |
| - String transactionManager() default ""; |
237 |
| - |
238 |
| - /** |
239 |
| - * The <em>mode</em> to use when determining whether SQL scripts should be |
240 |
| - * executed within a transaction. |
241 |
| - * <p>Defaults to {@link TransactionMode#DEFAULT DEFAULT}. |
242 |
| - * <p>Can be set to {@link TransactionMode#ISOLATED} to ensure that the SQL |
243 |
| - * scripts are executed in a new, isolated transaction that will be immediately |
244 |
| - * committed. |
245 |
| - * @see TransactionMode |
246 |
| - */ |
247 |
| - TransactionMode transactionMode() default TransactionMode.DEFAULT; |
248 |
| - |
249 |
| - /** |
250 |
| - * The encoding for the supplied SQL scripts, if different from the platform |
251 |
| - * encoding. |
252 |
| - * <p>An empty string denotes that the platform encoding should be used. |
253 |
| - */ |
254 |
| - String encoding() default ""; |
255 |
| - |
256 |
| - /** |
257 |
| - * The character string used to separate individual statements within the |
258 |
| - * SQL scripts. |
259 |
| - * <p>Implicitly defaults to {@code ";"} if not specified and falls back to |
260 |
| - * {@code "\n"} as a last resort. |
261 |
| - * <p>May be set to |
262 |
| - * {@link org.springframework.jdbc.datasource.init.ScriptUtils#EOF_STATEMENT_SEPARATOR} |
263 |
| - * to signal that each script contains a single statement without a |
264 |
| - * separator. |
265 |
| - * @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_STATEMENT_SEPARATOR |
266 |
| - * @see org.springframework.jdbc.datasource.init.ScriptUtils#EOF_STATEMENT_SEPARATOR |
267 |
| - */ |
268 |
| - String separator() default ""; |
269 |
| - |
270 |
| - /** |
271 |
| - * The prefix that identifies single-line comments within the SQL scripts. |
272 |
| - * <p>Implicitly defaults to {@code "--"}. |
273 |
| - * @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_COMMENT_PREFIX |
274 |
| - */ |
275 |
| - String commentPrefix() default ""; |
276 |
| - |
277 |
| - /** |
278 |
| - * The start delimiter that identifies block comments within the SQL scripts. |
279 |
| - * <p>Implicitly defaults to {@code "/*"}. |
280 |
| - * @see #blockCommentEndDelimiter |
281 |
| - * @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_BLOCK_COMMENT_START_DELIMITER |
282 |
| - */ |
283 |
| - String blockCommentStartDelimiter() default ""; |
284 |
| - |
285 |
| - /** |
286 |
| - * The end delimiter that identifies block comments within the SQL scripts. |
287 |
| - * <p>Implicitly defaults to <code>"*/"</code>. |
288 |
| - * @see #blockCommentStartDelimiter |
289 |
| - * @see org.springframework.jdbc.datasource.init.ScriptUtils#DEFAULT_BLOCK_COMMENT_END_DELIMITER |
290 |
| - */ |
291 |
| - String blockCommentEndDelimiter() default ""; |
292 |
| - |
293 |
| - /** |
294 |
| - * The <em>mode</em> to use when an error is encountered while executing an |
295 |
| - * SQL statement. |
296 |
| - * <p>Defaults to {@link ErrorMode#DEFAULT DEFAULT}. |
297 |
| - * @see ErrorMode |
298 |
| - */ |
299 |
| - ErrorMode errorMode() default ErrorMode.DEFAULT; |
300 |
| - |
301 | 302 | }
|
0 commit comments