ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/junit XMLJUnitResultFormatter.java
Date Thu, 17 Mar 2005 08:21:21 GMT
bodewig     2005/03/17 00:21:21

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/junit
                        XMLJUnitResultFormatter.java
  Log:
  Don't die if Test.getName returns null, PR 29407
  
  Revision  Changes    Path
  1.39      +8 -3      ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
  
  Index: XMLJUnitResultFormatter.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- XMLJUnitResultFormatter.java	22 Nov 2004 09:23:34 -0000	1.38
  +++ XMLJUnitResultFormatter.java	17 Mar 2005 08:21:21 -0000	1.39
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2000-2004 The Apache Software Foundation
  + * Copyright  2000-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -49,6 +49,9 @@
   
   public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstants {
   
  +    /** constant for unnnamed testsuites/cases */
  +    private static final String UNKNOWN = "unknown";
  +
       private static DocumentBuilder getDocumentBuilder() {
           try {
               return DocumentBuilderFactory.newInstance().newDocumentBuilder();
  @@ -103,7 +106,8 @@
       public void startTestSuite(JUnitTest suite) {
           doc = getDocumentBuilder().newDocument();
           rootElement = doc.createElement(TESTSUITE);
  -        rootElement.setAttribute(ATTR_NAME, suite.getName());
  +        String n = suite.getName();
  +        rootElement.setAttribute(ATTR_NAME, n == null ? UNKNOWN : n);
   
           //add the timestamp
           final String timestamp = DateUtils.format(new Date(),
  @@ -190,8 +194,9 @@
           Element currentTest = null;
           if (!failedTests.containsKey(test)) {
               currentTest = doc.createElement(TESTCASE);
  +            String n = JUnitVersionHelper.getTestCaseName(test);
               currentTest.setAttribute(ATTR_NAME,
  -                                     JUnitVersionHelper.getTestCaseName(test));
  +                                     n == null ? UNKNOWN : n);
               // a TestSuite can contain Tests from multiple classes,
               // even tests with the same name - disambiguate them.
               currentTest.setAttribute(ATTR_CLASSNAME,
  
  
  

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


Mime
View raw message