From 0b2592a70a040aae65bfc5277c894133c1f0684e Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 29 Sep 2011 22:01:38 +0000 Subject: [PATCH] [SPR-8240] polishing --- spring-framework-reference/src/testing.xml | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/spring-framework-reference/src/testing.xml b/spring-framework-reference/src/testing.xml index 29ee349362..73b2489ed4 100644 --- a/spring-framework-reference/src/testing.xml +++ b/spring-framework-reference/src/testing.xml @@ -1062,16 +1062,13 @@ public void testProcessRepeatedly() { Context management and caching Each TestContext provides context - management and caching support for the test instance for which it is - responsible. Test instances do not automatically receive access to the + management and caching support for the test instance it is responsible + for. Test instances do not automatically receive access to the configured ApplicationContext. However, if a test class implements the ApplicationContextAware interface, a reference to the ApplicationContext is supplied - to the test instance. Note that dependency injection support is - provided by the - DependencyInjectionTestExecutionListener which - is configured by default. In addition, + to the test instance. Note that AbstractJUnit4SpringContextTests and AbstractTestNGSpringContextTests implement ApplicationContextAware and therefore @@ -1096,6 +1093,11 @@ public class MyTest { // class body... } + + Note that support for dependency injection via + @Autowired is provided by the + DependencyInjectionTestExecutionListener + which is configured by default. In contrast to the deprecated JUnit 3.8 legacy class hierarchy, @@ -1189,11 +1191,11 @@ public class MyTest { To load an ApplicationContext for your tests from @Configuration - classes, annotate your test class with - @ContextConfiguration and configure - the classes attribute with an array that contains - class references to configuration classes. Alternatively, you can - implement and configure your own custom + classes (see ), annotate your test + class with @ContextConfiguration and + configure the classes attribute with an array + that contains class references to configuration classes. + Alternatively, you can implement and configure your own custom ContextLoader or SmartContextLoader for advanced use cases. @@ -1212,10 +1214,9 @@ public class MyTest { AnnotationConfigContextLoader will detect all static inner classes of the annotated test class that meet the requirements for configuration class implementations as specified in - the Javadoc for @Configuration (see - for further details). In the following - example, the OrderServiceTest class declares - a static inner configuration class named + the Javadoc for @Configuration. In + the following example, the OrderServiceTest + class declares a static inner configuration class named Config that will be automatically used to load the ApplicationContext for the test class. Note that the name of the configuration class is @@ -1362,7 +1363,7 @@ public class ExtendedTest extends BaseTest { setter injection, field injection, or both, depending on which annotations you choose and whether you place them on setter methods or fields. For consistency with the annotation support introduced in - Spring 3.0, you can use Spring's + Spring 2.5 and 3.0, you can use Spring's @Autowired annotation or the @Inject annotation from JSR 300.