Polishing
This commit is contained in:
@@ -17,12 +17,11 @@
|
||||
package org.springframework.test.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* {@code @Commit} is a test annotation that is used to indicate that a
|
||||
* <em>test-managed transaction</em> should be <em>committed</em> after
|
||||
@@ -49,9 +48,9 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @see Rollback
|
||||
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target({ TYPE, METHOD })
|
||||
@Rollback(false)
|
||||
public @interface Commit {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -76,19 +76,48 @@ import java.lang.annotation.Target;
|
||||
* @see org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener
|
||||
* @see org.springframework.test.context.support.DirtiesContextTestExecutionListener
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
public @interface DirtiesContext {
|
||||
|
||||
/**
|
||||
* The <i>mode</i> to use when a test method is annotated with
|
||||
* {@code @DirtiesContext}.
|
||||
* <p>Defaults to {@link MethodMode#AFTER_METHOD AFTER_METHOD}.
|
||||
* <p>Setting the method mode on an annotated test class has no meaning.
|
||||
* For class-level control, use {@link #classMode} instead.
|
||||
* @since 4.2
|
||||
*/
|
||||
MethodMode methodMode() default MethodMode.AFTER_METHOD;
|
||||
|
||||
/**
|
||||
* The <i>mode</i> to use when a test class is annotated with
|
||||
* {@code @DirtiesContext}.
|
||||
* <p>Defaults to {@link ClassMode#AFTER_CLASS AFTER_CLASS}.
|
||||
* <p>Setting the class mode on an annotated test method has no meaning.
|
||||
* For method-level control, use {@link #methodMode} instead.
|
||||
* @since 3.0
|
||||
*/
|
||||
ClassMode classMode() default ClassMode.AFTER_CLASS;
|
||||
|
||||
/**
|
||||
* The context cache clearing <em>mode</em> to use when a context is
|
||||
* configured as part of a hierarchy via
|
||||
* {@link org.springframework.test.context.ContextHierarchy @ContextHierarchy}.
|
||||
* <p>Defaults to {@link HierarchyMode#EXHAUSTIVE EXHAUSTIVE}.
|
||||
* @since 3.2.2
|
||||
*/
|
||||
HierarchyMode hierarchyMode() default HierarchyMode.EXHAUSTIVE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines <i>modes</i> which determine how {@code @DirtiesContext} is
|
||||
* interpreted when used to annotate a test method.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
static enum MethodMode {
|
||||
enum MethodMode {
|
||||
|
||||
/**
|
||||
* The associated {@code ApplicationContext} will be marked as
|
||||
@@ -103,13 +132,13 @@ public @interface DirtiesContext {
|
||||
AFTER_METHOD;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines <i>modes</i> which determine how {@code @DirtiesContext} is
|
||||
* interpreted when used to annotate a test class.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
static enum ClassMode {
|
||||
enum ClassMode {
|
||||
|
||||
/**
|
||||
* The associated {@code ApplicationContext} will be marked as
|
||||
@@ -140,15 +169,15 @@ public @interface DirtiesContext {
|
||||
AFTER_CLASS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines <i>modes</i> which determine how the context cache is cleared
|
||||
* when {@code @DirtiesContext} is used in a test whose context is
|
||||
* configured as part of a hierarchy via
|
||||
* {@link org.springframework.test.context.ContextHierarchy @ContextHierarchy}.
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
static enum HierarchyMode {
|
||||
enum HierarchyMode {
|
||||
|
||||
/**
|
||||
* The context cache will be cleared using an <em>exhaustive</em> algorithm
|
||||
@@ -174,37 +203,4 @@ public @interface DirtiesContext {
|
||||
CURRENT_LEVEL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The <i>mode</i> to use when a test method is annotated with
|
||||
* {@code @DirtiesContext}.
|
||||
* <p>Defaults to {@link MethodMode#AFTER_METHOD AFTER_METHOD}.
|
||||
* <p>Setting the method mode on an annotated test class has no meaning.
|
||||
* For class-level control, use {@link #classMode} instead.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
MethodMode methodMode() default MethodMode.AFTER_METHOD;
|
||||
|
||||
/**
|
||||
* The <i>mode</i> to use when a test class is annotated with
|
||||
* {@code @DirtiesContext}.
|
||||
* <p>Defaults to {@link ClassMode#AFTER_CLASS AFTER_CLASS}.
|
||||
* <p>Setting the class mode on an annotated test method has no meaning.
|
||||
* For method-level control, use {@link #methodMode} instead.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
ClassMode classMode() default ClassMode.AFTER_CLASS;
|
||||
|
||||
/**
|
||||
* The context cache clearing <em>mode</em> to use when a context is
|
||||
* configured as part of a hierarchy via
|
||||
* {@link org.springframework.test.context.ContextHierarchy @ContextHierarchy}.
|
||||
* <p>Defaults to {@link HierarchyMode#EXHAUSTIVE EXHAUSTIVE}.
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
HierarchyMode hierarchyMode() default HierarchyMode.EXHAUSTIVE;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -95,10 +95,10 @@ import java.lang.annotation.Target;
|
||||
* @see org.springframework.context.annotation.Profile
|
||||
* @see org.springframework.test.context.ActiveProfiles
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
public @interface IfProfileValue {
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,6 @@ public @interface IfProfileValue {
|
||||
/**
|
||||
* A single, permissible {@code value} of the <em>profile value</em>
|
||||
* for the given {@link #name}.
|
||||
*
|
||||
* <p>Note: Assigning values to both {@link #value} and {@link #values}
|
||||
* will lead to a configuration conflict.
|
||||
*/
|
||||
@@ -118,7 +117,6 @@ public @interface IfProfileValue {
|
||||
/**
|
||||
* A list of all permissible {@code values} of the <em>profile value</em>
|
||||
* for the given {@link #name}.
|
||||
*
|
||||
* <p>Note: Assigning values to both {@link #value} and {@link #values}
|
||||
* will lead to a configuration conflict.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.test.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* Test annotation to indicate that a test method should be invoked repeatedly.
|
||||
*
|
||||
@@ -41,9 +40,9 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @see org.springframework.test.context.junit4.rules.SpringMethodRule
|
||||
* @see org.springframework.test.context.junit4.statements.SpringRepeat
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target({ METHOD, ANNOTATION_TYPE })
|
||||
public @interface Repeat {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.test.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* {@code @Rollback} is a test annotation that is used to indicate whether
|
||||
* a <em>test-managed transaction</em> should be <em>rolled back</em> after
|
||||
@@ -54,9 +53,9 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @see Commit
|
||||
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target({ TYPE, METHOD })
|
||||
public @interface Rollback {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.test.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* Test-specific annotation to indicate that a test method has to finish
|
||||
* execution in a {@linkplain #millis() specified time period}.
|
||||
@@ -45,9 +44,9 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @see org.springframework.test.context.junit4.rules.SpringMethodRule
|
||||
* @see org.springframework.test.context.junit4.statements.SpringFailOnTimeout
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target({ METHOD, ANNOTATION_TYPE })
|
||||
public @interface Timed {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -27,8 +27,8 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@code MergedSqlConfig} encapsulates the <em>merged</em> {@link SqlConfig @SqlConfig}
|
||||
* attributes declared locally via {@link Sql#config} and globally as a
|
||||
* class-level annotation.
|
||||
* attributes declared locally via {@link Sql#config} and globally as a class-level annotation.
|
||||
*
|
||||
* <p>Explicit local configuration attributes override global configuration attributes.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
@@ -56,23 +56,6 @@ class MergedSqlConfig {
|
||||
private final ErrorMode errorMode;
|
||||
|
||||
|
||||
private static <E extends Enum<?>> E getEnum(AnnotationAttributes attributes, String attributeName,
|
||||
E inheritedOrDefaultValue, E defaultValue) {
|
||||
E value = attributes.getEnum(attributeName);
|
||||
if (value == inheritedOrDefaultValue) {
|
||||
value = defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private static String getString(AnnotationAttributes attributes, String attributeName, String defaultValue) {
|
||||
String value = attributes.getString(attributeName);
|
||||
if ("".equals(value)) {
|
||||
value = defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a {@code MergedSqlConfig} instance by merging the configuration
|
||||
* from the supplied local (potentially method-level) {@code @SqlConfig} annotation
|
||||
@@ -86,8 +69,8 @@ class MergedSqlConfig {
|
||||
Assert.notNull(testClass, "testClass must not be null");
|
||||
|
||||
// Get global attributes, if any.
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(testClass,
|
||||
SqlConfig.class.getName(), false, false);
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(
|
||||
testClass, SqlConfig.class.getName(), false, false);
|
||||
|
||||
// Override global attributes with local attributes.
|
||||
if (attributes != null) {
|
||||
@@ -95,7 +78,7 @@ class MergedSqlConfig {
|
||||
Object value = AnnotationUtils.getValue(localSqlConfig, key);
|
||||
if (value != null) {
|
||||
// Is the value explicit (i.e., not a 'default')?
|
||||
if (!value.equals("") && (value != TransactionMode.DEFAULT) && (value != ErrorMode.DEFAULT)) {
|
||||
if (!value.equals("") && value != TransactionMode.DEFAULT && value != ErrorMode.DEFAULT) {
|
||||
attributes.put(key, value);
|
||||
}
|
||||
}
|
||||
@@ -113,9 +96,9 @@ class MergedSqlConfig {
|
||||
this.separator = getString(attributes, "separator", ScriptUtils.DEFAULT_STATEMENT_SEPARATOR);
|
||||
this.commentPrefix = getString(attributes, "commentPrefix", ScriptUtils.DEFAULT_COMMENT_PREFIX);
|
||||
this.blockCommentStartDelimiter = getString(attributes, "blockCommentStartDelimiter",
|
||||
ScriptUtils.DEFAULT_BLOCK_COMMENT_START_DELIMITER);
|
||||
ScriptUtils.DEFAULT_BLOCK_COMMENT_START_DELIMITER);
|
||||
this.blockCommentEndDelimiter = getString(attributes, "blockCommentEndDelimiter",
|
||||
ScriptUtils.DEFAULT_BLOCK_COMMENT_END_DELIMITER);
|
||||
ScriptUtils.DEFAULT_BLOCK_COMMENT_END_DELIMITER);
|
||||
this.errorMode = getEnum(attributes, "errorMode", ErrorMode.DEFAULT, ErrorMode.FAIL_ON_ERROR);
|
||||
}
|
||||
|
||||
@@ -187,17 +170,36 @@ class MergedSqlConfig {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)//
|
||||
.append("dataSource", dataSource)//
|
||||
.append("transactionManager", transactionManager)//
|
||||
.append("transactionMode", transactionMode)//
|
||||
.append("encoding", encoding)//
|
||||
.append("separator", separator)//
|
||||
.append("commentPrefix", commentPrefix)//
|
||||
.append("blockCommentStartDelimiter", blockCommentStartDelimiter)//
|
||||
.append("blockCommentEndDelimiter", blockCommentEndDelimiter)//
|
||||
.append("errorMode", errorMode)//
|
||||
.toString();
|
||||
return new ToStringCreator(this)
|
||||
.append("dataSource", this.dataSource)
|
||||
.append("transactionManager", this.transactionManager)
|
||||
.append("transactionMode", this.transactionMode)
|
||||
.append("encoding", this.encoding)
|
||||
.append("separator", this.separator)
|
||||
.append("commentPrefix", this.commentPrefix)
|
||||
.append("blockCommentStartDelimiter", this.blockCommentStartDelimiter)
|
||||
.append("blockCommentEndDelimiter", this.blockCommentEndDelimiter)
|
||||
.append("errorMode", this.errorMode)
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
private static <E extends Enum<?>> E getEnum(AnnotationAttributes attributes, String attributeName,
|
||||
E inheritedOrDefaultValue, E defaultValue) {
|
||||
|
||||
E value = attributes.getEnum(attributeName);
|
||||
if (value == inheritedOrDefaultValue) {
|
||||
value = defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private static String getString(AnnotationAttributes attributes, String attributeName, String defaultValue) {
|
||||
String value = attributes.getString(attributeName);
|
||||
if ("".equals(value)) {
|
||||
value = defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,16 +17,15 @@
|
||||
package org.springframework.test.context.jdbc;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Repeatable;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* {@code @Sql} is used to annotate a test class or test method to configure
|
||||
* SQL {@link #scripts} and {@link #statements} to be executed against a given
|
||||
@@ -65,10 +64,10 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @see org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
|
||||
* @see org.springframework.jdbc.datasource.init.ScriptUtils
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RUNTIME)
|
||||
@Target({TYPE, METHOD})
|
||||
@Repeatable(SqlGroup.class)
|
||||
public @interface Sql {
|
||||
|
||||
@@ -88,7 +87,6 @@ public @interface Sql {
|
||||
* {@link #value}, but it may be used instead of {@link #value}. Similarly,
|
||||
* this attribute may be used in conjunction with or instead of
|
||||
* {@link #statements}.
|
||||
*
|
||||
* <h3>Path Resource Semantics</h3>
|
||||
* <p>Each path will be interpreted as a Spring
|
||||
* {@link org.springframework.core.io.Resource Resource}. A plain path
|
||||
@@ -101,7 +99,6 @@ public @interface Sql {
|
||||
* {@link org.springframework.util.ResourceUtils#CLASSPATH_URL_PREFIX classpath:},
|
||||
* {@link org.springframework.util.ResourceUtils#FILE_URL_PREFIX file:},
|
||||
* {@code http:}, etc.) will be loaded using the specified resource protocol.
|
||||
*
|
||||
* <h3>Default Script Detection</h3>
|
||||
* <p>If no SQL scripts or {@link #statements} are specified, an attempt will
|
||||
* be made to detect a <em>default</em> script depending on where this
|
||||
@@ -116,7 +113,6 @@ public @interface Sql {
|
||||
* {@code com.example.MyTest}, the corresponding default script is
|
||||
* {@code "classpath:com/example/MyTest.testMethod.sql"}.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see #value
|
||||
* @see #statements
|
||||
*/
|
||||
@@ -127,13 +123,11 @@ public @interface Sql {
|
||||
* <em>Inlined SQL statements</em> to execute.
|
||||
* <p>This attribute may be used in conjunction with or instead of
|
||||
* {@link #scripts}.
|
||||
*
|
||||
* <h3>Ordering</h3>
|
||||
* <p>Statements declared via this attribute will be executed after
|
||||
* statements loaded from resource {@link #scripts}. If you wish to have
|
||||
* inlined statements executed before scripts, simply declare multiple
|
||||
* instances of {@code @Sql} on the same class or method.
|
||||
*
|
||||
* @since 4.2
|
||||
* @see #scripts
|
||||
*/
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package org.springframework.test.context.jdbc;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* {@code @SqlConfig} defines metadata that is used to determine how to parse
|
||||
* and execute SQL scripts configured via the {@link Sql @Sql} annotation.
|
||||
@@ -59,10 +58,10 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @since 4.1
|
||||
* @see Sql
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RUNTIME)
|
||||
@Target(TYPE)
|
||||
public @interface SqlConfig {
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package org.springframework.test.context.jdbc;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* Container annotation that aggregates several {@link Sql @Sql} annotations.
|
||||
*
|
||||
@@ -39,10 +38,10 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @since 4.1
|
||||
* @see Sql
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RUNTIME)
|
||||
@Target({TYPE, METHOD})
|
||||
public @interface SqlGroup {
|
||||
|
||||
Sql[] value();
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.test.context.transaction;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* <p>Test annotation to indicate that the annotated {@code void} method
|
||||
* should be executed <em>after</em> a transaction is ended for a test method
|
||||
@@ -39,8 +38,8 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @see org.springframework.transaction.annotation.Transactional
|
||||
* @see BeforeTransaction
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target({ METHOD, ANNOTATION_TYPE })
|
||||
public @interface AfterTransaction {
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.test.context.transaction;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* <p>Test annotation to indicate that the annotated {@code void} method
|
||||
* should be executed <em>before</em> a transaction is started for a test method
|
||||
@@ -39,8 +38,8 @@ import static java.lang.annotation.RetentionPolicy.*;
|
||||
* @see org.springframework.transaction.annotation.Transactional
|
||||
* @see AfterTransaction
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target({ METHOD, ANNOTATION_TYPE })
|
||||
public @interface BeforeTransaction {
|
||||
}
|
||||
|
||||
@@ -47,19 +47,17 @@ import java.lang.annotation.Target;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see ServletTestExecutionListener
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface WebAppConfiguration {
|
||||
|
||||
/**
|
||||
* The resource path to the root directory of the web application.
|
||||
*
|
||||
* <p>A path that does not include a Spring resource prefix (e.g., {@code classpath:},
|
||||
* {@code file:}, etc.) will be interpreted as a file system resource, and a
|
||||
* path should not end with a slash.
|
||||
*
|
||||
* <p>Defaults to {@code "src/main/webapp"} as a file system resource. Note
|
||||
* that this is the standard directory for the root of a web application in
|
||||
* a project that follows the standard Maven project layout for a WAR.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -196,10 +196,10 @@ public abstract class MetaAnnotationUtils {
|
||||
for (Annotation composedAnnotation : clazz.getDeclaredAnnotations()) {
|
||||
if (!AnnotationUtils.isInJavaLangAnnotationPackage(composedAnnotation) && visited.add(composedAnnotation)) {
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
|
||||
composedAnnotation.annotationType(), visited, annotationTypes);
|
||||
composedAnnotation.annotationType(), visited, annotationTypes);
|
||||
if (descriptor != null) {
|
||||
return new UntypedAnnotationDescriptor(clazz, descriptor.getDeclaringClass(), composedAnnotation,
|
||||
descriptor.getAnnotation());
|
||||
descriptor.getAnnotation());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,13 +274,13 @@ public abstract class MetaAnnotationUtils {
|
||||
|
||||
private final AnnotationAttributes annotationAttributes;
|
||||
|
||||
|
||||
public AnnotationDescriptor(Class<?> rootDeclaringClass, T annotation) {
|
||||
this(rootDeclaringClass, rootDeclaringClass, null, annotation);
|
||||
}
|
||||
|
||||
public AnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass,
|
||||
Annotation composedAnnotation, T annotation) {
|
||||
|
||||
Assert.notNull(rootDeclaringClass, "rootDeclaringClass must not be null");
|
||||
Assert.notNull(annotation, "annotation must not be null");
|
||||
this.rootDeclaringClass = rootDeclaringClass;
|
||||
@@ -362,6 +362,7 @@ public abstract class MetaAnnotationUtils {
|
||||
|
||||
public UntypedAnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass,
|
||||
Annotation composedAnnotation, Annotation annotation) {
|
||||
|
||||
super(rootDeclaringClass, declaringClass, composedAnnotation, annotation);
|
||||
}
|
||||
|
||||
@@ -374,7 +375,7 @@ public abstract class MetaAnnotationUtils {
|
||||
@Override
|
||||
public Annotation synthesizeAnnotation() {
|
||||
throw new UnsupportedOperationException(
|
||||
"getMergedAnnotation() is unsupported in UntypedAnnotationDescriptor");
|
||||
"getMergedAnnotation() is unsupported in UntypedAnnotationDescriptor");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user