Skip to content

Commit

Permalink
[SUREFIRE-2228] Upgrade to Doxia 2.0.0 Milestone Stack
Browse files Browse the repository at this point in the history
This closes #629
  • Loading branch information
michael-o committed Aug 21, 2024
1 parent 5e14d4f commit f1a419a
Show file tree
Hide file tree
Showing 47 changed files with 521 additions and 271 deletions.
7 changes: 2 additions & 5 deletions maven-surefire-report-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</prerequisites>

<properties>
<doxiaVersion>1.12.0</doxiaVersion>
<doxiaVersion>2.0.0-M12</doxiaVersion>
</properties>

<dependencies>
Expand Down Expand Up @@ -111,13 +111,10 @@
<artifactId>doxia-core</artifactId>
<version>${doxiaVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>4.0.0-M15</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.apache.maven.settings.Settings;
import org.apache.maven.shared.utils.PathTool;
import org.codehaus.plexus.i18n.I18N;
Expand Down Expand Up @@ -149,16 +148,16 @@ protected boolean isGeneratedWhenNoResults() {
* {@inheritDoc}
*/
@Override
public void executeReport(Locale locale) throws MavenReportException {
public void executeReport(Locale locale) {
SurefireReportRenderer r = new SurefireReportRenderer(
getSink(),
getI18N(locale),
getI18Nsection(),
locale,
getConsoleLogger(),
showSuccess,
getReportsDirectories(),
determineXrefLocation());
determineXrefLocation(),
showSuccess);
r.render();
}

Expand Down Expand Up @@ -263,7 +262,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 = ".";
}
Expand Down Expand Up @@ -346,6 +346,10 @@ protected MavenProject getProject() {
return project;
}

protected List<MavenProject> getReactorProjects() {
return reactorProjects;
}

// TODO Review, especially Locale.getDefault()
private static class CustomI18N implements I18N {
private final MavenProject project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class FailsafeOnlyReport extends AbstractSurefireReport {
@Override
protected File getSurefireReportsDirectory(MavenProject subProject) {
String buildDir = subProject.getBuild().getDirectory();
return new File(buildDir + "/failsafe-reports");
return new File(buildDir, "failsafe-reports");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
private final Locale locale;

private final SurefireReportParser parser;
private final boolean showSuccess;
private final String xrefLocation;
private final List<ReportTestSuite> testSuites;
private final String xrefLocation;
private final boolean showSuccess;

public SurefireReportRenderer(
Sink sink,
I18N i18n,
String i18nSection,
Locale locale,
ConsoleLogger consoleLogger,
boolean showSuccess,
List<File> reportsDirectories,
String xrefLocation) {
String xrefLocation,
boolean showSuccess) {
super(sink);
this.i18n = i18n;
this.i18nSection = i18nSection;
Expand Down Expand Up @@ -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();

Expand All @@ -125,16 +121,14 @@ public void renderBody() {
renderSectionTestCases();

renderSectionFailureDetails();

endSection();
}

private void renderSectionSummary() {
Map<String, Object> 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();

Expand Down Expand Up @@ -168,7 +162,7 @@ private void renderSectionSummary() {

sink.lineBreak();

sink.section1_();
endSection();
}

private void renderSectionPackages() {
Expand All @@ -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();

Expand Down Expand Up @@ -227,11 +217,7 @@ private void renderSectionPackages() {

List<ReportTestSuite> testSuiteList = entry.getValue();

sink.section2();
sinkAnchor(packageName);
sink.sectionTitle2();
sink.text(packageName);
sink.sectionTitle2_();
startSection(packageName);

boolean showTable = false;

Expand Down Expand Up @@ -266,12 +252,12 @@ private void renderSectionPackages() {
endTable();
}

sink.section2_();
endSection();
}

sink.lineBreak();

sink.section1_();
endSection();
}

private void renderSectionTestSuite(ReportTestSuite suite) {
Expand Down Expand Up @@ -320,23 +306,15 @@ 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();

for (ReportTestSuite suite : testSuites) {
List<ReportTestCase> 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;

Expand All @@ -360,13 +338,13 @@ private void renderSectionTestCases() {
endTable();
}

sink.section2_();
endSection();
}
}

sink.lineBreak();

sink.section1_();
endSection();
}

private void constructTestCaseSection(ReportTestCase testCase) {
Expand Down Expand Up @@ -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() {
Expand All @@ -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();

Expand Down Expand Up @@ -554,7 +528,7 @@ private void renderSectionFailureDetails() {

sink.lineBreak();

sink.section1_();
endSection();
}

private void constructHotLinks() {
Expand Down
2 changes: 1 addition & 1 deletion maven-surefire-report-plugin/src/site/apt/usage.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Usage
mvn surefire-report:report
+---+

A HTML report should be generated in <<<$\{basedir\}/target/site/surefire-report.html>>>.
An HTML report should be generated in <<<$\{basedir\}/target/reports/surefire.html>>>.

[images/surefire-sample2.png] Sample standalone surefire-report

Original file line number Diff line number Diff line change
Expand Up @@ -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("<table border=\"0\" class=\"bodyTable\">\n"
containsString(toSystemNewLine("<table class=\"bodyTable\">\n"
+ "<tr class=\"a\">\n"
+ "<th>Tests</th>\n"
+ "<th>Errors</th>\n"
Expand All @@ -62,7 +62,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws
+ "<th>Success Rate</th>\n"
+ "<th>Time</th></tr>\n"
+ "<tr class=\"b\">\n"
+ "<td align=\"left\">1</td>\n"
+ "<td>1</td>\n"
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
Expand All @@ -72,7 +72,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws
+ "</table>")));
assertThat(
xml,
containsString(toSystemNewLine("<table border=\"0\" class=\"bodyTable\">\n"
containsString(toSystemNewLine("<table class=\"bodyTable\">\n"
+ "<tr class=\"a\">\n"
+ "<th>Package</th>\n"
+ "<th>Tests</th>\n"
Expand All @@ -82,7 +82,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws
+ "<th>Success Rate</th>\n"
+ "<th>Time</th></tr>\n"
+ "<tr class=\"b\">\n"
+ "<td align=\"left\"><a href=\"#surefire\">surefire</a></td>\n"
+ "<td><a href=\"#surefire\">surefire</a></td>\n"
+ "<td>1</td>\n"
+ "<td>1</td>\n"
+ "<td>0</td>\n"
Expand All @@ -91,7 +91,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws
+ "<td>0 s</td></tr></table>")));
assertThat(
xml,
containsString(toSystemNewLine("<table border=\"0\" class=\"bodyTable\">\n"
containsString(toSystemNewLine("<table class=\"bodyTable\">\n"
+ "<tr class=\"a\">\n"
+ "<th>-</th>\n"
+ "<th>Class</th>\n"
Expand All @@ -102,7 +102,7 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws
+ "<th>Success Rate</th>\n"
+ "<th>Time</th></tr>\n"
+ "<tr class=\"b\">\n"
+ "<td align=\"left\"><a href=\"#surefire.MyTest\"><img src=\"images/icon_error_sml.gif\" alt=\"\" /></a></td>\n"
+ "<td><a href=\"#surefire.MyTest\"><img src=\"images/icon_error_sml.gif\" /></a></td>\n"
+ "<td><a href=\"#surefire.MyTest\">MyTest</a></td>\n"
+ "<td>1</td>\n"
+ "<td>1</td>\n"
Expand All @@ -112,15 +112,15 @@ public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage() throws
+ "<td>0 s</td></tr></table>")));
assertThat(
xml,
containsString(toSystemNewLine("<table border=\"0\" class=\"bodyTable\">\n"
containsString(toSystemNewLine("<table class=\"bodyTable\">\n"
+ "<tr class=\"a\">\n"
+ "<td align=\"left\"><img src=\"images/icon_error_sml.gif\" alt=\"\" /></td>\n"
+ "<td><img src=\"images/icon_error_sml.gif\" /></td>\n"
+ "<td><a id=\"surefire.MyTest.test\"></a>test</td></tr>\n"
+ "<tr class=\"b\">\n"
+ "<td align=\"left\">-</td>\n"
+ "<td>-</td>\n"
+ "<td>java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: msg</td></tr>\n"
+ "<tr class=\"a\">\n"
+ "<td align=\"left\">-</td>\n"
+ "<td>-</td>\n"
+ "<td>\n"
+ "<div id=\"test-error\">surefire.MyTest:13</div></td></tr></table>")));
}
Expand Down
Loading

0 comments on commit f1a419a

Please sign in to comment.