| |
|
| org.springframework.test.ConditionalTestCase org.springframework.test.AbstractSpringContextTests org.springframework.test.AbstractSingleSpringContextTests org.springframework.test.AbstractDependencyInjectionSpringContextTests
All known Subclasses: org.springframework.test.AbstractTransactionalSpringContextTests,
AbstractDependencyInjectionSpringContextTests | abstract public class AbstractDependencyInjectionSpringContextTests extends AbstractSingleSpringContextTests (Code) | | Convenient superclass for tests depending on a Spring context.
The test instance itself is populated by Dependency Injection.
Really for integration testing, not unit testing.
You should not normally use the Spring container
for unit tests: simply populate your POJOs in plain JUnit tests!
This supports two modes of populating the test:
- Via Setter Dependency Injection. Simply express dependencies on objects
in the test fixture, and they will be satisfied by autowiring by type.
- Via Field Injection. Declare protected variables of the required type
which match named beans in the context. This is autowire by name,
rather than type. This approach is based on an approach originated by
Ara Abrahmian. Setter Dependency Injection is the default: set the
"populateProtectedVariables" property to true in the constructor to switch
on Field Injection.
author: Rod Johnson author: Rob Harrop author: Rick Evans since: 1.1.1 See Also: AbstractDependencyInjectionSpringContextTests.setDirty See Also: AbstractDependencyInjectionSpringContextTests.contextKey See Also: AbstractDependencyInjectionSpringContextTests.getContext See Also: AbstractDependencyInjectionSpringContextTests.getConfigLocations |
Field Summary | |
final public static int | AUTOWIRE_BY_NAME Constant that indicates autowiring bean properties by name. | final public static int | AUTOWIRE_BY_TYPE Constant that indicates autowiring bean properties by type. | final public static int | AUTOWIRE_NO Constant that indicates no autowiring at all. |
Method Summary | |
final public int | getAutowireMode() Return the autowire mode for test properties set by Dependency Injection. | protected void | injectDependencies() Inject dependencies into 'this' instance (that is, this test instance). | final public boolean | isDependencyCheck() Return whether or not dependency checking should be performed
for test properties set by Dependency Injection. | final public boolean | isPopulateProtectedVariables() Return whether to populate protected variables of this test case. | protected void | prepareTestInstance() Prepare this test instance, injecting dependencies into its
protected fields and its bean properties. | final public void | setAutowireMode(int autowireMode) Set the autowire mode for test properties set by Dependency Injection.
The default is "AUTOWIRE_BY_TYPE". | final public void | setDependencyCheck(boolean dependencyCheck) Set whether or not dependency checking should be performed
for test properties set by Dependency Injection. | final public void | setPopulateProtectedVariables(boolean populateFields) Set whether to populate protected variables of this test case. |
AbstractDependencyInjectionSpringContextTests | public AbstractDependencyInjectionSpringContextTests()(Code) | | Default constructor for AbstractDependencyInjectionSpringContextTests.
|
AbstractDependencyInjectionSpringContextTests | public AbstractDependencyInjectionSpringContextTests(String name)(Code) | | Constructor for AbstractDependencyInjectionSpringContextTests with a JUnit name.
Parameters: name - the name of this text fixture |
getAutowireMode | final public int getAutowireMode()(Code) | | Return the autowire mode for test properties set by Dependency Injection.
|
isDependencyCheck | final public boolean isDependencyCheck()(Code) | | Return whether or not dependency checking should be performed
for test properties set by Dependency Injection.
|
isPopulateProtectedVariables | final public boolean isPopulateProtectedVariables()(Code) | | Return whether to populate protected variables of this test case.
|
prepareTestInstance | protected void prepareTestInstance() throws Exception(Code) | | Prepare this test instance, injecting dependencies into its
protected fields and its bean properties.
|
setDependencyCheck | final public void setDependencyCheck(boolean dependencyCheck)(Code) | | Set whether or not dependency checking should be performed
for test properties set by Dependency Injection.
The default is "true", meaning that tests cannot be run
unless all properties are populated.
|
setPopulateProtectedVariables | final public void setPopulateProtectedVariables(boolean populateFields)(Code) | | Set whether to populate protected variables of this test case.
Default is "false".
|
Fields inherited from org.springframework.test.ConditionalTestCase | final protected Log logger(Code)(Java Doc)
|
|
|
|