From e77e070e7a697752ab9181e74ead1beed5e4e6d3 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 6 Jul 2009 18:04:37 +0000 Subject: [PATCH] [SPR-4702] Reference manual updates --- spring-framework-reference/src/testing.xml | 39 +++++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/spring-framework-reference/src/testing.xml b/spring-framework-reference/src/testing.xml index f9be02e082..820737996b 100644 --- a/spring-framework-reference/src/testing.xml +++ b/spring-framework-reference/src/testing.xml @@ -409,7 +409,7 @@ Spring-specific annotations that you can use in your unit and integration tests in conjunction with the TestContext framework. Refer to the respective JavaDoc for further information, - including default attribute values, etc. + including default attribute values, attribute aliases, etc. @@ -419,10 +419,10 @@ Defines class-level metadata which is used to determine how to load and configure an ApplicationContext. Specifically, - @ContextConfiguration defines the application context resource - locations to load as well as the - ContextLoader strategy to use for - loading the context. + @ContextConfiguration defines the + application context resource locations to + load as well as the ContextLoader + strategy to use for loading the context. @ContextConfiguration(locations={"example/test-context.xml"}, loader=CustomContextLoader.class) public class CustomConfiguredApplicationContextTests { @@ -442,16 +442,37 @@ public class CustomConfiguredApplicationContextTests { role="bold">@DirtiesContext The presence of this annotation on a test method indicates - that the underlying Spring container is 'dirtied' during the - execution of the test method, and thus must be rebuilt after the - test method finishes execution (regardless of whether the test - passed or not). + that the underlying Spring container has been dirtied + during the execution of the test method and thus must be closed after the + test method finishes execution (regardless of whether the annotated test + passed or not). Similarly, if a test class is annotated with + @DirtiesContext, the underlying + Spring container will be marked as dirty after all tests in the + class have completed execution. + + @DirtiesContext +public class ContextDirtyingTests { + // some tests that result in the Spring container being dirtied +} @DirtiesContext @Test public void testProcessWhichDirtiesAppCtx() { // some logic that results in the Spring container being dirtied } + + Whenever an application context is marked as + dirty, it will be removed from the testing + framework's cache and closed; thus the underlying Spring container will be + rebuilt for any subsequent test which requires a context with the + same set of resource locations. + + + Limitations of <interfacename>@DirtiesContext</interfacename> with JUnit 3.8 + In a JUnit 3.8 environment @DirtiesContext + is only supported on methods and thus not at the class level. + + -- GitLab