You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/04/30 19:41:09 UTC
[maven-surefire] 01/02: three
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch use-renderer
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 2d47b864da228b55a3ff36cdcd709d3a44a499dc
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Apr 30 21:29:53 2023 +0200
three
---
.../plugins/surefire/report/Surefire597Test.java | 6 +-
.../surefire/report/SurefireReportMojoTest.java | 93 +++++++---------------
.../resources/unit/surefire-1183/plugin-config.xml | 3 +-
3 files changed, 32 insertions(+), 70 deletions(-)
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 1440a015a..cf1724dc4 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
@@ -69,7 +69,7 @@ public class Surefire597Test extends TestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td>"
+ "</tr>"
+ "</table>")));
@@ -90,7 +90,7 @@ public class Surefire597Test extends TestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr></table>")));
assertThat(
xml,
@@ -111,7 +111,7 @@ public class Surefire597Test extends TestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr></table>")));
assertThat(
xml,
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/SurefireReportMojoTest.java
index b5dd1bf42..45050e7ab 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/SurefireReportMojoTest.java
@@ -19,26 +19,17 @@
package org.apache.maven.plugins.surefire.report;
import java.io.File;
-import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.io.Writer;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Locale;
-import org.apache.maven.doxia.site.decoration.DecorationModel;
-import org.apache.maven.doxia.siterenderer.Renderer;
-import org.apache.maven.doxia.siterenderer.RendererException;
-import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
-import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
import org.apache.maven.plugin.LegacySupport;
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.shared.utils.WriterFactory;
import org.apache.maven.shared.utils.io.FileUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
@@ -54,15 +45,23 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class SurefireReportMojoTest extends AbstractMojoTestCase {
private ArtifactStubFactory artifactStubFactory;
- private Renderer renderer;
+ // Can be removed with Doxia 2.0.0
+ private Locale origLocale;
@Override
protected void setUp() throws Exception {
super.setUp();
- renderer = (Renderer) lookup(Renderer.ROLE);
-
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 SurefireReportMojo createReportMojo(File pluginXmlFile) throws Exception {
@@ -105,7 +104,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
mojo.execute();
File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-test/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -127,7 +125,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
mojo.execute();
File report =
new File(getBasedir(), "target/site/unit/basic-surefire-report-success-false/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -142,8 +139,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
assertFalse(linkXRef);
mojo.execute();
File report =
- new File(getBasedir(), "target/site/unit/basic-surefire-report-success-false/surefire-report.html");
- renderer(mojo, report);
+ new File(getBasedir(), "target/site/unit/basic-surefire-report-linkxref-false/surefire-report.html");
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -157,7 +153,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
mojo.execute();
File report =
new File(getBasedir(), "target/site/unit/basic-surefire-report-reporting-null/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -172,7 +167,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
mojo.execute();
File report =
new File(getBasedir(), "target/site/unit/basic-surefire-report-anchor-test-cases/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -189,7 +183,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
SurefireReportMojo mojo = createReportMojo(testPom);
mojo.execute();
File report = new File(getBasedir(), "target/site/unit/surefire-report-single-error/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -200,7 +193,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td>")));
assertThat(
@@ -211,7 +204,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(
htmlContent,
@@ -226,7 +219,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest:13</a>"));
@@ -278,7 +271,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
mojo.execute();
File report = new File(
getBasedir(), "target/site/unit/surefire-report-nestedClass-trimStackTrace/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -289,7 +281,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td>")));
assertThat(
@@ -300,7 +292,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(
htmlContent,
@@ -315,7 +307,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest:13</a>"));
@@ -342,7 +334,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
SurefireReportMojo mojo = createReportMojo(testPom);
mojo.execute();
File report = new File(getBasedir(), "target/site/unit/surefire-report-nestedClass/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -353,7 +344,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td>")));
assertThat(
@@ -364,7 +355,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(
htmlContent,
@@ -379,7 +370,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest:13</a>"));
@@ -431,7 +422,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
mojo.execute();
File report =
new File(getBasedir(), "target/site/unit/surefire-report-enclosed-trimStackTrace/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -442,7 +432,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td>")));
assertThat(
@@ -453,7 +443,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(
htmlContent,
@@ -468,7 +458,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest$A:45</a>"));
@@ -495,7 +485,6 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
SurefireReportMojo mojo = createReportMojo(testPom);
mojo.execute();
File report = new File(getBasedir(), "target/site/unit/surefire-report-enclosed/surefire-report.html");
- renderer(mojo, report);
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
@@ -506,7 +495,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td>")));
assertThat(
@@ -517,7 +506,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(
htmlContent,
@@ -532,7 +521,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0%</td>\n"
+ + "<td>0.0%</td>\n"
+ "<td>0</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest$A:45</a>"));
@@ -609,37 +598,11 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
mojo.execute();
- File report = new File(getBasedir(), "target/site/acceptance-test-report.html");
- renderer(mojo, report);
+ File report = new File(getBasedir(), "target/site/unit/surefire-1183/acceptance-test-report.html");
assertTrue(report.exists());
String htmlContent = FileUtils.fileRead(report);
assertTrue(htmlContent.contains("<h2><a name=\"Acceptance_Test\"></a>Acceptance Test</h2></section>"));
}
-
- /**
- * Renderer the sink from the report mojo.
- *
- * @param mojo not null
- * @param outputHtml not null
- * @throws RendererException if any
- * @throws IOException if any
- */
- private void renderer(SurefireReportMojo mojo, File outputHtml) throws RendererException, IOException {
- Writer writer = null;
- SiteRenderingContext context = new SiteRenderingContext();
- context.setDecoration(new DecorationModel());
- context.setTemplateName("org/apache/maven/doxia/siterenderer/resources/default-site.vm");
- context.setLocale(Locale.ENGLISH);
-
- try {
- outputHtml.getParentFile().mkdirs();
- writer = WriterFactory.newXmlWriter(outputHtml);
-
- renderer.generateDocument(writer, (SiteRendererSink) mojo.getSink(), context);
- } finally {
- IOUtil.close(writer);
- }
- }
}
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 3166e7896..75ad4abd9 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
@@ -31,8 +31,7 @@
<outputName>acceptance-test-report</outputName>
<localRepository>${localRepository}</localRepository>
<outputDirectory>${basedir}/target/site/unit/surefire-1183</outputDirectory>
- <reportsDirectory>${basedir}/src/test/resources/unit/surefire-1183/acceptancetest-reports
- </reportsDirectory>
+ <reportsDirectory>${basedir}/src/test/resources/unit/surefire-1183/acceptancetest-reports</reportsDirectory>
</configuration>
</plugin>
</plugins>