diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index 087d860e72..0838809f8d 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -46,7 +46,7 @@ - 1.11.1 + 2.0.0-M8 1.0.0.v20140518 @@ -89,10 +89,12 @@ org.apache.maven.reporting maven-reporting-api + 4.0.0-M8 org.apache.maven.reporting maven-reporting-impl + 4.0.0-M11 org.codehaus.plexus diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReport.java similarity index 97% rename from maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java rename to maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReport.java index 3ec4928f93..a12949af65 100644 --- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java +++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReport.java @@ -55,7 +55,7 @@ * * @author Stephen Connolly */ -public abstract class AbstractSurefireReportMojo extends AbstractMavenReport { +public abstract class AbstractSurefireReport extends AbstractMavenReport { /** * If set to false, only failures are shown. @@ -77,12 +77,6 @@ public abstract class AbstractSurefireReportMojo extends AbstractMavenReport { @Parameter private File reportsDirectory; - /** - * The projects in the reactor for aggregation report. - */ - @Parameter(defaultValue = "${reactorProjects}", readonly = true) - private List reactorProjects; - /** * Location of the Xrefs to link. */ @@ -155,9 +149,9 @@ public void executeReport(Locale locale) throws MavenReportException { getI18Nsection(), locale, getConsoleLogger(), - showSuccess, getReportsDirectories(), - determineXrefLocation()); + determineXrefLocation(), + showSuccess); r.render(); } @@ -262,7 +256,8 @@ private String determineXrefLocation() { String location = null; if (linkXRef) { - String relativePath = PathTool.getRelativePath(getOutputDirectory(), xrefLocation.getAbsolutePath()); + String relativePath = PathTool.getRelativePath( + getReportOutputDirectory().getAbsolutePath(), xrefLocation.getAbsolutePath()); if (relativePath == null || relativePath.isEmpty()) { relativePath = "."; } @@ -345,6 +340,10 @@ protected MavenProject getProject() { return project; } + protected List getReactorProjects() { + return reactorProjects; + } + // TODO Review, especially Locale.getDefault() private static class CustomI18N implements I18N { private final MavenProject project; diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeReportMojo.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeOnlyReport.java similarity index 92% rename from maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeReportMojo.java rename to maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeOnlyReport.java index 9e889cd664..ae2b620789 100644 --- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeReportMojo.java +++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeOnlyReport.java @@ -35,12 +35,12 @@ */ @Mojo(name = "failsafe-report-only") @SuppressWarnings("unused") -public class FailsafeReportMojo extends AbstractSurefireReportMojo { +public class FailsafeOnlyReport extends AbstractSurefireReport { /** * The filename to use for the report. */ - @Parameter(defaultValue = "failsafe-report", property = "outputName", required = true) + @Parameter(defaultValue = "failsafe", property = "outputName", required = true) private String outputName; /** @@ -61,7 +61,7 @@ public class FailsafeReportMojo extends AbstractSurefireReportMojo { @Override protected File getSurefireReportsDirectory(MavenProject subProject) { String buildDir = subProject.getBuild().getDirectory(); - return new File(buildDir + "/failsafe-reports"); + return new File(buildDir, "failsafe-reports"); } @Override diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportOnlyMojo.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireOnlyReport.java similarity index 95% rename from maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportOnlyMojo.java rename to maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireOnlyReport.java index ec60196e33..d523e97697 100644 --- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportOnlyMojo.java +++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireOnlyReport.java @@ -34,4 +34,4 @@ @Mojo(name = "report-only") @Execute(phase = LifecyclePhase.NONE) @SuppressWarnings("unused") -public class SurefireReportOnlyMojo extends SurefireReportMojo {} +public class SurefireOnlyReport extends SurefireReport {} diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReport.java similarity index 94% rename from maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java rename to maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReport.java index 78a096fd79..1405ba9c9c 100644 --- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java +++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReport.java @@ -34,12 +34,12 @@ @Mojo(name = "report", inheritByDefault = false) @Execute(lifecycle = "surefire", phase = LifecyclePhase.TEST) @SuppressWarnings("unused") -public class SurefireReportMojo extends AbstractSurefireReportMojo { +public class SurefireReport extends AbstractSurefireReport { /** * The filename to use for the report. */ - @Parameter(defaultValue = "surefire-report", property = "outputName", required = true) + @Parameter(defaultValue = "surefire", property = "outputName", required = true) private String outputName; /** diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportRenderer.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportRenderer.java index e19c2bca28..c9dafe73fa 100644 --- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportRenderer.java +++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportRenderer.java @@ -50,9 +50,9 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer { private final Locale locale; private final SurefireReportParser parser; - private final boolean showSuccess; - private final String xrefLocation; private final List testSuites; + private final String xrefLocation; + private final boolean showSuccess; public SurefireReportRenderer( Sink sink, @@ -60,9 +60,9 @@ public SurefireReportRenderer( String i18nSection, Locale locale, ConsoleLogger consoleLogger, - boolean showSuccess, List reportsDirectories, - String xrefLocation) { + String xrefLocation, + boolean showSuccess) { super(sink); this.i18n = i18n; this.i18nSection = i18nSection; @@ -112,11 +112,7 @@ private String formatI18nString(String section, String key, Object... args) { public void renderBody() { javaScript(javascriptToggleDisplayCode()); - sink.section1(); - sink.sectionTitle1(); - sink.text(getTitle()); - sink.sectionTitle1_(); - sink.section1_(); + startSection(getTitle()); renderSectionSummary(); @@ -125,16 +121,14 @@ public void renderBody() { renderSectionTestCases(); renderSectionFailureDetails(); + + endSection(); } private void renderSectionSummary() { Map summary = parser.getSummary(testSuites); - sink.section1(); - sinkAnchor("Summary"); - sink.sectionTitle1(); - sink.text(getI18nString("surefire", "label.summary")); - sink.sectionTitle1_(); + startSection(getI18nString("surefire", "label.summary"), "Summary"); constructHotLinks(); @@ -168,7 +162,7 @@ private void renderSectionSummary() { sink.lineBreak(); - sink.section1_(); + endSection(); } private void renderSectionPackages() { @@ -177,11 +171,7 @@ private void renderSectionPackages() { return; } - sink.section1(); - sinkAnchor("Package_List"); - sink.sectionTitle1(); - sink.text(getI18nString("surefire", "label.packagelist")); - sink.sectionTitle1_(); + startSection(getI18nString("surefire", "label.packagelist"), "Package_List"); constructHotLinks(); @@ -227,11 +217,7 @@ private void renderSectionPackages() { List testSuiteList = entry.getValue(); - sink.section2(); - sinkAnchor(packageName); - sink.sectionTitle2(); - sink.text(packageName); - sink.sectionTitle2_(); + startSection(packageName); boolean showTable = false; @@ -266,12 +252,12 @@ private void renderSectionPackages() { endTable(); } - sink.section2_(); + endSection(); } sink.lineBreak(); - sink.section1_(); + endSection(); } private void renderSectionTestSuite(ReportTestSuite suite) { @@ -320,11 +306,7 @@ private void renderSectionTestCases() { return; } - sink.section1(); - sinkAnchor("Test_Cases"); - sink.sectionTitle1(); - sink.text(getI18nString("surefire", "label.testcases")); - sink.sectionTitle1_(); + startSection(getI18nString("surefire", "label.testcases"), "Test_Cases"); constructHotLinks(); @@ -332,11 +314,7 @@ private void renderSectionTestCases() { List testCases = suite.getTestCases(); if (!testCases.isEmpty()) { - sink.section2(); - sinkAnchor(suite.getPackageName() + '.' + suite.getName()); - sink.sectionTitle2(); - sink.text(suite.getName()); - sink.sectionTitle2_(); + startSection(suite.getName(), suite.getPackageName() + '.' + suite.getName()); boolean showTable = false; @@ -360,13 +338,13 @@ private void renderSectionTestCases() { endTable(); } - sink.section2_(); + endSection(); } } sink.lineBreak(); - sink.section1_(); + endSection(); } private void constructTestCaseSection(ReportTestCase testCase) { @@ -469,7 +447,7 @@ private void constructTestCaseSection(ReportTestCase testCase) { } private String toHtmlId(String id) { - return DoxiaUtils.isValidId(id) ? id : DoxiaUtils.encodeId(id, true); + return DoxiaUtils.isValidId(id) ? id : DoxiaUtils.encodeId(id); } private void renderSectionFailureDetails() { @@ -478,11 +456,7 @@ private void renderSectionFailureDetails() { return; } - sink.section1(); - sinkAnchor("Failure_Details"); - sink.sectionTitle1(); - sink.text(getI18nString("surefire", "label.failuredetails")); - sink.sectionTitle1_(); + startSection(getI18nString("surefire", "label.failuredetails"), "Failure_Details"); constructHotLinks(); @@ -554,7 +528,7 @@ private void renderSectionFailureDetails() { sink.lineBreak(); - sink.section1_(); + endSection(); } private void constructHotLinks() { diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java index 74df21fec5..fc1eaefd35 100644 --- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java @@ -34,7 +34,7 @@ public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(new JUnit4TestAdapter(Surefire597Test.class)); suite.addTest(new JUnit4TestAdapter(SurefireSchemaValidationTest.class)); - suite.addTestSuite(SurefireReportMojoTest.class); + suite.addTestSuite(SurefireReportTest.class); return suite; } } diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java index 598c916785..b1a9ddb890 100644 --- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java @@ -48,12 +48,12 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws i18n.initialize(); ConsoleLogger consoleLogger = new NullConsoleLogger(); SurefireReportRenderer r = new SurefireReportRenderer( - sink, i18n, "surefire", SiteTool.DEFAULT_LOCALE, consoleLogger, true, singletonList(report), null); + sink, i18n, "surefire", SiteTool.DEFAULT_LOCALE, consoleLogger, singletonList(report), null, true); r.render(); String xml = writer.toString(); assertThat( xml, - containsString(toSystemNewLine("\n" + containsString(toSystemNewLine("
\n" + "\n" + "\n" + "\n" @@ -62,7 +62,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws + "\n" + "\n" + "\n" - + "\n" + + "\n" + "\n" + "\n" + "\n" @@ -72,7 +72,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws + "
TestsErrorsSuccess RateTime
11100
"))); assertThat( xml, - containsString(toSystemNewLine("\n" + containsString(toSystemNewLine("
\n" + "\n" + "\n" + "\n" @@ -82,7 +82,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws + "\n" + "\n" + "\n" - + "\n" + + "\n" + "\n" + "\n" + "\n" @@ -91,7 +91,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws + "
PackageTestsSuccess RateTime
surefiresurefire1100 s
"))); assertThat( xml, - containsString(toSystemNewLine("\n" + containsString(toSystemNewLine("
\n" + "\n" + "\n" + "\n" @@ -102,7 +102,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws + "\n" + "\n" + "\n" - + "\n" + + "\n" + "\n" + "\n" + "\n" @@ -112,15 +112,15 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws + "
-ClassSuccess RateTime
\"\"MyTest110 s
"))); assertThat( xml, - containsString(toSystemNewLine("\n" + containsString(toSystemNewLine("
\n" + "\n" - + "\n" + + "\n" + "\n" + "\n" - + "\n" + + "\n" + "\n" + "\n" - + "\n" + + "\n" + "
\"\"test
--java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: msg
--\n" + "
surefire.MyTest:13
"))); } diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportTest.java similarity index 87% rename from maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java rename to maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportTest.java index 8dab21e862..1f42a6076a 100644 --- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportTest.java @@ -19,16 +19,19 @@ package org.apache.maven.plugins.surefire.report; import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLDecoder; -import java.util.Locale; +import java.util.Collections; +import java.util.List; +import org.apache.maven.model.Plugin; import org.apache.maven.plugin.LegacySupport; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.ArtifactStubFactory; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.plugins.surefire.report.stubs.DependencyArtifactStubFactory; +import org.apache.maven.project.MavenProject; import org.apache.maven.shared.utils.io.FileUtils; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; @@ -42,31 +45,23 @@ * @author Allan Ramirez */ @SuppressWarnings("checkstyle:linelength") -public class SurefireReportMojoTest extends AbstractMojoTestCase { +public class SurefireReportTest extends AbstractMojoTestCase { private ArtifactStubFactory artifactStubFactory; - // Can be removed with Doxia 2.0.0 - private Locale origLocale; - @Override protected void setUp() throws Exception { super.setUp(); artifactStubFactory = new DependencyArtifactStubFactory(getTestFile("target"), true, false); artifactStubFactory.getWorkingDir().mkdirs(); - - origLocale = Locale.getDefault(); - Locale.setDefault(Locale.ROOT); } - @Override - protected void tearDown() throws Exception { - Locale.setDefault(origLocale); - super.tearDown(); + protected File getPluginXmlFile(String projectDirName) { + return new File(getBasedir(), "src/test/resources/unit/" + projectDirName + "/plugin-config.xml"); } - protected SurefireReportMojo createReportMojo(File pluginXmlFile) throws Exception { - SurefireReportMojo mojo = (SurefireReportMojo) lookupMojo("report", pluginXmlFile); - assertNotNull("Mojo found.", mojo); + protected SurefireReport createReportMojo(File pluginXmlFile) throws Exception { + SurefireReport mojo = (SurefireReport) lookupMojo("report", pluginXmlFile); + assertNotNull("Mojo not found.", mojo); LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(newMavenSession(new MavenProjectStub())); @@ -75,18 +70,26 @@ protected SurefireReportMojo createReportMojo(File pluginXmlFile) throws Excepti repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() .newInstance(repoSession, new LocalRepository(artifactStubFactory.getWorkingDir()))); - // setVariableValueToObject( mojo, "session", legacySupport.getSession() ); - setVariableValueToObject(mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories()); + List reactorProjects = + mojo.getReactorProjects() != null ? mojo.getReactorProjects() : Collections.emptyList(); + + setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution()); + // setVariableValueToObject(mojo, "session", legacySupport.getSession()); + setVariableValueToObject(mojo, "repoSession", legacySupport.getRepositorySession()); + setVariableValueToObject(mojo, "reactorProjects", reactorProjects); + setVariableValueToObject( + mojo, "remoteProjectRepositories", mojo.getProject().getRemoteProjectRepositories()); + setVariableValueToObject( + mojo, "siteDirectory", new File(mojo.getProject().getBasedir(), "src/site")); return mojo; } public void testBasicSurefireReport() throws Exception { - File testPom = new File(getUnitBaseDir(), "basic-surefire-report-test/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("basic-surefire-report-test"); + SurefireReport mojo = createReportMojo(testPom); File outputDir = (File) getVariableValueFromObject(mojo, "outputDirectory"); boolean showSuccess = (Boolean) getVariableValueFromObject(mojo, "showSuccess"); File reportsDir = (File) getVariableValueFromObject(mojo, "reportsDirectory"); - String outputName = (String) getVariableValueFromObject(mojo, "outputName"); File xrefLocation = (File) getVariableValueFromObject(mojo, "xrefLocation"); boolean linkXRef = (Boolean) getVariableValueFromObject(mojo, "linkXRef"); @@ -96,7 +99,6 @@ public void testBasicSurefireReport() throws Exception { new File(getBasedir() + "/src/test/resources/unit/basic-surefire-report-test/surefire-reports") .getAbsolutePath(), reportsDir.getAbsolutePath()); - assertEquals("surefire-report", outputName); assertEquals( new File(getBasedir() + "/target/site/unit/basic-surefire-report-test/xref-test").getAbsolutePath(), xrefLocation.getAbsolutePath()); @@ -111,15 +113,25 @@ public void testBasicSurefireReport() throws Exception { assertTrue(idx >= 0); } - private File getUnitBaseDir() throws UnsupportedEncodingException { - URL resource = getClass().getResource("/unit"); - // URLDecoder.decode necessary for JDK 1.5+, where spaces are escaped to %20 - return new File(URLDecoder.decode(resource.getPath(), "UTF-8")).getAbsoluteFile(); + private MojoExecution getMockMojoExecution() { + MojoDescriptor md = new MojoDescriptor(); + md.setGoal("report"); + + MojoExecution me = new MojoExecution(md); + + PluginDescriptor pd = new PluginDescriptor(); + Plugin p = new Plugin(); + p.setGroupId("org.apache.maven.plugins"); + p.setArtifactId("maven-surefire-report-plugin"); + pd.setPlugin(p); + md.setPluginDescriptor(pd); + + return me; } public void testBasicSurefireReportIfShowSuccessIsFalse() throws Exception { - File testPom = new File(getUnitBaseDir(), "basic-surefire-report-success-false/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("basic-surefire-report-success-false"); + SurefireReport mojo = createReportMojo(testPom); boolean showSuccess = (Boolean) getVariableValueFromObject(mojo, "showSuccess"); assertFalse(showSuccess); mojo.execute(); @@ -133,8 +145,8 @@ public void testBasicSurefireReportIfShowSuccessIsFalse() throws Exception { } public void testBasicSurefireReportIfLinkXrefIsFalse() throws Exception { - File testPom = new File(getUnitBaseDir(), "basic-surefire-report-linkxref-false/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("basic-surefire-report-linkxref-false"); + SurefireReport mojo = createReportMojo(testPom); boolean linkXRef = (Boolean) getVariableValueFromObject(mojo, "linkXRef"); assertFalse(linkXRef); mojo.execute(); @@ -148,8 +160,8 @@ public void testBasicSurefireReportIfLinkXrefIsFalse() throws Exception { } public void testBasicSurefireReportIfReportingIsNull() throws Exception { - File testPom = new File(getUnitBaseDir(), "basic-surefire-report-reporting-null/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("basic-surefire-report-reporting-null"); + SurefireReport mojo = createReportMojo(testPom); mojo.execute(); File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-reporting-null/surefire-report.html"); @@ -162,8 +174,8 @@ public void testBasicSurefireReportIfReportingIsNull() throws Exception { @SuppressWarnings("checkstyle:methodname") public void testBasicSurefireReport_AnchorTestCases() throws Exception { - File testPom = new File(getUnitBaseDir(), "basic-surefire-report-anchor-test-cases/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("basic-surefire-report-anchor-test-cases"); + SurefireReport mojo = createReportMojo(testPom); mojo.execute(); File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-anchor-test-cases/surefire-report.html"); @@ -179,8 +191,8 @@ public void testBasicSurefireReport_AnchorTestCases() throws Exception { } public void testSurefireReportSingleError() throws Exception { - File testPom = new File(getUnitBaseDir(), "surefire-report-single-error/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("surefire-report-single-error"); + SurefireReport mojo = createReportMojo(testPom); mojo.execute(); File report = new File(getBasedir(), "target/site/unit/surefire-report-single-error/surefire-report.html"); assertTrue(report.exists()); @@ -189,7 +201,7 @@ public void testSurefireReportSingleError() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "1\n" + + "1\n" + "1\n" + "0\n" + "0\n" @@ -199,7 +211,7 @@ public void testSurefireReportSingleError() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "surefire\n" + + "surefire\n" + "1\n" + "1\n" + "0\n" @@ -209,9 +221,9 @@ public void testSurefireReportSingleError() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "" + + "" + "" - + "\"\"" + + "" + "" + "\n" + "MyTest\n" @@ -266,8 +278,8 @@ public void testSurefireReportSingleError() throws Exception { } public void testSurefireReportNestedClassTrimStackTrace() throws Exception { - File testPom = new File(getUnitBaseDir(), "surefire-report-nestedClass-trimStackTrace/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("surefire-report-nestedClass-trimStackTrace"); + SurefireReport mojo = createReportMojo(testPom); mojo.execute(); File report = new File( getBasedir(), "target/site/unit/surefire-report-nestedClass-trimStackTrace/surefire-report.html"); @@ -277,7 +289,7 @@ public void testSurefireReportNestedClassTrimStackTrace() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "1\n" + + "1\n" + "1\n" + "0\n" + "0\n" @@ -287,7 +299,7 @@ public void testSurefireReportNestedClassTrimStackTrace() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "surefire\n" + + "surefire\n" + "1\n" + "1\n" + "0\n" @@ -297,9 +309,9 @@ public void testSurefireReportNestedClassTrimStackTrace() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "" + + "" + "" - + "\"\"" + + "" + "" + "\n" + "MyTest\n" @@ -330,8 +342,8 @@ public void testSurefireReportNestedClassTrimStackTrace() throws Exception { } public void testSurefireReportNestedClass() throws Exception { - File testPom = new File(getUnitBaseDir(), "surefire-report-nestedClass/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("surefire-report-nestedClass"); + SurefireReport mojo = createReportMojo(testPom); mojo.execute(); File report = new File(getBasedir(), "target/site/unit/surefire-report-nestedClass/surefire-report.html"); assertTrue(report.exists()); @@ -340,7 +352,7 @@ public void testSurefireReportNestedClass() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "1\n" + + "1\n" + "1\n" + "0\n" + "0\n" @@ -350,7 +362,7 @@ public void testSurefireReportNestedClass() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "surefire\n" + + "surefire\n" + "1\n" + "1\n" + "0\n" @@ -360,9 +372,9 @@ public void testSurefireReportNestedClass() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "" + + "" + "" - + "\"\"" + + "" + "" + "\n" + "MyTest\n" @@ -417,8 +429,8 @@ public void testSurefireReportNestedClass() throws Exception { } public void testSurefireReportEnclosedTrimStackTrace() throws Exception { - File testPom = new File(getUnitBaseDir(), "surefire-report-enclosed-trimStackTrace/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("surefire-report-enclosed-trimStackTrace"); + SurefireReport mojo = createReportMojo(testPom); mojo.execute(); File report = new File(getBasedir(), "target/site/unit/surefire-report-enclosed-trimStackTrace/surefire-report.html"); @@ -428,7 +440,7 @@ public void testSurefireReportEnclosedTrimStackTrace() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "1\n" + + "1\n" + "1\n" + "0\n" + "0\n" @@ -438,7 +450,7 @@ public void testSurefireReportEnclosedTrimStackTrace() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "surefire\n" + + "surefire\n" + "1\n" + "1\n" + "0\n" @@ -448,9 +460,9 @@ public void testSurefireReportEnclosedTrimStackTrace() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "" + + "" + "" - + "\"\"" + + "" + "" + "\n" + "MyTest$A\n" @@ -481,8 +493,8 @@ public void testSurefireReportEnclosedTrimStackTrace() throws Exception { } public void testSurefireReportEnclosed() throws Exception { - File testPom = new File(getUnitBaseDir(), "surefire-report-enclosed/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("surefire-report-enclosed"); + SurefireReport mojo = createReportMojo(testPom); mojo.execute(); File report = new File(getBasedir(), "target/site/unit/surefire-report-enclosed/surefire-report.html"); assertTrue(report.exists()); @@ -491,7 +503,7 @@ public void testSurefireReportEnclosed() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "1\n" + + "1\n" + "1\n" + "0\n" + "0\n" @@ -501,7 +513,7 @@ public void testSurefireReportEnclosed() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "surefire\n" + + "surefire\n" + "1\n" + "1\n" + "0\n" @@ -511,9 +523,9 @@ public void testSurefireReportEnclosed() throws Exception { assertThat( htmlContent, containsString(toSystemNewLine("\n" - + "" + + "" + "" - + "\"\"" + + "" + "" + "\n" + "MyTest$A\n" @@ -578,8 +590,8 @@ public void testSurefireReportEnclosed() throws Exception { } public void testCustomTitleAndDescriptionReport() throws Exception { - File testPom = new File(getUnitBaseDir(), "surefire-1183/plugin-config.xml"); - SurefireReportMojo mojo = createReportMojo(testPom); + File testPom = getPluginXmlFile("surefire-1183"); + SurefireReport mojo = createReportMojo(testPom); File outputDir = (File) getVariableValueFromObject(mojo, "outputDirectory"); String outputName = (String) getVariableValueFromObject(mojo, "outputName"); @@ -599,6 +611,8 @@ public void testCustomTitleAndDescriptionReport() throws Exception { assertTrue(report.exists()); String htmlContent = FileUtils.fileRead(report); - assertTrue(htmlContent.contains("

Acceptance Test

")); + assertThat( + htmlContent, + containsString(toSystemNewLine("
\n

Acceptance Test

"))); } } diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/AnchorTestCasesStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/AnchorTestCasesStub.java new file mode 100644 index 0000000000..3b69f4ba88 --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/AnchorTestCasesStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class AnchorTestCasesStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "basic-surefire-report-anchor-test-cases"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/EnclosedStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/EnclosedStub.java new file mode 100644 index 0000000000..bdcce6b04b --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/EnclosedStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class EnclosedStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "surefire-report-enclosed"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/EnclosedTrimStackTraceStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/EnclosedTrimStackTraceStub.java new file mode 100644 index 0000000000..f5ba0e74b2 --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/EnclosedTrimStackTraceStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class EnclosedTrimStackTraceStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "surefire-report-enclosed-trimStackTrace"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/LinkXrefFalseStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/LinkXrefFalseStub.java new file mode 100644 index 0000000000..7bf7cf44b1 --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/LinkXrefFalseStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class LinkXrefFalseStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "basic-surefire-report-linkxref-false"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/NestedClassStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/NestedClassStub.java new file mode 100644 index 0000000000..6f1547b37c --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/NestedClassStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class NestedClassStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "surefire-report-nestedClass"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/NestedClassTrimStackTraceStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/NestedClassTrimStackTraceStub.java new file mode 100644 index 0000000000..1a30076f59 --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/NestedClassTrimStackTraceStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class NestedClassTrimStackTraceStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "surefire-report-nestedClass-trimStackTrace"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/ReportTestStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/ReportTestStub.java new file mode 100644 index 0000000000..d04125a722 --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/ReportTestStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class ReportTestStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "basic-surefire-report-test"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/ReportingNullStub.java similarity index 86% rename from maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java rename to maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/ReportingNullStub.java index 9365879e4b..86b557ab05 100644 --- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/ReportingNullStub.java @@ -22,12 +22,11 @@ import java.util.List; import org.apache.maven.model.ReportPlugin; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; /** * @author Allan Ramirez */ -public class SurefireRepMavenProjectStub2 extends MavenProjectStub { +public class ReportingNullStub extends SurefireReportMavenProjectStub { /** * {@inheritDoc} */ @@ -35,4 +34,9 @@ public class SurefireRepMavenProjectStub2 extends MavenProjectStub { public List getReportPlugins() { return new ArrayList<>(); } + + @Override + protected String getProjectDirName() { + return "basic-surefire-report-reporting-null"; + } } diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SingleErrorStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SingleErrorStub.java new file mode 100644 index 0000000000..60e83182e7 --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SingleErrorStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class SingleErrorStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "surefire-report-single-error"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SuccessFalseStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SuccessFalseStub.java new file mode 100644 index 0000000000..afe3559512 --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SuccessFalseStub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class SuccessFalseStub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "basic-surefire-report-success-false"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/Surefire1183Stub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/Surefire1183Stub.java new file mode 100644 index 0000000000..e39849618e --- /dev/null +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/Surefire1183Stub.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.maven.plugins.surefire.report.stubs; + +public class Surefire1183Stub extends SurefireReportMavenProjectStub { + + @Override + protected String getProjectDirName() { + return "surefire-1183"; + } +} diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireReportMavenProjectStub.java similarity index 77% rename from maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java rename to maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireReportMavenProjectStub.java index bd4497c243..17b2a95667 100644 --- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireReportMavenProjectStub.java @@ -18,22 +18,37 @@ */ package org.apache.maven.plugins.surefire.report.stubs; +import java.io.File; import java.util.Collections; import java.util.List; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.model.Model; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.Reporting; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.eclipse.aether.repository.RemoteRepository; /** * @author Allan Ramirez */ -public class SurefireRepMavenProjectStub extends MavenProjectStub { +public abstract class SurefireReportMavenProjectStub extends MavenProjectStub { + + protected abstract String getProjectDirName(); + + @Override + public File getBasedir() { + return new File(super.getBasedir() + "/src/test/resources/unit/" + getProjectDirName()); + } + + @Override + public File getFile() { + return new File(getBasedir(), "plugin-config.xml"); + } + /** * {@inheritDoc} */ @@ -47,10 +62,6 @@ public List getReportPlugins() { reportPlugin.setVersion("2.0-SNAPSHOT"); reporting.addPlugin(reportPlugin); - Model model = new Model(); - - model.setReporting(reporting); - return reporting.getPlugins(); } @@ -65,4 +76,9 @@ public List getRemoteArtifactRepositories() { return Collections.singletonList(repository); } + + @Override + public List getRemoteProjectRepositories() { + return RepositoryUtils.toRepos(getRemoteArtifactRepositories()); + } } diff --git a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-anchor-test-cases/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-anchor-test-cases/plugin-config.xml index 3045dce6dc..fe0e78d7f7 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-anchor-test-cases/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-anchor-test-cases/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/basic-surefire-report-anchor-test-cases - ${localRepository} - + true ${basedir}/src/test/resources/unit/basic-surefire-report-anchor-test-cases/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-linkxref-false/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-linkxref-false/plugin-config.xml index e0586aad1d..01f10b34a3 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-linkxref-false/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-linkxref-false/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/basic-surefire-report-linkxref-false - ${localRepository} - + true ${basedir}/src/test/resources/unit/basic-surefire-report-linkxref-false/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-reporting-null/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-reporting-null/plugin-config.xml index 8aca877bd4..f53e5dfea3 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-reporting-null/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-reporting-null/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/basic-surefire-report-reporting-null - ${localRepository} - + true ${basedir}/src/test/resources/unit/basic-surefire-report-reporting-null/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-success-false/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-success-false/plugin-config.xml index c798591122..27d6b2e388 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-success-false/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-success-false/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/basic-surefire-report-success-false - ${localRepository} - + false ${basedir}/src/test/resources/unit/basic-surefire-report-success-false/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-test/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-test/plugin-config.xml index 81e59caf1a..782c972c84 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-test/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/basic-surefire-report-test/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/basic-surefire-report-test - ${localRepository} - + true ${basedir}/src/test/resources/unit/basic-surefire-report-test/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/surefire-1183/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/surefire-1183/plugin-config.xml index 108f583508..c3a82a6884 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/surefire-1183/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/surefire-1183/plugin-config.xml @@ -25,9 +25,8 @@ maven-surefire-report-plugin + implementation="org.apache.maven.plugins.surefire.report.stubs.Surefire1183Stub"/> acceptance-test-report - ${localRepository} ${basedir}/src/test/resources/unit/surefire-1183/src/site/custom/surefire-report.properties ${basedir}/target/site/unit/surefire-1183 ${basedir}/src/test/resources/unit/surefire-1183/acceptancetest-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-enclosed-trimStackTrace/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-enclosed-trimStackTrace/plugin-config.xml index 981bb18824..d02fe60dab 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-enclosed-trimStackTrace/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-enclosed-trimStackTrace/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/surefire-report-enclosed-trimStackTrace - ${localRepository} - + true ${basedir}/src/test/resources/unit/surefire-report-enclosed-trimStackTrace/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-enclosed/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-enclosed/plugin-config.xml index 26bae34abb..5bb6b5ab64 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-enclosed/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-enclosed/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/surefire-report-enclosed - ${localRepository} - + true ${basedir}/src/test/resources/unit/surefire-report-enclosed/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-nestedClass-trimStackTrace/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-nestedClass-trimStackTrace/plugin-config.xml index dcf6a9a723..7e6c0a506c 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-nestedClass-trimStackTrace/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-nestedClass-trimStackTrace/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/surefire-report-nestedClass-trimStackTrace - ${localRepository} - + true ${basedir}/src/test/resources/unit/surefire-report-nestedClass-trimStackTrace/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-nestedClass/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-nestedClass/plugin-config.xml index 86ff4639b5..5b577227c5 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-nestedClass/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-nestedClass/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/surefire-report-nestedClass - ${localRepository} - + true ${basedir}/src/test/resources/unit/surefire-report-nestedClass/surefire-reports diff --git a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-single-error/plugin-config.xml b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-single-error/plugin-config.xml index e8a3f58895..cfb5505a25 100644 --- a/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-single-error/plugin-config.xml +++ b/maven-surefire-report-plugin/src/test/resources/unit/surefire-report-single-error/plugin-config.xml @@ -24,8 +24,7 @@ maven-surefire-report-plugin ${basedir}/target/site/unit/surefire-report-single-error - ${localRepository} - + true ${basedir}/src/test/resources/unit/surefire-report-single-error/surefire-reports diff --git a/pom.xml b/pom.xml index 36612f5461..3261564d3b 100644 --- a/pom.xml +++ b/pom.xml @@ -124,11 +124,6 @@ commons-io ${commonsIoVersion} - - org.apache.maven.reporting - maven-reporting-api - 3.1.1 - org.apache.maven maven-core @@ -167,21 +162,6 @@ maven-shared-utils ${mavenSharedUtilsVersion} - - org.apache.maven.reporting - maven-reporting-impl - 3.2.0 - - - org.apache.maven - maven-core - - - org.apache.maven - maven-plugin-api - - - org.apache.maven.shared maven-common-artifact-filters diff --git a/surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml b/surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml index 4aa101ba56..52349558f8 100644 --- a/surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml +++ b/surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml @@ -57,7 +57,7 @@ org.apache.maven.plugins maven-site-plugin - 3.7.1 + 4.0.0-M11 @@ -67,7 +67,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.0.0 + 4.0.0-M1-SNAPSHOT false