Polish SpringJUnit4ClassRunner and related support classes

This commit is contained in:
Sam Brannen
2015-05-11 13:39:22 +02:00
parent 7ea50238a6
commit d14e29a5c0
8 changed files with 113 additions and 105 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@@ -41,11 +41,10 @@ import org.springframework.tests.sample.beans.Pet;
import static org.junit.Assert.*;
/**
* <p>
* SpringJUnit4ClassRunnerAppCtxTests serves as a <em>proof of concept</em>
* JUnit 4 based test class, which verifies the expected functionality of
* {@link SpringJUnit4ClassRunner} in conjunction with the following:
* </p>
*
* <ul>
* <li>{@link ContextConfiguration @ContextConfiguration}</li>
* <li>{@link Autowired @Autowired}</li>
@@ -58,18 +57,15 @@ import static org.junit.Assert.*;
* <li>{@link BeanNameAware}</li>
* <li>{@link InitializingBean}</li>
* </ul>
* <p>
* Since no application context resource
*
* <p>Since no application context resource
* {@link ContextConfiguration#locations() locations} are explicitly declared
* and since the {@link ContextConfiguration#loader() ContextLoader} is left set
* to the default value of {@link GenericXmlContextLoader}, this test class's
* dependencies will be injected via {@link Autowired @Autowired},
* {@link Inject @Inject}, and {@link Resource @Resource} from beans defined in
* the {@link ApplicationContext} loaded from the default classpath resource:
*
* {@code &quot;/org/springframework/test/context/junit/SpringJUnit4ClassRunnerAppCtxTests-context.xml&quot;}
* .
* </p>
* {@value #DEFAULT_CONTEXT_RESOURCE_PATH}.
*
* @author Sam Brannen
* @since 2.5
@@ -79,14 +75,12 @@ import static org.junit.Assert.*;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@TestExecutionListeners( { DependencyInjectionTestExecutionListener.class })
@TestExecutionListeners(DependencyInjectionTestExecutionListener.class)
public class SpringJUnit4ClassRunnerAppCtxTests implements ApplicationContextAware, BeanNameAware, InitializingBean {
/**
* Default resource path for the application context configuration for
* {@link SpringJUnit4ClassRunnerAppCtxTests}:
*
* {@code &quot;/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml&quot;}
* {@link SpringJUnit4ClassRunnerAppCtxTests}: {@value #DEFAULT_CONTEXT_RESOURCE_PATH}
*/
public static final String DEFAULT_CONTEXT_RESOURCE_PATH = "/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml";