|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
public abstract class AbstractDependencyInjectionSpringContextTests
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:
AbstractSingleSpringContextTests.setDirty()
,
AbstractSingleSpringContextTests.contextKey()
,
AbstractSpringContextTests.getContext(java.lang.Object)
,
AbstractSingleSpringContextTests.getConfigLocations()
Field Summary | |
---|---|
static int |
AUTOWIRE_BY_NAME
Constant that indicates autowiring bean properties by name. |
static int |
AUTOWIRE_BY_TYPE
Constant that indicates autowiring bean properties by type. |
static int |
AUTOWIRE_NO
Constant that indicates no autowiring at all. |
Fields inherited from class org.springframework.test.AbstractSingleSpringContextTests |
---|
applicationContext |
Fields inherited from class org.springframework.test.ConditionalTestCase |
---|
logger |
Constructor Summary | |
---|---|
AbstractDependencyInjectionSpringContextTests()
Default constructor for AbstractDependencyInjectionSpringContextTests. |
|
AbstractDependencyInjectionSpringContextTests(String name)
Constructor for AbstractDependencyInjectionSpringContextTests with a JUnit name. |
Method Summary | |
---|---|
int |
getAutowireMode()
Return the autowire mode for test properties set by Dependency Injection. |
boolean |
isDependencyCheck()
Return whether or not dependency checking should be performed for test properties set by Dependency Injection. |
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. |
void |
setAutowireMode(int autowireMode)
Set the autowire mode for test properties set by Dependency Injection. |
void |
setDependencyCheck(boolean dependencyCheck)
Set whether or not dependency checking should be performed for test properties set by Dependency Injection. |
void |
setPopulateProtectedVariables(boolean populateFields)
Set whether to populate protected variables of this test case. |
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests |
---|
contextKey, getConfigLocations, getLoadCount, loadContext, loadContextLocations, onSetUp, onTearDown, setDirty, setUp, tearDown |
Methods inherited from class org.springframework.test.AbstractSpringContextTests |
---|
addContext, contextKeyString, getContext, hasCachedContext, setDirty |
Methods inherited from class org.springframework.test.ConditionalTestCase |
---|
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled, runBare |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runTest, setName, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int AUTOWIRE_NO
setAutowireMode(int)
,
Constant Field Valuespublic static final int AUTOWIRE_BY_NAME
setAutowireMode(int)
,
Constant Field Valuespublic static final int AUTOWIRE_BY_TYPE
setAutowireMode(int)
,
Constant Field ValuesConstructor Detail |
---|
public AbstractDependencyInjectionSpringContextTests()
public AbstractDependencyInjectionSpringContextTests(String name)
name
- the name of this text fixtureMethod Detail |
---|
public final void setPopulateProtectedVariables(boolean populateFields)
public final boolean isPopulateProtectedVariables()
public final void setAutowireMode(int autowireMode)
The default is "AUTOWIRE_BY_TYPE". Can be set to "AUTOWIRE_BY_NAME" or "AUTOWIRE_NO" instead.
AUTOWIRE_BY_TYPE
,
AUTOWIRE_BY_NAME
,
AUTOWIRE_NO
public final int getAutowireMode()
public final void setDependencyCheck(boolean dependencyCheck)
The default is "true", meaning that tests cannot be run unless all properties are populated.
public final boolean isDependencyCheck()
protected void prepareTestInstance() throws Exception
prepareTestInstance
in class AbstractSingleSpringContextTests
Exception
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |