Skip to content

Commit

Permalink
Prepare for Doxia 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-o committed May 7, 2023
1 parent 47b15d6 commit e24fb01
Show file tree
Hide file tree
Showing 59 changed files with 486 additions and 266 deletions.
2 changes: 1 addition & 1 deletion maven-failsafe-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>

<groupId>org.apache.maven.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion maven-surefire-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>

<artifactId>maven-surefire-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion maven-surefire-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>

<groupId>org.apache.maven.plugins</groupId>
Expand Down
6 changes: 4 additions & 2 deletions maven-surefire-report-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>

<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -46,7 +46,7 @@
</prerequisites>

<properties>
<doxiaVersion>1.11.1</doxiaVersion>
<doxiaVersion>2.0.0-M6</doxiaVersion>
<aetherVersion>1.0.0.v20140518</aetherVersion>
</properties>

Expand Down Expand Up @@ -89,10 +89,12 @@
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>4.0.0-M6</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>4.0.0-M8</version>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,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<MavenProject> reactorProjects;

/**
* Location of the Xrefs to link.
*/
Expand Down Expand Up @@ -354,6 +348,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 @@ -19,7 +19,6 @@
package org.apache.maven.plugins.surefire.report;

import java.io.File;
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -84,10 +83,10 @@ public String getTitle() {
* @return The translated string.
*/
private String getI18nString(String key) {
return getI18nString(getI18Nsection(), key);
return getI18nString(getI18nSection(), key);
}

private String getI18Nsection() {
private String getI18nSection() {
return i18nSection;
}

Expand All @@ -100,14 +99,19 @@ private String getI18nString(String section, String key) {
return i18n.getString("surefire-report", locale, "report." + section + '.' + key);
}

/**
* @param section The section.
* @param key The key to translate.
* @return the translated key.
*/
private String formatI18nString(String section, String key, Object... args) {
return i18n.format("surefire-report", locale, "report." + section + '.' + key, args);
}

public void renderBody() {
javaScript(javascriptToggleDisplayCode());

sink.section1();
sink.sectionTitle1();
sink.text(getTitle());
sink.sectionTitle1_();
sink.section1_();
startSection(getTitle());

renderSectionSummary();

Expand All @@ -116,19 +120,14 @@ public void renderBody() {
renderSectionTestCases();

renderSectionFailureDetails();

endSection();
}

private void renderSectionSummary() {
Map<String, Object> summary = parser.getSummary(testSuites);
NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
percentFormat.setMinimumFractionDigits(1);

sink.section1();
sinkAnchor("Summary");
sink.sectionTitle1();
sink.text(getI18nString("surefire", "label.summary"));
sink.sectionTitle1_();
startSection(getI18nString("surefire", "label.summary"), "Summary");

constructHotLinks();

Expand All @@ -150,8 +149,8 @@ private void renderSectionSummary() {
String.valueOf(summary.get("totalErrors")),
String.valueOf(summary.get("totalFailures")),
String.valueOf(summary.get("totalSkipped")),
percentFormat.format(summary.get("totalPercentage")),
numberFormat.format(summary.get("totalElapsedTime")) + " s"
formatI18nString("surefire", "value.successrate", summary.get("totalPercentage")),
formatI18nString("surefire", "value.time", summary.get("totalElapsedTime"))
});

endTable();
Expand All @@ -162,7 +161,7 @@ private void renderSectionSummary() {

sink.lineBreak();

sink.section1_();
endSection();
}

private void renderSectionPackages() {
Expand All @@ -171,15 +170,7 @@ private void renderSectionPackages() {
return;
}

NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
percentFormat.setMinimumFractionDigits(1);

sink.section1();
sinkAnchor("Package_List");
sink.sectionTitle1();
sink.text(getI18nString("surefire", "label.packagelist"));
sink.sectionTitle1_();
startSection(getI18nString("surefire", "label.packagelist"), "Package_List");

constructHotLinks();

Expand All @@ -205,13 +196,13 @@ private void renderSectionPackages() {
Map<String, Object> packageSummary = parser.getSummary(testSuiteList);

tableRow(new String[] {
'{' + packageName + ", #" + packageName + '}',
createLinkPatternedText(packageName, '#' + packageName),
String.valueOf(packageSummary.get("totalTests")),
String.valueOf(packageSummary.get("totalErrors")),
String.valueOf(packageSummary.get("totalFailures")),
String.valueOf(packageSummary.get("totalSkipped")),
percentFormat.format(packageSummary.get("totalPercentage")),
numberFormat.format(packageSummary.get("totalElapsedTime")) + " s"
formatI18nString("surefire", "value.successrate", packageSummary.get("totalPercentage")),
formatI18nString("surefire", "value.time", packageSummary.get("totalElapsedTime"))
});
}

Expand All @@ -225,11 +216,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 @@ -264,19 +251,15 @@ private void renderSectionPackages() {
endTable();
}

sink.section2_();
endSection();
}

sink.lineBreak();

sink.section1_();
endSection();
}

private void renderSectionTestSuite(ReportTestSuite suite) {
NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
percentFormat.setMinimumFractionDigits(1);

sink.tableRow();

sink.tableCell();
Expand All @@ -297,7 +280,7 @@ private void renderSectionTestSuite(ReportTestSuite suite) {

sink.tableCell_();

tableCell('{' + suite.getName() + ", #" + suite.getPackageName() + '.' + suite.getName() + '}');
tableCell(createLinkPatternedText(suite.getName(), '#' + suite.getPackageName() + '.' + suite.getName()));

tableCell(Integer.toString(suite.getNumberOfTests()));

Expand All @@ -310,9 +293,9 @@ private void renderSectionTestSuite(ReportTestSuite suite) {
float percentage = parser.computePercentage(
suite.getNumberOfTests(), suite.getNumberOfErrors(),
suite.getNumberOfFailures(), suite.getNumberOfSkipped());
tableCell(percentFormat.format(percentage));
tableCell(formatI18nString("surefire", "value.successrate", percentage));

tableCell(numberFormat.format(suite.getTimeElapsed()) + " s");
tableCell(formatI18nString("surefire", "value.time", suite.getTimeElapsed()));

sink.tableRow_();
}
Expand All @@ -322,23 +305,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 @@ -362,18 +337,16 @@ private void renderSectionTestCases() {
endTable();
}

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

sink.lineBreak();

sink.section1_();
endSection();
}

private void constructTestCaseSection(ReportTestCase testCase) {
NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);

sink.tableRow();

sink.tableCell();
Expand Down Expand Up @@ -427,7 +400,7 @@ private void constructTestCaseSection(ReportTestCase testCase) {
sinkCellAnchor(testCase.getName(), "TC_" + toHtmlId(testCase.getFullName()));
}

tableCell(numberFormat.format(testCase.getTime()) + " s");
tableCell(formatI18nString("surefire", "value.time", testCase.getTime()));

sink.tableRow_();

Expand Down Expand Up @@ -460,7 +433,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 @@ -469,11 +442,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 @@ -540,7 +509,7 @@ private void renderSectionFailureDetails() {

sink.lineBreak();

sink.section1_();
endSection();
}

private void constructHotLinks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ report.surefire.label.testcases=Test Cases
report.surefire.label.failuredetails=Failure Details
report.surefire.text.note1=Note: failures are anticipated and checked for with assertions while errors are unanticipated.
report.surefire.text.note2=Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
report.surefire.value.successrate={0,choice,0#0%|0.0<{0,number,0.0%}|1#{0,number,0%}}
# Needs to be copied into other bundles only if non-Latin script is used
report.surefire.value.time={0,choice,0#0|0.0<{0,number,0.000}|1.0#{0,number,0.0}|1000#{0,number,0}} s

report.failsafe.name=Failsafe
report.failsafe.description=Report on the integration test results of the project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ report.surefire.label.tests=Tests
report.surefire.label.time =Zeit
report.surefire.text.note1 =Hinweis: Fehlschl\u00E4ge werden erwartet und durch Behauptungen \u00FCberpr\u00FCft w\u00E4hrend Fehler unerwartet sind.
report.surefire.text.note2 =Hinweis: Die Paketstatistiken werden nicht rekursiv berechnet, es werden lediglich die Ergebnisse aller enthaltenen Tests aufsummiert.
report.surefire.value.successrate={0,choice,0#0 %|0.0<{0,number,0.0 %}|1#{0,number,0 %}}

report.failsafe.name=Failsafe
report.failsafe.description=Bericht \u00FCber die Integrationstestresultate des Projekts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ report.surefire.label.testcases=Testfall
report.surefire.label.failuredetails=Detaljer om misslyckade tester
report.surefire.text.note1=Notera: misslyckade tester \u00e4r f\u00f6rv\u00e4ntade och har kontrollerats med assertions medan felaktiga tester \u00e4r ov\u00e4ntade.
report.surefire.text.note2=Notera: paketstatistiken ber\u00e4knas inte rekursivt, den summerar bara alla testsviters antal.
report.surefire.value.successrate={0,choice,0#0 %|0.0<{0,number,0.0 %}|1#{0,number,0 %}}

report.failsafe.name=Failsafe
report.failsafe.description=Rapport om integration testresultaten f\u00f6r projektet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit e24fb01

Please sign in to comment.