From db412627e12283e6f51b8e502074b096ac9ff0e1 Mon Sep 17 00:00:00 2001 From: Jan Materne Date: Wed, 25 Apr 2007 08:14:42 +0000 Subject: [PATCH] Bug 41940 : works for JUnit's own runners, but not for Ant's. Ideas? git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@532247 13f79535-47bb-0310-9956-ffa450edef68 --- .../junit/org/apache/tools/ant/BuildFileTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java index 0b55ce7c0..5a628f9b2 100644 --- a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java @@ -22,6 +22,7 @@ import junit.framework.TestCase; import java.io.File; import java.io.PrintStream; import java.net.URL; +import java.util.Hashtable; /** * A BuildFileTest is a TestCase which executes targets from an Ant buildfile @@ -67,6 +68,17 @@ public abstract class BuildFileTest extends TestCase { * test target depend on it. */ protected void tearDown() throws Exception { + if (project == null) { + /* + * Maybe the BuildFileTest was subclassed and there is + * no initialized project. So we could avoid getting a + * NPE. + * If there is an initialized project getTargets() does + * not return null as it is initialized by an empty + * HashSet. + */ + return; + } final String tearDown = "tearDown"; if (project.getTargets().containsKey(tearDown)) { project.executeTarget(tearDown);