AbstractJUnit4SpringContextTests
@Deprecated @TestExecutionListeners(value={DependencyInjectionTestExecutionListener.class,DirtiesContextTestExecutionListener.class}) public abstract class AbstractJUnit38SpringContextTests extends TestCase implements ApplicationContextAware
Abstract base TestCase
which integrates the Spring TestContext
Framework and explicit ApplicationContext
testing support in a
JUnit 3.8 environment.
Concrete subclasses:
@ContextConfiguration
annotation to configure the
application context
resource locations
. If your test does not need to load an application
context, you may choose to omit the
@ContextConfiguration
declaration and configure the appropriate
TestExecutionListeners
manually.AbstractJUnit38SpringContextTests()
and
AbstractJUnit38SpringContextTests(String)
and delegate to
super();
and super(name);
respectively.
The following list constitutes all annotations currently supported directly
by AbstractJUnit38SpringContextTests
. (Note that additional
annotations may be supported by various
TestExecutionListeners
)
@DirtiesContext
(via the configured
DirtiesContextTestExecutionListener
; only supported on methods for
JUnit 3.8)@ProfileValueSourceConfiguration
@IfProfileValue
@ExpectedException
@Timed
@Repeat
JUnit 3.8 does not support before class or after class
lifecycle callbacks. The following
TestExecutionListener
methods are therefore unsupported in a JUnit 3.8
environment:
TestContext
,
TestContextManager
,
TestExecutionListeners
,
AbstractTransactionalJUnit38SpringContextTests
,
AbstractJUnit4SpringContextTests
,
AbstractTestNGSpringContextTests
Modifier and Type | Class and Description |
---|---|
private static interface |
AbstractJUnit38SpringContextTests.TestExecutionCallback
Deprecated.
Private inner class that defines a callback analogous to
Runnable
, just declaring Throwable. |
Modifier and Type | Field and Description |
---|---|
protected ApplicationContext |
applicationContext
Deprecated.
The
ApplicationContext that was injected into this test instance
via setApplicationContext(ApplicationContext) . |
private static int |
disabledTestCount
Deprecated.
|
protected Log |
logger
Deprecated.
Logger available to subclasses.
|
protected ProfileValueSource |
profileValueSource
Deprecated.
ProfileValueSource available to subclasses but primarily intended
for internal use to provide support for @IfProfileValue . |
private TestContextManager |
testContextManager
Deprecated.
|
Constructor and Description |
---|
AbstractJUnit38SpringContextTests()
Deprecated.
Constructs a new AbstractJUnit38SpringContextTests instance; initializes
the internal
TestContextManager for the current test; and
retrieves the configured (or default) ProfileValueSource . |
AbstractJUnit38SpringContextTests(java.lang.String name)
Deprecated.
Constructs a new AbstractJUnit38SpringContextTests instance with the
supplied
name ; initializes the internal
TestContextManager for the current test; and retrieves the
configured (or default) ProfileValueSource . |
Modifier and Type | Method and Description |
---|---|
static int |
getDisabledTestCount()
Deprecated.
Return the number of tests disabled in this environment.
|
private java.lang.reflect.Method |
getTestMethod()
Deprecated.
Get the current test method.
|
protected void |
recordDisabled(java.lang.reflect.Method testMethod)
Deprecated.
Records the supplied test method as disabled in the current
environment by incrementing the total number of disabled tests and
logging a debug message.
|
void |
runBare()
Deprecated.
Runs the Spring TestContext Framework test sequence.
|
private void |
runManaged(java.lang.reflect.Method testMethod)
Deprecated.
Calls
TestContextManager.beforeTestMethod(Object,Method) and
TestContextManager.afterTestMethod(Object,Method,Throwable) at
the appropriate test execution points. |
private void |
runTest(AbstractJUnit38SpringContextTests.TestExecutionCallback tec,
java.lang.reflect.Method testMethod)
Deprecated.
Runs a test via the supplied
AbstractJUnit38SpringContextTests.TestExecutionCallback , providing
support for the @ExpectedException and
@Repeat annotations. |
private void |
runTestTimed(AbstractJUnit38SpringContextTests.TestExecutionCallback tec,
java.lang.reflect.Method testMethod)
Deprecated.
Runs a timed test via the supplied
AbstractJUnit38SpringContextTests.TestExecutionCallback
, providing support for the @Timed annotation. |
void |
setApplicationContext(ApplicationContext applicationContext)
Deprecated.
Sets the
ApplicationContext to be used by this test instance,
provided via ApplicationContextAware semantics. |
private static int disabledTestCount
protected final Log logger
protected ApplicationContext applicationContext
ApplicationContext
that was injected into this test instance
via setApplicationContext(ApplicationContext)
.protected final ProfileValueSource profileValueSource
ProfileValueSource
available to subclasses but primarily intended
for internal use to provide support for @IfProfileValue
.private final TestContextManager testContextManager
public AbstractJUnit38SpringContextTests()
TestContextManager
for the current test; and
retrieves the configured (or default) ProfileValueSource
.public AbstractJUnit38SpringContextTests(java.lang.String name)
name
; initializes the internal
TestContextManager
for the current test; and retrieves the
configured (or default) ProfileValueSource
.name
- the name of the current test to executepublic static int getDisabledTestCount()
public final void setApplicationContext(ApplicationContext applicationContext)
ApplicationContext
to be used by this test instance,
provided via ApplicationContextAware
semantics.setApplicationContext
in interface ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectBeanInitializationException
public void runBare() throws java.lang.Throwable
In addition to standard TestCase#runBare()
semantics, this
implementation performs the following:
prepareTestInstance()
,
beforeTestMethod()
, and
afterTestMethod()
on this test's TestContextManager
at the
appropriate test execution points.@IfProfileValue
.@Repeat
.@Timed
.@ExpectedException
.java.lang.Throwable
ProfileValueUtils.isTestEnabledInThisEnvironment(java.lang.Class<?>)
private java.lang.reflect.Method getTestMethod()
private void runTestTimed(AbstractJUnit38SpringContextTests.TestExecutionCallback tec, java.lang.reflect.Method testMethod) throws java.lang.Throwable
AbstractJUnit38SpringContextTests.TestExecutionCallback
, providing support for the @Timed
annotation.tec
- the test execution callback to runtestMethod
- the actual test method: used to retrieve the
timeout
java.lang.Throwable
- if any exception is thrownTimed
,
runTest(org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests.TestExecutionCallback, java.lang.reflect.Method)
private void runTest(AbstractJUnit38SpringContextTests.TestExecutionCallback tec, java.lang.reflect.Method testMethod) throws java.lang.Throwable
AbstractJUnit38SpringContextTests.TestExecutionCallback
, providing
support for the @ExpectedException
and
@Repeat
annotations.tec
- the test execution callback to runtestMethod
- the actual test method: used to retrieve the
@ExpectedException
and @Repeat
annotationsjava.lang.Throwable
- if any exception is thrownExpectedException
,
Repeat
private void runManaged(java.lang.reflect.Method testMethod) throws java.lang.Throwable
TestContextManager.beforeTestMethod(Object,Method)
and
TestContextManager.afterTestMethod(Object,Method,Throwable)
at
the appropriate test execution points.testMethod
- the test method to runjava.lang.Throwable
- if any exception is thrownrunBare()
,
TestCase#runTest()
protected void recordDisabled(java.lang.reflect.Method testMethod)
testMethod
- the test method that is disabled.getDisabledTestCount()