You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2016/01/17 23:11:57 UTC
[2/4] maven-surefire git commit: [SUREFIRE-1217] Differentiate XML
schema for failsafe and surefire
[SUREFIRE-1217] Differentiate XML schema for failsafe and surefire
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/71b00149
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/71b00149
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/71b00149
Branch: refs/heads/3.0-rc1
Commit: 71b00149392475a43bef2f0e618e3f5b5a64cdaa
Parents: cfb6177
Author: Tibor17 <ti...@lycos.com>
Authored: Sat Jan 16 09:55:44 2016 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sat Jan 16 09:55:44 2016 +0100
----------------------------------------------------------------------
maven-failsafe-plugin/pom.xml | 20 ++++++++++++
.../plugin/failsafe/IntegrationTestMojo.java | 6 ++++
.../plugin/surefire/AbstractSurefireMojo.java | 5 ++-
.../maven/plugin/surefire/CommonReflector.java | 8 ++---
.../surefire/StartupReportConfiguration.java | 34 ++++++++++++++------
.../surefire/report/DefaultReporterFactory.java | 8 +++--
.../surefire/report/StatelessXmlReporter.java | 19 +++++------
.../report/DefaultReporterFactoryTest.java | 2 +-
.../report/StatelessXmlReporterTest.java | 26 +++++++--------
.../maven/plugin/surefire/SurefirePlugin.java | 6 ++++
maven-surefire-plugin/src/site/apt/index.apt.vm | 3 +-
11 files changed, 94 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-failsafe-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index 8c56890..06c8e95 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -174,6 +174,26 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <id>generate-test-report</id>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target name="generate-failsafe-test-report">
+ <move file="${project.build.directory}/source-site/resources/xsd/surefire-test-report.xsd"
+ tofile="${project.build.directory}/source-site/resources/xsd/failsafe-test-report.xsd"/>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<siteDirectory>${project.build.directory}/source-site</siteDirectory>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index fd744fe..bf50fec 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -390,6 +390,12 @@ public class IntegrationTestMojo
return new String[]{ "**/IT*.java", "**/*IT.java", "**/*ITCase.java" };
}
+ @Override
+ protected String getReportSchemaLocation()
+ {
+ return "https://maven.apache.org/surefire/maven-failsafe-plugin/xsd/failsafe-test-report.xsd";
+ }
+
public boolean isSkipTests()
{
return skipTests;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 111c9c5..eaa01a8 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -720,6 +720,8 @@ public abstract class AbstractSurefireMojo
protected abstract String[] getDefaultIncludes();
+ protected abstract String getReportSchemaLocation();
+
private String getDefaultExcludes()
{
return "**/*$*";
@@ -1599,7 +1601,8 @@ public abstract class AbstractSurefireMojo
return new StartupReportConfiguration( isUseFile(), isPrintSummary(), getReportFormat(),
isRedirectTestOutputToFile(), isDisableXmlReport(),
getReportsDirectory(), isTrimStackTrace(), getReportNameSuffix(),
- configChecksum, requiresRunHistory(), getRerunFailingTestsCount() );
+ configChecksum, requiresRunHistory(), getRerunFailingTestsCount(),
+ getReportSchemaLocation() );
}
private boolean isSpecificTestSpecified()
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
index a8be45b..06ec9a5 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
@@ -59,21 +59,21 @@ public class CommonReflector
surefireClassLoader );
}
-
- Object createStartupReportConfiguration( @Nonnull StartupReportConfiguration reporterConfiguration )
+ private Object createStartupReportConfiguration( @Nonnull StartupReportConfiguration reporterConfiguration )
{
Constructor<?> constructor = ReflectionUtils.getConstructor( startupReportConfiguration,
boolean.class, boolean.class,
String.class, boolean.class, boolean.class,
File.class, boolean.class, String.class,
- String.class, boolean.class, int.class );
+ String.class, boolean.class, int.class,
+ String.class );
//noinspection BooleanConstructorCall
Object[] params = { reporterConfiguration.isUseFile(), reporterConfiguration.isPrintSummary(),
reporterConfiguration.getReportFormat(), reporterConfiguration.isRedirectTestOutputToFile(),
reporterConfiguration.isDisableXmlReport(), reporterConfiguration.getReportsDirectory(),
reporterConfiguration.isTrimStackTrace(), reporterConfiguration.getReportNameSuffix(),
reporterConfiguration.getConfigurationHash(), reporterConfiguration.isRequiresRunHistory(),
- reporterConfiguration.getRerunFailingTestsCount() };
+ reporterConfiguration.getRerunFailingTestsCount(), reporterConfiguration.getXsdSchemaLocation() };
return ReflectionUtils.newInstance( constructor, params );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
index 5717f70..f45b303 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
@@ -45,6 +45,10 @@ import javax.annotation.Nonnull;
*/
public class StartupReportConfiguration
{
+ public static final String BRIEF_REPORT_FORMAT = ConsoleReporter.BRIEF;
+
+ public static final String PLAIN_REPORT_FORMAT = ConsoleReporter.PLAIN;
+
private final PrintStream originalSystemOut;
private final PrintStream originalSystemErr;
@@ -71,13 +75,11 @@ public class StartupReportConfiguration
private final int rerunFailingTestsCount;
- private final Properties testVmSystemProperties = new Properties();
-
- public static final String BRIEF_REPORT_FORMAT = ConsoleReporter.BRIEF;
+ private String xsdSchemaLocation;
- public static final String PLAIN_REPORT_FORMAT = ConsoleReporter.PLAIN;
+ private final Properties testVmSystemProperties = new Properties();
- private final Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistoryMap
+ private final Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistory
= new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>();
@SuppressWarnings( "checkstyle:parameternumber" )
@@ -85,7 +87,7 @@ public class StartupReportConfiguration
boolean redirectTestOutputToFile, boolean disableXmlReport,
@Nonnull File reportsDirectory, boolean trimStackTrace, String reportNameSuffix,
String configurationHash, boolean requiresRunHistory,
- int rerunFailingTestsCount )
+ int rerunFailingTestsCount, String xsdSchemaLocation )
{
this.useFile = useFile;
this.printSummary = printSummary;
@@ -100,20 +102,27 @@ public class StartupReportConfiguration
this.originalSystemOut = System.out;
this.originalSystemErr = System.err;
this.rerunFailingTestsCount = rerunFailingTestsCount;
+ this.xsdSchemaLocation = xsdSchemaLocation;
}
+ /**
+ * For testing purposes only.
+ */
public static StartupReportConfiguration defaultValue()
{
File target = new File( "./target" );
return new StartupReportConfiguration( true, true, "PLAIN", false, false, target, false, null, "TESTHASH",
- false, 0 );
+ false, 0, null );
}
+ /**
+ * For testing purposes only.
+ */
public static StartupReportConfiguration defaultNoXml()
{
File target = new File( "./target" );
return new StartupReportConfiguration( true, true, "PLAIN", false, true, target, false, null, "TESTHASHxXML",
- false, 0 );
+ false, 0, null );
}
public boolean isUseFile()
@@ -160,8 +169,8 @@ public class StartupReportConfiguration
{
return isDisableXmlReport()
? null
- : new StatelessXmlReporter( reportsDirectory, reportNameSuffix, trimStackTrace,
- rerunFailingTestsCount, testClassMethodRunHistoryMap );
+ : new StatelessXmlReporter( reportsDirectory, reportNameSuffix, trimStackTrace, rerunFailingTestsCount,
+ testClassMethodRunHistory, xsdSchemaLocation );
}
public FileReporter instantiateFileReporter()
@@ -228,4 +237,9 @@ public class StartupReportConfiguration
{
return originalSystemOut;
}
+
+ public String getXsdSchemaLocation()
+ {
+ return xsdSchemaLocation;
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
index 13bcc96..dbb78d7 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
@@ -36,6 +36,8 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentLinkedQueue;
+import static org.apache.maven.plugin.surefire.report.ConsoleReporter.PLAIN;
+
/**
* Provides reporting modules on the plugin side.
* <p/>
@@ -46,7 +48,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
public class DefaultReporterFactory
implements ReporterFactory
{
-
private RunStatistics globalStats = new RunStatistics();
private final StartupReportConfiguration reportConfiguration;
@@ -78,7 +79,7 @@ public class DefaultReporterFactory
reportConfiguration.instantiateStatelessXmlReporter(),
reportConfiguration.instantiateConsoleOutputFileReporter(), statisticsReporter,
reportConfiguration.isTrimStackTrace(),
- ConsoleReporter.PLAIN.equals( reportConfiguration.getReportFormat() ),
+ PLAIN.equals( reportConfiguration.getReportFormat() ),
reportConfiguration.isBriefOrPlainFormat() );
addListener( testSetRunListener );
return testSetRunListener;
@@ -151,6 +152,9 @@ public class DefaultReporterFactory
return globalStats;
}
+ /**
+ * For testing purposes only.
+ */
public static DefaultReporterFactory defaultNoXml()
{
return new DefaultReporterFactory( StartupReportConfiguration.defaultNoXml() );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/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..9e22f1e 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
@@ -94,19 +94,23 @@ public class StatelessXmlReporter
private final int rerunFailingTestsCount;
+ private final String xsdSchemaLocation;
+
// Map between test class name and a map between test method name
// and the list of runs for each test method
private final Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistoryMap;
public StatelessXmlReporter( File reportsDirectory, String reportNameSuffix, boolean trimStackTrace,
int rerunFailingTestsCount,
- Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistoryMap )
+ Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistoryMap,
+ String xsdSchemaLocation )
{
this.reportsDirectory = reportsDirectory;
this.reportNameSuffix = reportNameSuffix;
this.trimStackTrace = trimStackTrace;
this.rerunFailingTestsCount = rerunFailingTestsCount;
this.testClassMethodRunHistoryMap = testClassMethodRunHistoryMap;
+ this.xsdSchemaLocation = xsdSchemaLocation;
}
public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStats testSetStats )
@@ -128,8 +132,7 @@ public class StatelessXmlReporter
XMLWriter ppw = new PrettyPrintXMLWriter( fw );
ppw.setEncoding( ENCODING );
- createTestSuiteElement( ppw, testSetReportEntry, testSetStats, reportNameSuffix,
- testSetReportEntry.elapsedTimeAsString() );
+ createTestSuiteElement( ppw, testSetReportEntry, testSetStats, testSetReportEntry.elapsedTimeAsString() );
showProperties( ppw );
@@ -347,17 +350,15 @@ public class StatelessXmlReporter
ppw.addAttribute( "time", timeAsString );
}
- private static void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, TestSetStats testSetStats,
- String reportNameSuffix1, String timeAsString )
+ private void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, TestSetStats testSetStats,
+ String timeAsString )
{
ppw.startElement( "testsuite" );
ppw.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
+ ppw.addAttribute( "xsi:noNamespaceSchemaLocation", xsdSchemaLocation );
- ppw.addAttribute( "xsi:noNamespaceSchemaLocation",
- "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" );
-
- ppw.addAttribute( "name", report.getReportName( reportNameSuffix1 ) );
+ ppw.addAttribute( "name", report.getReportName( reportNameSuffix ) );
if ( report.getGroup() != null )
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
index c71611d..090a11b 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
@@ -62,7 +62,7 @@ public class DefaultReporterFactoryTest
public void testMergeTestHistoryResult()
{
StartupReportConfiguration reportConfig = new StartupReportConfiguration( true, true, "PLAIN", false, false, new File("target"), false, null, "TESTHASH",
- false, 1 );
+ false, 1, null );
DefaultReporterFactory factory = new DefaultReporterFactory( reportConfig );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/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 e82515e..5b649e3 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
@@ -43,19 +43,18 @@ import java.util.concurrent.atomic.AtomicInteger;
public class StatelessXmlReporterTest
extends TestCase
{
- private TestSetStats stats;
-
- private TestSetStats rerunStats;
-
- private File expectedReportFile;
-
- private File reportDir;
-
+ private static final String XSD =
+ "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd";
private final static String TEST_ONE = "aTestMethod";
private final static String TEST_TWO = "bTestMethod";
private final static String TEST_THREE = "cTestMethod";
private static final AtomicInteger FOLDER_POSTFIX = new AtomicInteger();
+ private TestSetStats stats;
+ private TestSetStats rerunStats;
+ private File expectedReportFile;
+ private File reportDir;
+
@Override
protected void setUp()
throws Exception
@@ -85,7 +84,7 @@ public class StatelessXmlReporterTest
{
StatelessXmlReporter reporter =
new StatelessXmlReporter( reportDir, null, false, 0,
- new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>() );
+ new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>(), XSD );
reporter.cleanTestHistoryMap();
ReportEntry reportEntry = new SimpleReportEntry( getClass().getName(), getClass().getName(), 12 );
@@ -138,7 +137,7 @@ public class StatelessXmlReporterTest
stats.testSucceeded( t2 );
StatelessXmlReporter reporter = new StatelessXmlReporter( reportDir, null, false, 0,
- new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>() );
+ new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>(), XSD );
reporter.testSetCompleted( testSetReportEntry, stats );
FileInputStream fileInputStream = new FileInputStream( expectedReportFile );
@@ -217,11 +216,8 @@ public class StatelessXmlReporterTest
rerunStats.testSucceeded( testThreeSecondRun );
StatelessXmlReporter reporter =
- new StatelessXmlReporter( reportDir,
- null,
- false,
- 1,
- new HashMap<String, Map<String, List<WrappedReportEntry>>>() );
+ new StatelessXmlReporter( reportDir, null, false, 1,
+ new HashMap<String, Map<String, List<WrappedReportEntry>>>(), XSD );
reporter.testSetCompleted( testSetReportEntry, stats );
reporter.testSetCompleted( testSetReportEntry, rerunStats );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 7d8044e..52a6210 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -344,6 +344,12 @@ public class SurefirePlugin
return new String[]{ "**/Test*.java", "**/*Test.java", "**/*TestCase.java" };
}
+ @Override
+ protected String getReportSchemaLocation()
+ {
+ return "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd";
+ }
+
// now for the implementation of the field accessors
public boolean isSkipTests()
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/71b00149/maven-surefire-plugin/src/site/apt/index.apt.vm
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/apt/index.apt.vm b/maven-surefire-plugin/src/site/apt/index.apt.vm
index 9c7ef2f..2a3d670 100644
--- a/maven-surefire-plugin/src/site/apt/index.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/index.apt.vm
@@ -79,7 +79,8 @@ mvn verify
By default, these files are generated at <<<$\{basedir\}/target/${thisPlugin.toLowerCase()}-reports>>>.
- The schema for the Surefire XML reports is available at {{{./xsd/surefire-test-report.xsd}Surefire XML Report Schema}}.
+ The schema for the ${thisPlugin} XML reports is available at
+ {{{./xsd/${thisPlugin.toLowerCase()}-test-report.xsd}${thisPlugin} XML Report Schema}}.
For an HTML format of the report, please see the
{{{http://maven.apache.org/plugins/maven-surefire-report-plugin/}Maven Surefire Report Plugin}}.