提交 028a6901 编写于 作者: J Juergen Hoeller

Polishing

上级 ed98393f
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -203,7 +203,7 @@ public class OrderComparator implements Comparator<Object> {
* Strategy interface to provide an order source for a given object.
* @since 4.1
*/
public static interface OrderSourceProvider {
public interface OrderSourceProvider {
/**
* Return an order source for the specified object, i.e. an object that
......
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -68,29 +68,10 @@ import static java.lang.annotation.RetentionPolicy.*;
@Documented
@Inherited
@Retention(RUNTIME)
@Target({ TYPE, METHOD })
@Target({TYPE, METHOD})
@Repeatable(SqlGroup.class)
public @interface Sql {
/**
* Enumeration of <em>phases</em> that dictate when SQL scripts are executed.
*/
static enum ExecutionPhase {
/**
* The configured SQL scripts and statements will be executed
* <em>before</em> the corresponding test method.
*/
BEFORE_TEST_METHOD,
/**
* The configured SQL scripts and statements will be executed
* <em>after</em> the corresponding test method.
*/
AFTER_TEST_METHOD
}
/**
* Alias for {@link #scripts}.
* <p>This attribute may <strong>not</strong> be used in conjunction with
......@@ -173,4 +154,23 @@ public @interface Sql {
*/
SqlConfig config() default @SqlConfig();
/**
* Enumeration of <em>phases</em> that dictate when SQL scripts are executed.
*/
enum ExecutionPhase {
/**
* The configured SQL scripts and statements will be executed
* <em>before</em> the corresponding test method.
*/
BEFORE_TEST_METHOD,
/**
* The configured SQL scripts and statements will be executed
* <em>after</em> the corresponding test method.
*/
AFTER_TEST_METHOD
}
}
/*
* 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");
* you may not use this file except in compliance with the License.
......@@ -65,12 +65,122 @@ import static java.lang.annotation.RetentionPolicy.*;
@Target(TYPE)
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>"*&#47;"</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
* executed within a transaction and what the transaction propagation behavior
* should be.
*/
static enum TransactionMode {
enum TransactionMode {
/**
* Indicates that the <em>default</em> transaction mode should be used.
......@@ -137,11 +247,12 @@ public @interface SqlConfig {
ISOLATED
}
/**
* Enumeration of <em>modes</em> that dictate how errors are handled while
* executing SQL statements.
*/
static enum ErrorMode {
enum ErrorMode {
/**
* Indicates that the <em>default</em> error mode should be used.
......@@ -188,114 +299,4 @@ public @interface SqlConfig {
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>"*&#47;"</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;
}
/*
* 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");
* you may not use this file except in compliance with the License.
......@@ -42,7 +42,7 @@ import static java.lang.annotation.RetentionPolicy.*;
@Documented
@Inherited
@Retention(RUNTIME)
@Target({ TYPE, METHOD })
@Target({TYPE, METHOD})
public @interface SqlGroup {
Sql[] value();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册