ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r532247 - /ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java
Date Wed, 25 Apr 2007 08:14:42 GMT
Author: jhm
Date: Wed Apr 25 01:14:42 2007
New Revision: 532247

URL: http://svn.apache.org/viewvc?view=rev&rev=532247
Log:
Bug 41940 : works for JUnit's own runners, but not for Ant's. Ideas?

Modified:
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java?view=diff&rev=532247&r1=532246&r2=532247
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java Wed Apr 25 01:14:42
2007
@@ -22,6 +22,7 @@
 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 @@
      * 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);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message