You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mf...@apache.org on 2016/01/13 07:06:14 UTC

[14/15] maven-surefire git commit: SUREFIRE-1217: Create FailsafeStatelessXmlReporter.

SUREFIRE-1217: Create FailsafeStatelessXmlReporter.


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/c78d238a
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/c78d238a
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/c78d238a

Branch: refs/heads/SUREFIRE-1217
Commit: c78d238aa37c9bb7d863082ad7a139251731ca4f
Parents: 8b59849
Author: Mirko Friedenhagen <mf...@apache.org>
Authored: Sun Jan 10 21:28:29 2016 +0100
Committer: Mirko Friedenhagen <mf...@apache.org>
Committed: Wed Jan 13 07:05:33 2016 +0100

----------------------------------------------------------------------
 .../report/FailsafeStatelessXmlReporter.java    | 39 ++++++++++++++++++++
 .../surefire/report/StatelessXmlReporter.java   | 20 ++++++++--
 .../report/StatelessXmlReporterTest.java        |  8 +++-
 3 files changed, 62 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c78d238a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FailsafeStatelessXmlReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FailsafeStatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FailsafeStatelessXmlReporter.java
new file mode 100644
index 0000000..5689aaf
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FailsafeStatelessXmlReporter.java
@@ -0,0 +1,39 @@
+package org.apache.maven.plugin.surefire.report;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Extension of {@link StatelessXmlReporter} for the maven-failsafe-plugin.
+ *
+ * @since 2.19.2
+ */
+public class FailsafeStatelessXmlReporter extends StatelessXmlReporter {
+
+    static final String FAILSAFE_TEST_REPORT_XSD = "https://maven.apache.org/surefire/maven-failsafe-plugin/xsd/failsafe-test-report.xsd";
+
+    public FailsafeStatelessXmlReporter(File reportsDirectory, String reportNameSuffix, boolean trimStackTrace, int rerunFailingTestsCount, Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistoryMap) {
+        super(reportsDirectory, reportNameSuffix, trimStackTrace, rerunFailingTestsCount, testClassMethodRunHistoryMap,
+                FAILSAFE_TEST_REPORT_XSD);
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c78d238a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index 3305c5b..bff5620 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -86,6 +86,8 @@ public class StatelessXmlReporter
 
     private static final Charset ENCODING_CS = Charset.forName( ENCODING );
 
+    static final String SUREFIRE_TEST_REPORT_XSD = "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd";
+
     private final File reportsDirectory;
 
     private final String reportNameSuffix;
@@ -98,15 +100,27 @@ public class StatelessXmlReporter
     // and the list of runs for each test method
     private final Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistoryMap;
 
+    final String testReportXsd;
+
     public StatelessXmlReporter( File reportsDirectory, String reportNameSuffix, boolean trimStackTrace,
                                  int rerunFailingTestsCount,
                                  Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistoryMap )
     {
+        this( reportsDirectory, reportNameSuffix, trimStackTrace, rerunFailingTestsCount,
+                testClassMethodRunHistoryMap, SUREFIRE_TEST_REPORT_XSD);
+    }
+
+    StatelessXmlReporter( File reportsDirectory, String reportNameSuffix, boolean trimStackTrace,
+                                 int rerunFailingTestsCount,
+                                 Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistoryMap,
+                                 String testReportXsd )
+    {
         this.reportsDirectory = reportsDirectory;
         this.reportNameSuffix = reportNameSuffix;
         this.trimStackTrace = trimStackTrace;
         this.rerunFailingTestsCount = rerunFailingTestsCount;
         this.testClassMethodRunHistoryMap = testClassMethodRunHistoryMap;
+        this.testReportXsd = testReportXsd;
     }
 
     public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStats testSetStats )
@@ -129,7 +143,7 @@ public class StatelessXmlReporter
             ppw.setEncoding( ENCODING );
 
             createTestSuiteElement( ppw, testSetReportEntry, testSetStats, reportNameSuffix,
-                                    testSetReportEntry.elapsedTimeAsString() );
+                                    testSetReportEntry.elapsedTimeAsString(), testReportXsd );
 
             showProperties( ppw );
 
@@ -348,14 +362,14 @@ public class StatelessXmlReporter
     }
 
     private static void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, TestSetStats testSetStats,
-                                                String reportNameSuffix1, String timeAsString )
+                                                String reportNameSuffix1, String timeAsString, String testReportXsd )
     {
         ppw.startElement( "testsuite" );
 
         ppw.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
 
         ppw.addAttribute( "xsi:noNamespaceSchemaLocation",
-                          "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" );
+                        testReportXsd );
 
         ppw.addAttribute( "name", report.getReportName( reportNameSuffix1 ) );
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c78d238a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
index 09fa1d1..643a291 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
@@ -84,8 +84,7 @@ public class StatelessXmlReporterTest
     public void testFileNameWithoutSuffix()
     {
         StatelessXmlReporter reporter =
-            new StatelessXmlReporter( reportDir, null, false, 0,
-                                      new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>() );
+                createStatelessXmlReporter();
         reporter.cleanTestHistoryMap();
 
         ReportEntry reportEntry = new SimpleReportEntry( getClass().getName(), getClass().getName(), 12 );
@@ -99,6 +98,11 @@ public class StatelessXmlReporterTest
                     expectedReportFile.exists() );
     }
 
+    StatelessXmlReporter createStatelessXmlReporter() {
+        return new StatelessXmlReporter( reportDir, null, false, 0,
+                                  new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>() );
+    }
+
 
     public void testAllFieldsSerialized()
         throws IOException