You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/02/19 06:14:29 UTC
svn commit: r628990 -
/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
Author: bodewig
Date: Mon Feb 18 21:11:38 2008
New Revision: 628990
URL: http://svn.apache.org/viewvc?rev=628990&view=rev
Log:
fix part of Cactus problems with the refactored JUnit task of 1.7.0: create the "delegate" as needed instead of in execute()
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=628990&r1=628989&r2=628990&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Mon Feb 18 21:11:38 2008
@@ -162,6 +162,7 @@
private boolean splitJunit = false;
private JUnitTaskMirror delegate;
+ private ClassLoader mirrorLoader;
/** A boolean on whether to get the forked path for ant classes */
private boolean forkedPathChecked = false;
@@ -746,14 +747,10 @@
}
/**
- * Runs the testcase.
- *
- * @throws BuildException in case of test failures or errors
- * @since Ant 1.2
+ * Sets up the delegate that will actually run the tests.
*/
- public void execute() throws BuildException {
+ protected void setupJUnitDelegate() {
ClassLoader myLoader = JUnitTask.class.getClassLoader();
- ClassLoader mirrorLoader;
if (splitJunit) {
Path path = new Path(getProject());
path.add(antRuntimeClasses);
@@ -766,6 +763,16 @@
mirrorLoader = myLoader;
}
delegate = createMirror(this, mirrorLoader);
+ }
+
+ /**
+ * Runs the testcase.
+ *
+ * @throws BuildException in case of test failures or errors
+ * @since Ant 1.2
+ */
+ public void execute() throws BuildException {
+ setupJUnitDelegate();
List testLists = new ArrayList();
@@ -793,11 +800,7 @@
}
}
} finally {
- deleteClassLoader();
- if (mirrorLoader instanceof SplitLoader) {
- ((SplitLoader) mirrorLoader).cleanup();
- }
- delegate = null;
+ cleanup();
}
}
@@ -1262,6 +1265,10 @@
* @return the results
*/
private TestResultHolder executeInVM(JUnitTest arg) throws BuildException {
+ if (delegate == null) {
+ setupJUnitDelegate();
+ }
+
JUnitTest test = (JUnitTest) arg.clone();
test.setProperties(getProject().getProperties());
if (dir != null) {
@@ -1514,6 +1521,10 @@
*/
private void logVmExit(FormatterElement[] feArray, JUnitTest test,
String message, String testCase) {
+ if (delegate == null) {
+ setupJUnitDelegate();
+ }
+
try {
log("Using System properties " + System.getProperties(),
Project.MSG_VERBOSE);
@@ -1592,6 +1603,14 @@
}
/**
+ * Removes resources.
+ */
+ protected void cleanup() {
+ deleteClassLoader();
+ delegate = null;
+ }
+
+ /**
* Removes a classloader if needed.
* @since Ant 1.7
*/
@@ -1600,6 +1619,10 @@
classLoader.cleanup();
classLoader = null;
}
+ if (mirrorLoader instanceof SplitLoader) {
+ ((SplitLoader) mirrorLoader).cleanup();
+ }
+ mirrorLoader = null;
}
/**