|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests
@TestExecutionListeners(value={DependencyInjectionTestExecutionListener.class,DirtiesContextTestExecutionListener.class})
public abstract class AbstractJUnit38SpringContextTests
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| Nested Class Summary | |
|---|---|
private static interface |
AbstractJUnit38SpringContextTests.TestExecutionCallback
Private inner class that defines a callback analogous to Runnable
, just declaring Throwable. |
| Field Summary | |
|---|---|
protected ApplicationContext |
applicationContext
The ApplicationContext that was injected into this test instance
via setApplicationContext(ApplicationContext). |
private static int |
disabledTestCount
|
protected Log |
logger
Logger available to subclasses. |
protected ProfileValueSource |
profileValueSource
ProfileValueSource available to subclasses but primarily intended
for internal use to provide support for @IfProfileValue. |
private TestContextManager |
testContextManager
|
| Constructor Summary | |
|---|---|
AbstractJUnit38SpringContextTests()
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)
Constructs a new AbstractJUnit38SpringContextTests instance with the supplied name; initializes the internal
TestContextManager for the current test; and retrieves the
configured (or default) ProfileValueSource. |
|
| Method Summary | |
|---|---|
static int |
getDisabledTestCount()
Return the number of tests disabled in this environment. |
private java.lang.reflect.Method |
getTestMethod()
Get the current test method. |
protected void |
recordDisabled(java.lang.reflect.Method testMethod)
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()
Runs the Spring TestContext Framework test sequence. |
private void |
runManaged(java.lang.reflect.Method testMethod)
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)
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)
Runs a timed test via the supplied AbstractJUnit38SpringContextTests.TestExecutionCallback
, providing support for the @Timed annotation. |
void |
setApplicationContext(ApplicationContext applicationContext)
Sets the ApplicationContext to be used by this test instance,
provided via ApplicationContextAware semantics. |
| Methods inherited from class junit.framework.TestCase |
|---|
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, 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, failNotEquals, failNotSame, failSame |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
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 execute| Method Detail |
|---|
public static int getDisabledTestCount()
public final void setApplicationContext(ApplicationContext applicationContext)
ApplicationContext to be used by this test instance,
provided via ApplicationContextAware semantics.
setApplicationContext in interface ApplicationContextAwareapplicationContext - 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.
runBare in class junit.framework.TestCasejava.lang.ThrowableProfileValueUtils.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 annotations
java.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 run
java.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()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||