maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tibordig...@apache.org
Subject [maven-surefire] branch master updated: [SUREFIRE-1552] Nil element "failureMessage" in failsafe-summary.xml should have self closed tag
Date Tue, 14 Aug 2018 21:37:25 GMT
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/master by this push:
     new 2beecc6  [SUREFIRE-1552] Nil element "failureMessage" in failsafe-summary.xml should
have self closed tag
2beecc6 is described below

commit 2beecc632edae82661767c07a28ef06934814c0b
Author: Tibor17 <tibordigana@apache.org>
AuthorDate: Tue Aug 14 23:37:13 2018 +0200

    [SUREFIRE-1552] Nil element "failureMessage" in failsafe-summary.xml should have self
closed tag
---
 .../failsafe/util/FailsafeSummaryXmlUtils.java     | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java
b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java
index d06da13..2e033f1 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java
@@ -35,6 +35,7 @@ import java.util.Locale;
 
 import static java.lang.Boolean.parseBoolean;
 import static java.lang.Integer.parseInt;
+import static java.lang.String.format;
 import static org.apache.commons.lang3.StringEscapeUtils.escapeXml10;
 import static org.apache.commons.lang3.StringEscapeUtils.unescapeXml;
 import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
@@ -49,8 +50,11 @@ public final class FailsafeSummaryXmlUtils
     private static final String FAILSAFE_SUMMARY_XML_SCHEMA_LOCATION =
             "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/failsafe-summary.xsd";
 
-    private static final String FAILSAFE_SUMMARY_XML_NIL_ATTR =
-            " xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
+    private static final String MESSAGE_NIL_ELEMENT =
+            "<failureMessage xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>";
+
+    private static final String MESSAGE_ELEMENT =
+            "<failureMessage>%s</failureMessage>";
 
     private static final String FAILSAFE_SUMMARY_XML_TEMPLATE =
             "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
@@ -61,7 +65,7 @@ public final class FailsafeSummaryXmlUtils
                     + "    <errors>%d</errors>\n"
                     + "    <failures>%d</failures>\n"
                     + "    <skipped>%d</skipped>\n"
-                    + "    <failureMessage%s>%s</failureMessage>\n"
+                    + "    %s\n"
                     + "</failsafe-summary>";
 
     private FailsafeSummaryXmlUtils()
@@ -102,16 +106,15 @@ public final class FailsafeSummaryXmlUtils
             throws IOException
     {
         String failure = fromRunResult.getFailure();
-        String xml = String.format( Locale.ROOT, FAILSAFE_SUMMARY_XML_TEMPLATE,
-                                          fromRunResult.getFailsafeCode(),
-                                          String.valueOf( fromRunResult.isTimeout() ),
-                                          fromRunResult.getCompletedCount(),
-                                          fromRunResult.getErrors(),
-                                          fromRunResult.getFailures(),
-                                          fromRunResult.getSkipped(),
-                                          isBlank( failure ) ? FAILSAFE_SUMMARY_XML_NIL_ATTR
: "",
-                                          isBlank( failure ) ? "" : escapeXml10( failure
)
-        );
+        String msg = isBlank( failure ) ? MESSAGE_NIL_ELEMENT : format( MESSAGE_ELEMENT,
escapeXml10( failure ) );
+        String xml = format( Locale.ROOT, FAILSAFE_SUMMARY_XML_TEMPLATE,
+                fromRunResult.getFailsafeCode(),
+                String.valueOf( fromRunResult.isTimeout() ),
+                fromRunResult.getCompletedCount(),
+                fromRunResult.getErrors(),
+                fromRunResult.getFailures(),
+                fromRunResult.getSkipped(),
+                msg );
 
         FileOutputStream os = new FileOutputStream( toFailsafeSummaryXml );
         try


Mime
View raw message