diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/TestExecutionListener.java b/org.springframework.test/src/main/java/org/springframework/test/context/TestExecutionListener.java index 4870c15d543..2b67223d938 100644 --- a/org.springframework.test/src/main/java/org/springframework/test/context/TestExecutionListener.java +++ b/org.springframework.test/src/main/java/org/springframework/test/context/TestExecutionListener.java @@ -54,6 +54,10 @@ public interface TestExecutionListener { *
* This method should be called immediately before framework-specific * before class lifecycle callbacks. + *
+ * If a given testing framework (e.g., JUnit 3.8) does not support
+ * before class lifecycle callbacks, this method will not be called
+ * for that framework.
*
* @param testContext the test context for the test; never null
* @throws Exception allows any exception to propagate
@@ -108,6 +112,10 @@ public interface TestExecutionListener {
*
* This method should be called immediately after framework-specific * after class lifecycle callbacks. + *
+ * If a given testing framework (e.g., JUnit 3.8) does not support
+ * after class lifecycle callbacks, this method will not be called
+ * for that framework.
*
* @param testContext the test context for the test; never null
* @throws Exception allows any exception to propagate
diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/junit38/AbstractJUnit38SpringContextTests.java b/org.springframework.test/src/main/java/org/springframework/test/context/junit38/AbstractJUnit38SpringContextTests.java
index c841db88547..16f6261dfce 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/junit38/AbstractJUnit38SpringContextTests.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/junit38/AbstractJUnit38SpringContextTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@ import java.lang.reflect.Modifier;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.test.annotation.ExpectedException;
@@ -39,47 +39,67 @@ import org.springframework.test.context.support.DirtiesContextTestExecutionListe
/**
*
- * Abstract base {@link TestCase} which integrates the - * Spring TestContext Framework with explicit - * {@link ApplicationContext} testing support in a JUnit 3.8 - * environment. + * Abstract base {@link TestCase} which integrates the Spring TestContext + * Framework and explicit {@link ApplicationContext} testing support in a + * JUnit 3.8 environment. *
** Concrete subclasses: *
*super(); and super(name);
- * respectively.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
- * {@link org.springframework.test.context.TestExecutionListener TestExecutionListeners})
+ * by AbstractJUnit38SpringContextTests. (Note that additional
+ * annotations may be supported by various
+ * {@link org.springframework.test.context.TestExecutionListener
+ * TestExecutionListeners})
*
+ * JUnit 3.8 does not support before class or after class + * lifecycle callbacks. The following + * {@link org.springframework.test.context.TestExecutionListener + * TestExecutionListener} methods are therefore unsupported in a JUnit 3.8 + * environment: + *
name; initializes the internal
* {@link TestContextManager} for the current test; and retrieves the
* configured (or default) {@link ProfileValueSource}.
+ *
* @param name the name of the current test to execute
*/
public AbstractJUnit38SpringContextTests(String name) {
@@ -149,7 +170,6 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
this.profileValueSource = ProfileValueUtils.retrieveProfileValueSource(getClass());
}
-
/**
* Sets the {@link ApplicationContext} to be used by this test instance,
* provided via {@link ApplicationContextAware} semantics.
@@ -158,24 +178,26 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
this.applicationContext = applicationContext;
}
-
/**
* Runs the Spring TestContext Framework test sequence.
- * In addition to standard {@link TestCase#runBare()} semantics, this + *
+ * In addition to standard {@link TestCase#runBare()} semantics, this * implementation performs the following: *
timeout
+ * @param testMethod the actual test method: used to retrieve the
+ * timeout
* @throws Throwable if any exception is thrown
* @see Timed
* @see #runTest
@@ -243,21 +268,22 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
/**
* Runs a test via the supplied {@link TestExecutionCallback}, providing
- * support for the {@link ExpectedException @ExpectedException} and
- * {@link Repeat @Repeat} annotations.
+ * support for the {@link ExpectedException @ExpectedException} and
+ * {@link Repeat @Repeat} annotations.
+ *
* @param tec the test execution callback to run
* @param testMethod the actual test method: used to retrieve the
- * {@link ExpectedException @ExpectedException} and {@link Repeat @Repeat} annotations
+ * {@link ExpectedException @ExpectedException} and {@link Repeat
+ * @Repeat} annotations
* @throws Throwable if any exception is thrown
* @see ExpectedException
* @see Repeat
*/
private void runTest(TestExecutionCallback tec, Method testMethod) throws Throwable {
ExpectedException expectedExceptionAnnotation = testMethod.getAnnotation(ExpectedException.class);
- boolean exceptionIsExpected = (expectedExceptionAnnotation != null &&
- expectedExceptionAnnotation.value() != null);
- Class extends Throwable> expectedException =
- (exceptionIsExpected ? expectedExceptionAnnotation.value() : null);
+ boolean exceptionIsExpected = (expectedExceptionAnnotation != null && expectedExceptionAnnotation.value() != null);
+ Class extends Throwable> expectedException = (exceptionIsExpected ? expectedExceptionAnnotation.value()
+ : null);
Repeat repeat = testMethod.getAnnotation(Repeat.class);
int runs = ((repeat != null) && (repeat.value() > 1)) ? repeat.value() : 1;
@@ -278,8 +304,8 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
}
if (!expectedException.isAssignableFrom(ex.getClass())) {
// Wrap the unexpected throwable with an explicit message.
- AssertionFailedError assertionError = new AssertionFailedError("Unexpected exception, expected <" +
- expectedException.getName() + "> but was <" + ex.getClass().getName() + ">");
+ AssertionFailedError assertionError = new AssertionFailedError("Unexpected exception, expected <"
+ + expectedException.getName() + "> but was <" + ex.getClass().getName() + ">");
assertionError.initCause(ex);
throw assertionError;
}
@@ -291,6 +317,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
* Calls {@link TestContextManager#beforeTestMethod(Object,Method)} and
* {@link TestContextManager#afterTestMethod(Object,Method,Throwable)} at
* the appropriate test execution points.
+ *
* @param testMethod the test method to run
* @throws Throwable if any exception is thrown
* @see #runBare()
@@ -344,6 +371,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
* Records the supplied test method as disabled in the current
* environment by incrementing the total number of disabled tests and
* logging a debug message.
+ *
* @param testMethod the test method that is disabled.
* @see #getDisabledTestCount()
*/
@@ -357,8 +385,8 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
/**
- * Private inner class that defines a callback analogous to
- * {@link Runnable}, just declaring Throwable.
+ * Private inner class that defines a callback analogous to {@link Runnable}
+ * , just declaring Throwable.
*/
private static interface TestExecutionCallback {