SpringSource/spring-framework — pull request #43 by ttddyy (2012-02-29 01:39:05+00:00)
Title: Add support for creating test contexts with parent context

Hello,

I created "@ParentContextConfiguration" to support parent test contexts in spring-test framework.

Sample:

```java
@ParentContextConfiguration("parent-context.xml")
@ContextConfiguration("child-context.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class SomeTests {

@Autowired
protected ApplicationContext applicationContext;

// applicationContext.getParent() returns the parent app context
}
```

Parent context will be shared across the test classes if they are annotated to use parent context and have same configurations(xml locations, configuration classes, etc). It uses existing context caching mechanism.
I also added "parent" attribute to @DirtiesContext annotation in order to close the parent context if required. When "parent=true" is set on @DirtiesContext, DirtiesContextTestExecutionListener will close the parent application context as well as child contexts using the specified parent context.

Changes:

- created @ParentContextConfiguration to configure the parent application context.

- reused the @ContextConfigurationAttributes to represent both @ContextConfiguration and @ParentContextConfiguration

- changed ContextLoader SPI to pass a parent ApplicationContext

- refactored ContextLoaderUtils to use "getConfigurationAttributes()" to resolve the context loader class and configuration attribute in a similar manner.

- created ContextCacheKey class which contains two MergedContextConfiguration (one for parent, one for child) as a key of ContextCache.

- added "parent" attribute on @DirtiesContext

- @DirtiesContext(parent=true) will remove parent app context and all child app contexts using that parent context from the cache

- unit tests

Issue: [SPR-5613](https://jira.springsource.org/browse/SPR-5613)

Submitted the CLA

Thanks,