Skip to content

Commit cafb99a

Browse files
committed
Polishing
(cherry picked from commit 028a690)
1 parent 9c5cabf commit cafb99a

File tree

4 files changed

+139
-138
lines changed

4 files changed

+139
-138
lines changed

spring-core/src/main/java/org/springframework/core/OrderComparator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -203,7 +203,7 @@ else if (value instanceof List) {
203203
* Strategy interface to provide an order source for a given object.
204204
* @since 4.1
205205
*/
206-
public static interface OrderSourceProvider {
206+
public interface OrderSourceProvider {
207207

208208
/**
209209
* Return an order source for the specified object, i.e. an object that

spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -68,29 +68,10 @@
6868
@Documented
6969
@Inherited
7070
@Retention(RUNTIME)
71-
@Target({ TYPE, METHOD })
71+
@Target({TYPE, METHOD})
7272
@Repeatable(SqlGroup.class)
7373
public @interface Sql {
7474

75-
/**
76-
* Enumeration of <em>phases</em> that dictate when SQL scripts are executed.
77-
*/
78-
static enum ExecutionPhase {
79-
80-
/**
81-
* The configured SQL scripts and statements will be executed
82-
* <em>before</em> the corresponding test method.
83-
*/
84-
BEFORE_TEST_METHOD,
85-
86-
/**
87-
* The configured SQL scripts and statements will be executed
88-
* <em>after</em> the corresponding test method.
89-
*/
90-
AFTER_TEST_METHOD
91-
}
92-
93-
9475
/**
9576
* Alias for {@link #scripts}.
9677
* <p>This attribute may <strong>not</strong> be used in conjunction with
@@ -173,4 +154,23 @@ static enum ExecutionPhase {
173154
*/
174155
SqlConfig config() default @SqlConfig();
175156

157+
158+
/**
159+
* Enumeration of <em>phases</em> that dictate when SQL scripts are executed.
160+
*/
161+
enum ExecutionPhase {
162+
163+
/**
164+
* The configured SQL scripts and statements will be executed
165+
* <em>before</em> the corresponding test method.
166+
*/
167+
BEFORE_TEST_METHOD,
168+
169+
/**
170+
* The configured SQL scripts and statements will be executed
171+
* <em>after</em> the corresponding test method.
172+
*/
173+
AFTER_TEST_METHOD
174+
}
175+
176176
}

spring-test/src/main/java/org/springframework/test/context/jdbc/SqlConfig.java

Lines changed: 114 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -65,12 +65,122 @@
6565
@Target(TYPE)
6666
public @interface SqlConfig {
6767

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>"*&#47;"</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+
68178
/**
69179
* Enumeration of <em>modes</em> that dictate whether SQL scripts should be
70180
* executed within a transaction and what the transaction propagation behavior
71181
* should be.
72182
*/
73-
static enum TransactionMode {
183+
enum TransactionMode {
74184

75185
/**
76186
* Indicates that the <em>default</em> transaction mode should be used.
@@ -137,11 +247,12 @@ static enum TransactionMode {
137247
ISOLATED
138248
}
139249

250+
140251
/**
141252
* Enumeration of <em>modes</em> that dictate how errors are handled while
142253
* executing SQL statements.
143254
*/
144-
static enum ErrorMode {
255+
enum ErrorMode {
145256

146257
/**
147258
* Indicates that the <em>default</em> error mode should be used.
@@ -188,114 +299,4 @@ static enum ErrorMode {
188299
IGNORE_FAILED_DROPS
189300
}
190301

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>"*&#47;"</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-
301302
}

spring-test/src/main/java/org/springframework/test/context/jdbc/SqlGroup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@
4242
@Documented
4343
@Inherited
4444
@Retention(RUNTIME)
45-
@Target({ TYPE, METHOD })
45+
@Target({TYPE, METHOD})
4646
public @interface SqlGroup {
4747

4848
Sql[] value();

0 commit comments

Comments
 (0)