Update documentation regarding nested test class support

Closes gh-28579
This commit is contained in:
Sam Brannen
2022-06-08 09:40:43 +02:00
parent be1b7da12f
commit 479ef3f3fd
23 changed files with 176 additions and 127 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -34,8 +34,8 @@ import java.lang.annotation.Target;
* *
* <p>When declared as a class-level annotation, {@code @Commit} defines * <p>When declared as a class-level annotation, {@code @Commit} defines
* the default commit semantics for all test methods within the test class * the default commit semantics for all test methods within the test class
* hierarchy. When declared as a method-level annotation, {@code @Commit} * hierarchy or nested class hierarchy. When declared as a method-level annotation,
* defines commit semantics for the specific test method, potentially * {@code @Commit} defines commit semantics for the specific test method, potentially
* overriding class-level default commit or rollback semantics. * overriding class-level default commit or rollback semantics.
* *
* <p><strong>Warning</strong>: {@code @Commit} can be used as direct * <p><strong>Warning</strong>: {@code @Commit} can be used as direct

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -34,9 +34,9 @@ import java.lang.annotation.Target;
* *
* <p>When declared as a class-level annotation, {@code @Rollback} defines * <p>When declared as a class-level annotation, {@code @Rollback} defines
* the default rollback semantics for all test methods within the test class * the default rollback semantics for all test methods within the test class
* hierarchy. When declared as a method-level annotation, {@code @Rollback} * hierarchy or nested class hierarchy. When declared as a method-level annotation,
* defines rollback semantics for the specific test method, potentially * {@code @Rollback} defines rollback semantics for the specific test method,
* overriding class-level default commit or rollback semantics. * potentially overriding class-level default commit or rollback semantics.
* *
* <p>As of Spring Framework 4.2, {@code @Commit} can be used as direct * <p>As of Spring Framework 4.2, {@code @Commit} can be used as direct
* replacement for {@code @Rollback(false)}. * replacement for {@code @Rollback(false)}.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 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.
@@ -78,17 +78,17 @@ public @interface ActiveProfiles {
Class<? extends ActiveProfilesResolver> resolver() default ActiveProfilesResolver.class; Class<? extends ActiveProfilesResolver> resolver() default ActiveProfilesResolver.class;
/** /**
* Whether or not bean definition profiles from superclasses should be * Whether or not bean definition profiles from superclasses and enclosing
* <em>inherited</em>. * classes should be <em>inherited</em>.
* <p>The default value is {@code true}, which means that a test * <p>The default value is {@code true}, which means that a test class will
* class will <em>inherit</em> bean definition profiles defined by a * <em>inherit</em> bean definition profiles defined by a test superclass or
* test superclass. Specifically, the bean definition profiles for a test * enclosing class. Specifically, the bean definition profiles for a test
* class will be appended to the list of bean definition profiles * class will be appended to the list of bean definition profiles defined by
* defined by a test superclass. Thus, subclasses have the option of * a test superclass or enclosing class. Thus, subclasses and nested classes
* <em>extending</em> the list of bean definition profiles. * have the option of <em>extending</em> the list of bean definition profiles.
* <p>If {@code inheritProfiles} is set to {@code false}, the bean * <p>If {@code inheritProfiles} is set to {@code false}, the bean definition
* definition profiles for the test class will <em>shadow</em> and * profiles for the test class will <em>shadow</em> and effectively replace
* effectively replace any bean definition profiles defined by a superclass. * any bean definition profiles defined by a superclass or enclosing class.
* <p>In the following example, the {@code ApplicationContext} for * <p>In the following example, the {@code ApplicationContext} for
* {@code BaseTest} will be loaded using only the &quot;base&quot; * {@code BaseTest} will be loaded using only the &quot;base&quot;
* bean definition profile; beans defined in the &quot;extended&quot; profile * bean definition profile; beans defined in the &quot;extended&quot; profile

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -171,18 +171,19 @@ public @interface ContextConfiguration {
/** /**
* Whether or not {@linkplain #locations resource locations} or * Whether or not {@linkplain #locations resource locations} or
* {@linkplain #classes <em>component classes</em>} from test superclasses * {@linkplain #classes <em>component classes</em>} from test superclasses
* should be <em>inherited</em>. * and enclosing classes should be <em>inherited</em>.
* <p>The default value is {@code true}. This means that an annotated test * <p>The default value is {@code true}. This means that an annotated test
* class will <em>inherit</em> the resource locations or component classes * class will <em>inherit</em> the resource locations or component classes
* defined by test superclasses. Specifically, the resource locations or * defined by test superclasses and enclosing classes. Specifically, the
* component classes for a given test class will be appended to the list of * resource locations or component classes for a given test class will be
* resource locations or component classes defined by test superclasses. * appended to the list of resource locations or component classes defined
* Thus, subclasses have the option of <em>extending</em> the list of resource * by test superclasses and enclosing classes. Thus, subclasses and nested
* classes have the option of <em>extending</em> the list of resource
* locations or component classes. * locations or component classes.
* <p>If {@code inheritLocations} is set to {@code false}, the * <p>If {@code inheritLocations} is set to {@code false}, the
* resource locations or component classes for the annotated test class * resource locations or component classes for the annotated test class
* will <em>shadow</em> and effectively replace any resource locations * will <em>shadow</em> and effectively replace any resource locations
* or component classes defined by superclasses. * or component classes defined by superclasses and enclosing classes.
* <p>In the following example that uses path-based resource locations, the * <p>In the following example that uses path-based resource locations, the
* {@link org.springframework.context.ApplicationContext ApplicationContext} * {@link org.springframework.context.ApplicationContext ApplicationContext}
* for {@code ExtendedTest} will be loaded from * for {@code ExtendedTest} will be loaded from
@@ -225,16 +226,16 @@ public @interface ContextConfiguration {
/** /**
* Whether or not {@linkplain #initializers context initializers} from test * Whether or not {@linkplain #initializers context initializers} from test
* superclasses should be <em>inherited</em>. * superclasses and enclosing classes should be <em>inherited</em>.
* <p>The default value is {@code true}. This means that an annotated test * <p>The default value is {@code true}. This means that an annotated test
* class will <em>inherit</em> the application context initializers defined * class will <em>inherit</em> the application context initializers defined
* by test superclasses. Specifically, the initializers for a given test * by test superclasses and enclosing classes. Specifically, the initializers
* class will be added to the set of initializers defined by test * for a given test class will be added to the set of initializers defined by
* superclasses. Thus, subclasses have the option of <em>extending</em> the * test superclasses and enclosing classes. Thus, subclasses and nested classes
* set of initializers. * have the option of <em>extending</em> the set of initializers.
* <p>If {@code inheritInitializers} is set to {@code false}, the initializers * <p>If {@code inheritInitializers} is set to {@code false}, the initializers
* for the annotated test class will <em>shadow</em> and effectively replace * for the annotated test class will <em>shadow</em> and effectively replace
* any initializers defined by superclasses. * any initializers defined by superclasses and enclosing classes.
* <p>In the following example, the * <p>In the following example, the
* {@link org.springframework.context.ApplicationContext ApplicationContext} * {@link org.springframework.context.ApplicationContext ApplicationContext}
* for {@code ExtendedTest} will be initialized using * for {@code ExtendedTest} will be initialized using
@@ -263,9 +264,10 @@ public @interface ContextConfiguration {
* for loading an {@link org.springframework.context.ApplicationContext * for loading an {@link org.springframework.context.ApplicationContext
* ApplicationContext}. * ApplicationContext}.
* <p>If not specified, the loader will be inherited from the first superclass * <p>If not specified, the loader will be inherited from the first superclass
* that is annotated or meta-annotated with {@code @ContextConfiguration} and * or enclosing class that is annotated or meta-annotated with
* specifies an explicit loader. If no class in the hierarchy specifies an * {@code @ContextConfiguration} and specifies an explicit loader. If no class
* explicit loader, a default loader will be used instead. * in the type hierarchy or enclosing class hierarchy specifies an explicit
* loader, a default loader will be used instead.
* <p>The default concrete implementation chosen at runtime will be either * <p>The default concrete implementation chosen at runtime will be either
* {@link org.springframework.test.context.support.DelegatingSmartContextLoader * {@link org.springframework.test.context.support.DelegatingSmartContextLoader
* DelegatingSmartContextLoader} or * DelegatingSmartContextLoader} or
@@ -290,10 +292,12 @@ public @interface ContextConfiguration {
* <p>If not specified the name will be inferred based on the numerical level * <p>If not specified the name will be inferred based on the numerical level
* within all declared contexts within the hierarchy. * within all declared contexts within the hierarchy.
* <p>This attribute is only applicable when used within a test class hierarchy * <p>This attribute is only applicable when used within a test class hierarchy
* that is configured using {@code @ContextHierarchy}, in which case the name * or enclosing class hierarchy that is configured using
* can be used for <em>merging</em> or <em>overriding</em> this configuration * {@code @ContextHierarchy}, in which case the name can be used for
* with configuration of the same name in hierarchy levels defined in superclasses. * <em>merging</em> or <em>overriding</em> this configuration with configuration
* See the Javadoc for {@link ContextHierarchy @ContextHierarchy} for details. * of the same name in hierarchy levels defined in superclasses or enclosing
* classes. See the Javadoc for {@link ContextHierarchy @ContextHierarchy} for
* details.
* @since 3.2.2 * @since 3.2.2
*/ */
String name() default ""; String name() default "";

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2022 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.
@@ -46,7 +46,7 @@ public interface ContextCustomizerFactory {
* @param testClass the test class * @param testClass the test class
* @param configAttributes the list of context configuration attributes for * @param configAttributes the list of context configuration attributes for
* the test class, ordered <em>bottom-up</em> (i.e., as if we were traversing * the test class, ordered <em>bottom-up</em> (i.e., as if we were traversing
* up the class hierarchy); never {@code null} or empty * up the class hierarchy or enclosing class hierarchy); never {@code null} or empty
* @return a {@link ContextCustomizer} or {@code null} if no customizer should * @return a {@link ContextCustomizer} or {@code null} if no customizer should
* be used * be used
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.
@@ -31,16 +31,16 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* {@code MergedContextConfiguration} encapsulates the <em>merged</em> * {@code MergedContextConfiguration} encapsulates the <em>merged</em> context
* context configuration declared on a test class and all of its superclasses * configuration declared on a test class and all of its superclasses and
* via {@link ContextConfiguration @ContextConfiguration}, * enclosing classes via {@link ContextConfiguration @ContextConfiguration},
* {@link ActiveProfiles @ActiveProfiles}, and * {@link ActiveProfiles @ActiveProfiles}, and
* {@link TestPropertySource @TestPropertySource}. * {@link TestPropertySource @TestPropertySource}.
* *
* <p>Merged context resource locations, annotated classes, active profiles, * <p>Merged context resource locations, annotated classes, active profiles,
* property resource locations, and in-lined properties represent all declared * property resource locations, and in-lined properties represent all declared
* values in the test class hierarchy taking into consideration the semantics * values in the test class hierarchy and enclosing class hierarchy taking into
* of the {@link ContextConfiguration#inheritLocations}, * consideration the semantics of the {@link ContextConfiguration#inheritLocations},
* {@link ActiveProfiles#inheritProfiles}, * {@link ActiveProfiles#inheritProfiles},
* {@link TestPropertySource#inheritLocations}, and * {@link TestPropertySource#inheritLocations}, and
* {@link TestPropertySource#inheritProperties} flags. * {@link TestPropertySource#inheritProperties} flags.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2022 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.
@@ -126,7 +126,8 @@ public interface TestContextBootstrapper {
* flag of {@link TestExecutionListeners @TestExecutionListeners} must be * flag of {@link TestExecutionListeners @TestExecutionListeners} must be
* taken into consideration. Specifically, if the {@code inheritListeners} * taken into consideration. Specifically, if the {@code inheritListeners}
* flag is set to {@code true}, listeners declared for a given test class must * flag is set to {@code true}, listeners declared for a given test class must
* be appended to the end of the list of listeners declared in superclasses. * be appended to the end of the list of listeners declared in superclasses
* or enclosing classes.
* @return a list of {@code TestExecutionListener} instances * @return a list of {@code TestExecutionListener} instances
*/ */
List<TestExecutionListener> getTestExecutionListeners(); List<TestExecutionListener> getTestExecutionListeners();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -79,15 +79,16 @@ public @interface TestExecutionListeners {
/** /**
* Whether or not {@link #listeners TestExecutionListeners} from superclasses * Whether or not {@link #listeners TestExecutionListeners} from superclasses
* should be <em>inherited</em>. * and enclosing classes should be <em>inherited</em>.
* <p>The default value is {@code true}, which means that an annotated * <p>The default value is {@code true}, which means that an annotated class
* class will <em>inherit</em> the listeners defined by an annotated * will <em>inherit</em> the listeners defined by an annotated superclass or
* superclass. Specifically, the listeners for an annotated class will be * enclosing class. Specifically, the listeners for an annotated class will be
* appended to the list of listeners defined by an annotated superclass. * appended to the list of listeners defined by an annotated superclass or
* Thus, subclasses have the option of <em>extending</em> the list of * enclosing class. Thus, subclasses and nested classes have the option of
* listeners. In the following example, {@code AbstractBaseTest} will * <em>extending</em> the list of listeners. In the following example,
* be configured with {@code DependencyInjectionTestExecutionListener} * {@code AbstractBaseTest} will be configured with
* and {@code DirtiesContextTestExecutionListener}; whereas, * {@code DependencyInjectionTestExecutionListener} and
* {@code DirtiesContextTestExecutionListener}; whereas,
* {@code TransactionalTest} will be configured with * {@code TransactionalTest} will be configured with
* {@code DependencyInjectionTestExecutionListener}, * {@code DependencyInjectionTestExecutionListener},
* {@code DirtiesContextTestExecutionListener}, <strong>and</strong> * {@code DirtiesContextTestExecutionListener}, <strong>and</strong>
@@ -107,18 +108,19 @@ public @interface TestExecutionListeners {
* }</pre> * }</pre>
* <p>If {@code inheritListeners} is set to {@code false}, the listeners for * <p>If {@code inheritListeners} is set to {@code false}, the listeners for
* the annotated class will <em>shadow</em> and effectively replace any * the annotated class will <em>shadow</em> and effectively replace any
* listeners defined by a superclass. * listeners defined by a superclass or enclosing class.
*/ */
boolean inheritListeners() default true; boolean inheritListeners() default true;
/** /**
* The <em>merge mode</em> to use when {@code @TestExecutionListeners} is * The <em>merge mode</em> to use when {@code @TestExecutionListeners} is
* declared on a class that does <strong>not</strong> inherit listeners * declared on a class that does <strong>not</strong> inherit listeners from
* from a superclass. * a superclass or enclosing class.
* <p>Can be set to {@link MergeMode#MERGE_WITH_DEFAULTS MERGE_WITH_DEFAULTS} * <p>Can be set to {@link MergeMode#MERGE_WITH_DEFAULTS MERGE_WITH_DEFAULTS}
* to have locally declared listeners <em>merged</em> with the default * to have locally declared listeners <em>merged</em> with the default
* listeners. * listeners.
* <p>The mode is ignored if listeners are inherited from a superclass. * <p>The mode is ignored if listeners are inherited from a superclass or
* enclosing class.
* <p>Defaults to {@link MergeMode#REPLACE_DEFAULTS REPLACE_DEFAULTS} * <p>Defaults to {@link MergeMode#REPLACE_DEFAULTS REPLACE_DEFAULTS}
* for backwards compatibility. * for backwards compatibility.
* @see MergeMode * @see MergeMode
@@ -131,7 +133,8 @@ public @interface TestExecutionListeners {
* Enumeration of <em>modes</em> that dictate whether or not explicitly * Enumeration of <em>modes</em> that dictate whether or not explicitly
* declared listeners are merged with the default listeners when * declared listeners are merged with the default listeners when
* {@code @TestExecutionListeners} is declared on a class that does * {@code @TestExecutionListeners} is declared on a class that does
* <strong>not</strong> inherit listeners from a superclass. * <strong>not</strong> inherit listeners from a superclass or enclosing
* class.
* @since 4.1 * @since 4.1
*/ */
enum MergeMode { enum MergeMode {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -151,16 +151,18 @@ public @interface TestPropertySource {
/** /**
* Whether or not test property source {@link #locations} from superclasses * Whether or not test property source {@link #locations} from superclasses
* should be <em>inherited</em>. * and enclosing classes should be <em>inherited</em>.
* <p>The default value is {@code true}, which means that a test class will * <p>The default value is {@code true}, which means that a test class will
* <em>inherit</em> property source locations defined by a superclass. * <em>inherit</em> property source locations defined by a superclass or
* Specifically, the property source locations for a test class will be * enclosing class. Specifically, the property source locations for a test
* appended to the list of property source locations defined by a superclass. * class will be appended to the list of property source locations defined
* Thus, subclasses have the option of <em>extending</em> the list of test * by a superclass or enclosing class. Thus, subclasses and nested classes
* property source locations. * have the option of <em>extending</em> the list of test property source
* locations.
* <p>If {@code inheritLocations} is set to {@code false}, the property * <p>If {@code inheritLocations} is set to {@code false}, the property
* source locations for the test class will <em>shadow</em> and effectively * source locations for the test class will <em>shadow</em> and effectively
* replace any property source locations defined by a superclass. * replace any property source locations defined by a superclass or
* enclosing class.
* <p>In the following example, the {@code ApplicationContext} for * <p>In the following example, the {@code ApplicationContext} for
* {@code BaseTest} will be loaded using only the {@code "base.properties"} * {@code BaseTest} will be loaded using only the {@code "base.properties"}
* file as a test property source. In contrast, the {@code ApplicationContext} * file as a test property source. In contrast, the {@code ApplicationContext}
@@ -228,16 +230,17 @@ public @interface TestPropertySource {
String[] properties() default {}; String[] properties() default {};
/** /**
* Whether or not inlined test {@link #properties} from superclasses should * Whether or not inlined test {@link #properties} from superclasses and
* be <em>inherited</em>. * enclosing classes should be <em>inherited</em>.
* <p>The default value is {@code true}, which means that a test class will * <p>The default value is {@code true}, which means that a test class will
* <em>inherit</em> inlined properties defined by a superclass. Specifically, * <em>inherit</em> inlined properties defined by a superclass or enclosing
* the inlined properties for a test class will be appended to the list of * class. Specifically, the inlined properties for a test class will be
* inlined properties defined by a superclass. Thus, subclasses have the * appended to the list of inlined properties defined by a superclass or
* option of <em>extending</em> the list of inlined test properties. * enclosing class. Thus, subclasses and nested classes have the option of
* <em>extending</em> the list of inlined test properties.
* <p>If {@code inheritProperties} is set to {@code false}, the inlined * <p>If {@code inheritProperties} is set to {@code false}, the inlined
* properties for the test class will <em>shadow</em> and effectively * properties for the test class will <em>shadow</em> and effectively
* replace any inlined properties defined by a superclass. * replace any inlined properties defined by a superclass or enclosing class.
* <p>In the following example, the {@code ApplicationContext} for * <p>In the following example, the {@code ApplicationContext} for
* {@code BaseTest} will be loaded using only the inlined {@code key1} * {@code BaseTest} will be loaded using only the inlined {@code key1}
* property. In contrast, the {@code ApplicationContext} for * property. In contrast, the {@code ApplicationContext} for
@@ -261,7 +264,7 @@ public @interface TestPropertySource {
* test class hierarchy (i.e., directly present or meta-present on a test * test class hierarchy (i.e., directly present or meta-present on a test
* class) are considered to be <em>local</em> annotations, in contrast to * class) are considered to be <em>local</em> annotations, in contrast to
* {@code @TestPropertySource} annotations that are inherited from a * {@code @TestPropertySource} annotations that are inherited from a
* superclass.</li> * superclass or enclosing class.</li>
* <li>All local {@code @TestPropertySource} annotations must declare the * <li>All local {@code @TestPropertySource} annotations must declare the
* same value for the {@code inheritProperties} flag.</li> * same value for the {@code inheritProperties} flag.</li>
* <li>The {@code inheritProperties} flag is not taken into account between * <li>The {@code inheritProperties} flag is not taken into account between

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -36,6 +36,10 @@ import java.lang.annotation.Target;
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom * <p>This annotation may be used as a <em>meta-annotation</em> to create custom
* <em>composed annotations</em>. * <em>composed annotations</em>.
* *
* <p>This annotation will be inherited from an enclosing test class by default. See
* {@link org.springframework.test.context.NestedTestConfiguration @NestedTestConfiguration}
* for details.
*
* @author Sam Brannen * @author Sam Brannen
* @since 5.3.3 * @since 5.3.3
* @see ApplicationEvents * @see ApplicationEvents

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 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.
@@ -53,6 +53,11 @@ import org.springframework.core.annotation.AliasFor;
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom * <p>This annotation may be used as a <em>meta-annotation</em> to create custom
* <em>composed annotations</em> with attribute overrides. * <em>composed annotations</em> with attribute overrides.
* *
* <p>As of Spring Framework 5.3, this annotation will be inherited from an
* enclosing test class by default. See
* {@link org.springframework.test.context.NestedTestConfiguration @NestedTestConfiguration}
* for details.
*
* @author Sam Brannen * @author Sam Brannen
* @since 4.1 * @since 4.1
* @see SqlConfig * @see SqlConfig

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2022 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.
@@ -54,6 +54,11 @@ import java.lang.annotation.Target;
* {@code ""}, <code>{}</code>, or {@code DEFAULT}. Explicit local configuration * {@code ""}, <code>{}</code>, or {@code DEFAULT}. Explicit local configuration
* therefore <em>overrides</em> global configuration. * therefore <em>overrides</em> global configuration.
* *
* <p>As of Spring Framework 5.3, this annotation will be inherited from an
* enclosing test class by default. See
* {@link org.springframework.test.context.NestedTestConfiguration @NestedTestConfiguration}
* for details.
*
* @author Sam Brannen * @author Sam Brannen
* @author Tadaya Tsuyukubo * @author Tadaya Tsuyukubo
* @since 4.1 * @since 4.1

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2022 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.
@@ -34,6 +34,11 @@ import java.lang.annotation.Target;
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom * <p>This annotation may be used as a <em>meta-annotation</em> to create custom
* <em>composed annotations</em>. * <em>composed annotations</em>.
* *
* <p>As of Spring Framework 5.3, this annotation will be inherited from an
* enclosing test class by default. See
* {@link org.springframework.test.context.NestedTestConfiguration @NestedTestConfiguration}
* for details.
*
* @author Sam Brannen * @author Sam Brannen
* @since 4.1 * @since 4.1
* @see Sql * @see Sql

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 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.
@@ -37,6 +37,11 @@ import java.lang.annotation.Target;
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom * <p>This annotation may be used as a <em>meta-annotation</em> to create custom
* <em>composed annotations</em> with attribute overrides. * <em>composed annotations</em> with attribute overrides.
* *
* <p>As of Spring Framework 5.3, this annotation will be inherited from an
* enclosing test class by default. See
* {@link org.springframework.test.context.NestedTestConfiguration @NestedTestConfiguration}
* for details.
*
* @author Sam Brannen * @author Sam Brannen
* @author Dmitry Semukhin * @author Dmitry Semukhin
* @since 5.2 * @since 5.2

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2022 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.
@@ -35,6 +35,11 @@ import org.springframework.test.context.ContextConfiguration;
* {@link ContextConfiguration @ContextConfiguration} from the <em>Spring TestContext * {@link ContextConfiguration @ContextConfiguration} from the <em>Spring TestContext
* Framework</em>. * Framework</em>.
* *
* <p>As of Spring Framework 5.3, this annotation will effectively be inherited
* from an enclosing test class by default. See
* {@link org.springframework.test.context.NestedTestConfiguration @NestedTestConfiguration}
* for details.
*
* @author Sam Brannen * @author Sam Brannen
* @since 5.0 * @since 5.0
* @see ExtendWith * @see ExtendWith

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2022 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.
@@ -38,6 +38,11 @@ import org.springframework.test.context.web.WebAppConfiguration;
* {@link WebAppConfiguration @WebAppConfiguration} from the <em>Spring TestContext * {@link WebAppConfiguration @WebAppConfiguration} from the <em>Spring TestContext
* Framework</em>. * Framework</em>.
* *
* <p>As of Spring Framework 5.3, this annotation will effectively be inherited
* from an enclosing test class by default. See
* {@link org.springframework.test.context.NestedTestConfiguration @NestedTestConfiguration}
* for details.
*
* @author Sam Brannen * @author Sam Brannen
* @since 5.0 * @since 5.0
* @see ExtendWith * @see ExtendWith

View File

@@ -37,9 +37,10 @@ import org.springframework.util.Assert;
* configuration. Each candidate is given a chance to * configuration. Each candidate is given a chance to
* {@linkplain #processContextConfiguration process} the * {@linkplain #processContextConfiguration process} the
* {@link ContextConfigurationAttributes} for each class in the test class hierarchy * {@link ContextConfigurationAttributes} for each class in the test class hierarchy
* that is annotated with {@link ContextConfiguration @ContextConfiguration}, and * and enclosing class hierarchy that is annotated with
* the candidate that supports the merged, processed configuration will be used to * {@link ContextConfiguration @ContextConfiguration}, and the candidate that
* actually {@linkplain #loadContext load} the context. * supports the merged, processed configuration will be used to actually
* {@linkplain #loadContext load} the context.
* *
* <p>Any reference to an <em>XML-based loader</em> can be interpreted to mean * <p>Any reference to an <em>XML-based loader</em> can be interpreted to mean
* a context loader that supports only XML configuration files or one that * a context loader that supports only XML configuration files or one that

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -318,7 +318,8 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
* should be built (must not be {@code null}) * should be built (must not be {@code null})
* @param configAttributesList the list of context configuration attributes for the * @param configAttributesList the list of context configuration attributes for the
* specified test class, ordered <em>bottom-up</em> (i.e., as if we were * specified test class, ordered <em>bottom-up</em> (i.e., as if we were
* traversing up the class hierarchy); never {@code null} or empty * traversing up the class hierarchy and enclosing class hierarchy); never
* {@code null} or empty
* @param parentConfig the merged context configuration for the parent application * @param parentConfig the merged context configuration for the parent application
* context in a context hierarchy, or {@code null} if there is no parent * context in a context hierarchy, or {@code null} if there is no parent
* @param cacheAwareContextLoaderDelegate the cache-aware context loader delegate to * @param cacheAwareContextLoaderDelegate the cache-aware context loader delegate to
@@ -431,7 +432,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
* resolved; must not be {@code null} * resolved; must not be {@code null}
* @param configAttributesList the list of configuration attributes to process; must * @param configAttributesList the list of configuration attributes to process; must
* not be {@code null}; must be ordered <em>bottom-up</em> * not be {@code null}; must be ordered <em>bottom-up</em>
* (i.e., as if we were traversing up the class hierarchy) * (i.e., as if we were traversing up the class hierarchy and enclosing class hierarchy)
* @return the resolved {@code ContextLoader} for the supplied {@code testClass} * @return the resolved {@code ContextLoader} for the supplied {@code testClass}
* (never {@code null}) * (never {@code null})
* @throws IllegalStateException if {@link #getDefaultContextLoaderClass(Class)} * @throws IllegalStateException if {@link #getDefaultContextLoaderClass(Class)}
@@ -468,7 +469,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
* </ol> * </ol>
* @param configAttributesList the list of configuration attributes to process; * @param configAttributesList the list of configuration attributes to process;
* must not be {@code null}; must be ordered <em>bottom-up</em> * must not be {@code null}; must be ordered <em>bottom-up</em>
* (i.e., as if we were traversing up the class hierarchy) * (i.e., as if we were traversing up the class hierarchy and enclosing class hierarchy)
* @return the {@code ContextLoader} class to use for the supplied configuration * @return the {@code ContextLoader} class to use for the supplied configuration
* attributes, or {@code null} if no explicit loader is found * attributes, or {@code null} if no explicit loader is found
* @throws IllegalArgumentException if supplied configuration attributes are * @throws IllegalArgumentException if supplied configuration attributes are

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -60,11 +60,12 @@ abstract class ActiveProfilesUtils {
* <p>Note that the {@link ActiveProfiles#inheritProfiles inheritProfiles} flag of * <p>Note that the {@link ActiveProfiles#inheritProfiles inheritProfiles} flag of
* {@link ActiveProfiles @ActiveProfiles} will be taken into consideration. * {@link ActiveProfiles @ActiveProfiles} will be taken into consideration.
* Specifically, if the {@code inheritProfiles} flag is set to {@code true}, profiles * Specifically, if the {@code inheritProfiles} flag is set to {@code true}, profiles
* defined in the test class will be merged with those defined in superclasses. * defined in the test class will be merged with those defined in superclasses
* and enclosing classes.
* @param testClass the class for which to resolve the active profiles (must not be * @param testClass the class for which to resolve the active profiles (must not be
* {@code null}) * {@code null})
* @return the set of active profiles for the specified class, including active * @return the set of active profiles for the specified class, including active
* profiles from superclasses if appropriate (never {@code null}) * profiles from superclasses and enclosing classes if appropriate (never {@code null})
* @see ActiveProfiles * @see ActiveProfiles
* @see ActiveProfilesResolver * @see ActiveProfilesResolver
* @see org.springframework.context.annotation.Profile * @see org.springframework.context.annotation.Profile

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2022 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.
@@ -52,12 +52,13 @@ abstract class ApplicationContextInitializerUtils {
* <p>Note that the {@link ContextConfiguration#inheritInitializers inheritInitializers} * <p>Note that the {@link ContextConfiguration#inheritInitializers inheritInitializers}
* flag of {@link ContextConfiguration @ContextConfiguration} will be taken into * flag of {@link ContextConfiguration @ContextConfiguration} will be taken into
* consideration. Specifically, if the {@code inheritInitializers} flag is set to * consideration. Specifically, if the {@code inheritInitializers} flag is set to
* {@code true} for a given level in the class hierarchy represented by the provided * {@code true} for a given level in the class hierarchy and enclosing class
* configuration attributes, context initializer classes defined at the given level * hierarchy represented by the provided configuration attributes, context
* will be merged with those defined in higher levels of the class hierarchy. * initializer classes defined at the given level will be merged with those
* defined in higher levels of the class hierarchy or enclosing class hierarchy.
* @param configAttributesList the list of configuration attributes to process; must * @param configAttributesList the list of configuration attributes to process; must
* not be {@code null} or <em>empty</em>; must be ordered <em>bottom-up</em> * not be {@code null} or <em>empty</em>; must be ordered <em>bottom-up</em>
* (i.e., as if we were traversing up the class hierarchy) * (i.e., as if we were traversing up the class hierarchy or enclosing class hierarchy)
* @return the set of merged context initializer classes, including those from * @return the set of merged context initializer classes, including those from
* superclasses if appropriate (never {@code null}) * superclasses if appropriate (never {@code null})
* @since 3.2 * @since 3.2

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@@ -63,17 +63,17 @@ abstract class ContextLoaderUtils {
/** /**
* Resolve the list of lists of {@linkplain ContextConfigurationAttributes context * Resolve the list of lists of {@linkplain ContextConfigurationAttributes context
* configuration attributes} for the supplied {@linkplain Class test class} and its * configuration attributes} for the supplied {@linkplain Class test class} and its
* superclasses, taking into account context hierarchies declared via * superclasses and enclosing classes, taking into account context hierarchies
* {@link ContextHierarchy @ContextHierarchy} and * declared via {@link ContextHierarchy @ContextHierarchy} and
* {@link ContextConfiguration @ContextConfiguration}. * {@link ContextConfiguration @ContextConfiguration}.
* <p>The outer list represents a top-down ordering of context configuration * <p>The outer list represents a top-down ordering of context configuration
* attributes, where each element in the list represents the context configuration * attributes, where each element in the list represents the context configuration
* declared on a given test class in the class hierarchy. Each nested list * declared on a given test class in the class hierarchy or enclosing class
* contains the context configuration attributes declared either via a single * hierarchy. Each nested list contains the context configuration attributes
* instance of {@code @ContextConfiguration} on the particular class or via * declared either via a single instance of {@code @ContextConfiguration} on
* multiple instances of {@code @ContextConfiguration} declared within a * the particular class or via multiple instances of {@code @ContextConfiguration}
* single {@code @ContextHierarchy} instance on the particular class. * declared within a single {@code @ContextHierarchy} instance on the particular
* Furthermore, each nested list maintains the order in which * class. Furthermore, each nested list maintains the order in which
* {@code @ContextConfiguration} instances are declared. * {@code @ContextConfiguration} instances are declared.
* <p>Note that the {@link ContextConfiguration#inheritLocations inheritLocations} and * <p>Note that the {@link ContextConfiguration#inheritLocations inheritLocations} and
* {@link ContextConfiguration#inheritInitializers() inheritInitializers} flags of * {@link ContextConfiguration#inheritInitializers() inheritInitializers} flags of
@@ -157,14 +157,14 @@ abstract class ContextLoaderUtils {
/** /**
* Build a <em>context hierarchy map</em> for the supplied {@linkplain Class * Build a <em>context hierarchy map</em> for the supplied {@linkplain Class
* test class} and its superclasses, taking into account context hierarchies * test class} and its superclasses and enclosing classes, taking into account
* declared via {@link ContextHierarchy @ContextHierarchy} and * context hierarchies declared via {@link ContextHierarchy @ContextHierarchy}
* {@link ContextConfiguration @ContextConfiguration}. * and {@link ContextConfiguration @ContextConfiguration}.
* <p>Each value in the map represents the consolidated list of {@linkplain * <p>Each value in the map represents the consolidated list of {@linkplain
* ContextConfigurationAttributes context configuration attributes} for a * ContextConfigurationAttributes context configuration attributes} for a
* given level in the context hierarchy (potentially across the test class * given level in the context hierarchy (potentially across the test class
* hierarchy), keyed by the {@link ContextConfiguration#name() name} of the * hierarchy and enclosing class hierarchy), keyed by the
* context hierarchy level. * {@link ContextConfiguration#name() name} of the context hierarchy level.
* <p>If a given level in the context hierarchy does not have an explicit * <p>If a given level in the context hierarchy does not have an explicit
* name (i.e., configured via {@link ContextConfiguration#name}), a name will * name (i.e., configured via {@link ContextConfiguration#name}), a name will
* be generated for that hierarchy level by appending the numerical level to * be generated for that hierarchy level by appending the numerical level to
@@ -217,8 +217,8 @@ abstract class ContextLoaderUtils {
/** /**
* Resolve the list of {@linkplain ContextConfigurationAttributes context * Resolve the list of {@linkplain ContextConfigurationAttributes context
* configuration attributes} for the supplied {@linkplain Class test class} and its * configuration attributes} for the supplied {@linkplain Class test class}
* superclasses. * and its superclasses and enclosing classes.
* <p>Note that the {@link ContextConfiguration#inheritLocations inheritLocations} and * <p>Note that the {@link ContextConfiguration#inheritLocations inheritLocations} and
* {@link ContextConfiguration#inheritInitializers() inheritInitializers} flags of * {@link ContextConfiguration#inheritInitializers() inheritInitializers} flags of
* {@link ContextConfiguration @ContextConfiguration} will <strong>not</strong> * {@link ContextConfiguration @ContextConfiguration} will <strong>not</strong>
@@ -227,8 +227,8 @@ abstract class ContextLoaderUtils {
* @param testClass the class for which to resolve the configuration attributes * @param testClass the class for which to resolve the configuration attributes
* (must not be {@code null}) * (must not be {@code null})
* @return the list of configuration attributes for the specified class, ordered * @return the list of configuration attributes for the specified class, ordered
* <em>bottom-up</em> (i.e., as if we were traversing up the class hierarchy); * <em>bottom-up</em> (i.e., as if we were traversing up the class hierarchy
* never {@code null} * and enclosing class hierarchy); never {@code null}
* @throws IllegalArgumentException if the supplied class is {@code null} or if * @throws IllegalArgumentException if the supplied class is {@code null} or if
* {@code @ContextConfiguration} is not <em>present</em> on the supplied class * {@code @ContextConfiguration} is not <em>present</em> on the supplied class
*/ */

View File

@@ -24,9 +24,9 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* {@code MergedTestPropertySources} encapsulates the <em>merged</em> * {@code MergedTestPropertySources} encapsulates the <em>merged</em> property
* property sources declared on a test class and all of its superclasses * sources declared on a test class and all of its superclasses and enclosing
* via {@link TestPropertySource @TestPropertySource}. * classes via {@link TestPropertySource @TestPropertySource}.
* *
* @author Sam Brannen * @author Sam Brannen
* @since 4.1 * @since 4.1

View File

@@ -73,10 +73,10 @@ import org.springframework.util.StringUtils;
* to be run within a transaction that will, by default, be automatically * to be run within a transaction that will, by default, be automatically
* <em>rolled back</em> after completion of the test. If a test class is * <em>rolled back</em> after completion of the test. If a test class is
* annotated with {@code @Transactional}, each test method within that class * annotated with {@code @Transactional}, each test method within that class
* hierarchy will be run within a transaction. Test methods that are * hierarchy or nested class hierarchy will be run within a transaction. Test
* <em>not</em> annotated with {@code @Transactional} (at the class or method * methods that are <em>not</em> annotated with {@code @Transactional} (at the
* level) will not be run within a transaction. Furthermore, tests that * class or method level) will not be run within a transaction. Furthermore,
* <em>are</em> annotated with {@code @Transactional} but have the * tests that <em>are</em> annotated with {@code @Transactional} but have the
* {@link Transactional#propagation propagation} type set to * {@link Transactional#propagation propagation} type set to
* {@link org.springframework.transaction.annotation.Propagation#NOT_SUPPORTED NOT_SUPPORTED} * {@link org.springframework.transaction.annotation.Propagation#NOT_SUPPORTED NOT_SUPPORTED}
* or {@link org.springframework.transaction.annotation.Propagation#NEVER NEVER} * or {@link org.springframework.transaction.annotation.Propagation#NEVER NEVER}