java.lang.Object | ||||||
↳ | junit.framework.Assert | |||||
↳ | junit.framework.TestCase | |||||
↳ | org.springframework.test.ConditionalTestCase | |||||
↳ | org.springframework.test.AbstractSpringContextTests | |||||
↳ | org.springframework.test.AbstractSingleSpringContextTests | |||||
↳ | org.springframework.test.AbstractDependencyInjectionSpringContextTests |
Known Direct Subclasses |
Known Indirect Subclasses |
This class is deprecated.
as of Spring 3.0, in favor of using the listener-based test context framework
(AbstractJUnit38SpringContextTests
)
Convenient superclass for JUnit 3.8 based 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:
populateProtectedVariables
property to true
in
the constructor to switch on Field Injection.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | AUTOWIRE_BY_NAME | Constant that indicates autowiring bean properties by name. | |||||||||
int | AUTOWIRE_BY_TYPE | Constant that indicates autowiring bean properties by type. | |||||||||
int | AUTOWIRE_NO | Constant that indicates no autowiring at all. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.test.AbstractSingleSpringContextTests
| |||||||||||
From class
org.springframework.test.ConditionalTestCase
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor for AbstractDependencyInjectionSpringContextTests.
| |||||||||||
Constructor for AbstractDependencyInjectionSpringContextTests with a
JUnit name.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the autowire mode for test properties set by Dependency Injection.
| |||||||||||
Return whether or not dependency checking should be performed for test
properties set by Dependency Injection.
| |||||||||||
Return whether to populate protected variables of this test case.
| |||||||||||
Set the autowire mode for test properties set by Dependency Injection.
| |||||||||||
Set whether or not dependency checking should be performed for test
properties set by Dependency Injection.
| |||||||||||
Set whether to populate protected variables of this test case.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Inject dependencies into 'this' instance (that is, this test instance).
| |||||||||||
Prepare this test instance, injecting dependencies into its protected
fields and its bean properties.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.test.AbstractSingleSpringContextTests
| |||||||||||
From class
org.springframework.test.AbstractSpringContextTests
| |||||||||||
From class
org.springframework.test.ConditionalTestCase
| |||||||||||
From class
junit.framework.TestCase
| |||||||||||
From class
junit.framework.Assert
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
junit.framework.Test
|
Constant that indicates autowiring bean properties by name.
Constant that indicates autowiring bean properties by type.
Constant that indicates no autowiring at all.
Default constructor for AbstractDependencyInjectionSpringContextTests.
Constructor for AbstractDependencyInjectionSpringContextTests with a JUnit name.
name | the name of this text fixture |
---|
Return the autowire mode for test properties set by Dependency Injection.
Return whether or not dependency checking should be performed for test properties set by Dependency Injection.
Return whether to populate protected variables of this test case.
Set the autowire mode for test properties set by Dependency Injection.
The default is AUTOWIRE_BY_TYPE
. Can be set to
AUTOWIRE_BY_NAME
or AUTOWIRE_NO
instead.
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.
Set whether to populate protected variables of this test case. Default is
false
.
Inject dependencies into 'this' instance (that is, this test instance).
The default implementation populates protected variables if the #populateProtectedVariables() appropriate flag is set, else uses autowiring if autowiring is switched on (which it is by default).
Override this method if you need full control over how dependencies are injected into the test instance.
Exception | in case of dependency injection failure |
---|---|
IllegalStateException | if the ApplicationContext for this
test instance has not been configured |
Prepare this test instance, injecting dependencies into its protected fields and its bean properties.
Note: if the ApplicationContext
for this test instance has not
been configured (e.g., is null
), dependency injection
will naturally not be performed, but an informational
message will be written to the log.
Exception |
---|