Skip to content

Commit 5e14d4f

Browse files
committed
[SUREFIRE-2161] Align Mojo class names and output names
1 parent c0784ab commit 5e14d4f

File tree

33 files changed

+120
-126
lines changed

33 files changed

+120
-126
lines changed

maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java

-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@
160160
* Abstract base class for running tests using Surefire.
161161
*
162162
* @author Stephen Connolly
163-
* @version $Id: SurefirePlugin.java 945065 2010-05-17 10:26:22Z stephenc $
164163
*/
165164
public abstract class AbstractSurefireMojo extends AbstractMojo implements SurefireExecutionParameters {
166165
private static final Map<String, String> JAVA_9_MATCHER_OLD_NOTATION = singletonMap("version", "[1.9,)");

maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java renamed to maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefireMojo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
defaultPhase = LifecyclePhase.TEST,
4646
threadSafe = true,
4747
requiresDependencyResolution = ResolutionScope.TEST)
48-
public class SurefirePlugin extends AbstractSurefireMojo implements SurefireReportParameters {
48+
public class SurefireMojo extends AbstractSurefireMojo implements SurefireReportParameters {
4949

5050
/**
5151
* The directory containing generated classes of the project being tested. This will be included after the test

maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java renamed to maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefireMojoTest.java

+26-26
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,26 @@
3131
/**
3232
*
3333
*/
34-
public class SurefirePluginTest extends TestCase {
34+
public class SurefireMojoTest extends TestCase {
3535
@Rule
3636
public final ExpectedException e = ExpectedException.none();
3737

3838
public void testDefaultIncludes() {
39-
assertThat(new SurefirePlugin().getDefaultIncludes())
39+
assertThat(new SurefireMojo().getDefaultIncludes())
4040
.containsOnly("**/Test*.java", "**/*Test.java", "**/*Tests.java", "**/*TestCase.java");
4141
}
4242

4343
public void testReportSchemaLocation() {
44-
assertThat(new SurefirePlugin().getReportSchemaLocation())
44+
assertThat(new SurefireMojo().getReportSchemaLocation())
4545
.isEqualTo("https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd");
4646
}
4747

4848
public void testFailIfNoTests() throws Exception {
4949
RunResult runResult = new RunResult(0, 0, 0, 0);
5050
try {
51-
SurefirePlugin plugin = new SurefirePlugin();
52-
plugin.setFailIfNoTests(true);
53-
plugin.handleSummary(runResult, null);
51+
SurefireMojo mojo = new SurefireMojo();
52+
mojo.setFailIfNoTests(true);
53+
mojo.handleSummary(runResult, null);
5454
} catch (MojoFailureException e) {
5555
assertThat(e.getLocalizedMessage())
5656
.isEqualTo("No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)");
@@ -63,8 +63,8 @@ public void testFailIfNoTests() throws Exception {
6363
public void testTestFailure() throws Exception {
6464
RunResult runResult = new RunResult(1, 0, 1, 0);
6565
try {
66-
SurefirePlugin plugin = new SurefirePlugin();
67-
plugin.handleSummary(runResult, null);
66+
SurefireMojo mojo = new SurefireMojo();
67+
mojo.handleSummary(runResult, null);
6868
} catch (MojoFailureException e) {
6969
assertThat(e.getLocalizedMessage())
7070
.isEqualTo("There are test failures.\n\nPlease refer to null "
@@ -79,47 +79,47 @@ public void testTestFailure() throws Exception {
7979
}
8080

8181
public void testPluginName() {
82-
assertThat(new SurefirePlugin().getPluginName()).isEqualTo("surefire");
82+
assertThat(new SurefireMojo().getPluginName()).isEqualTo("surefire");
8383
}
8484

8585
public void testShouldGetNullEnv() {
86-
SurefirePlugin plugin = new SurefirePlugin();
87-
assertThat(plugin.getExcludedEnvironmentVariables()).hasSize(0);
86+
SurefireMojo mojo = new SurefireMojo();
87+
assertThat(mojo.getExcludedEnvironmentVariables()).hasSize(0);
8888
}
8989

9090
public void testShouldGetEnv() {
91-
SurefirePlugin plugin = new SurefirePlugin();
92-
plugin.setExcludedEnvironmentVariables(new String[] {"ABC", "KLM"});
93-
assertThat(plugin.getExcludedEnvironmentVariables()).hasSize(2).contains("ABC", "KLM");
91+
SurefireMojo mojo = new SurefireMojo();
92+
mojo.setExcludedEnvironmentVariables(new String[] {"ABC", "KLM"});
93+
assertThat(mojo.getExcludedEnvironmentVariables()).hasSize(2).contains("ABC", "KLM");
9494
}
9595

9696
public void testShouldGetPropertyFile() {
97-
SurefirePlugin plugin = new SurefirePlugin();
98-
plugin.setSystemPropertiesFile(new File("testShouldGetPropertyFile"));
99-
assertThat(plugin.getSystemPropertiesFile()).isEqualTo(new File("testShouldGetPropertyFile"));
97+
SurefireMojo mojo = new SurefireMojo();
98+
mojo.setSystemPropertiesFile(new File("testShouldGetPropertyFile"));
99+
assertThat(mojo.getSystemPropertiesFile()).isEqualTo(new File("testShouldGetPropertyFile"));
100100
}
101101

102102
public void testNegativeFailOnFlakeCount() {
103-
SurefirePlugin plugin = new SurefirePlugin();
104-
plugin.setFailOnFlakeCount(-1);
103+
SurefireMojo mojo = new SurefireMojo();
104+
mojo.setFailOnFlakeCount(-1);
105105
e.expect(MojoFailureException.class);
106106
e.expectMessage("Parameter \"failOnFlakeCount\" should not be negative.");
107107
}
108108

109109
public void testFailOnFlakeCountWithoutRerun() {
110-
SurefirePlugin plugin = new SurefirePlugin();
111-
plugin.setFailOnFlakeCount(1);
110+
SurefireMojo mojo = new SurefireMojo();
111+
mojo.setFailOnFlakeCount(1);
112112
e.expect(MojoFailureException.class);
113113
e.expectMessage("\"failOnFlakeCount\" requires rerunFailingTestsCount to be at least 1.");
114114
}
115115

116116
public void testShouldHaveJUnit5EnginesFilter() {
117-
SurefirePlugin plugin = new SurefirePlugin();
117+
SurefireMojo mojo = new SurefireMojo();
118118

119-
plugin.setIncludeJUnit5Engines(new String[] {"e1", "e2"});
120-
assertThat(plugin.getIncludeJUnit5Engines()).isEqualTo(new String[] {"e1", "e2"});
119+
mojo.setIncludeJUnit5Engines(new String[] {"e1", "e2"});
120+
assertThat(mojo.getIncludeJUnit5Engines()).isEqualTo(new String[] {"e1", "e2"});
121121

122-
plugin.setExcludeJUnit5Engines(new String[] {"e1", "e2"});
123-
assertThat(plugin.getExcludeJUnit5Engines()).isEqualTo(new String[] {"e1", "e2"});
122+
mojo.setExcludeJUnit5Engines(new String[] {"e1", "e2"});
123+
assertThat(mojo.getExcludeJUnit5Engines()).isEqualTo(new String[] {"e1", "e2"});
124124
}
125125
}
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
* @author Stephen Connolly
5757
*/
58-
public abstract class AbstractSurefireReportMojo extends AbstractMavenReport {
58+
public abstract class AbstractSurefireReport extends AbstractMavenReport {
5959

6060
/**
6161
* If set to false, only failures are shown.
+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
*/
3636
@Mojo(name = "failsafe-report-only")
3737
@SuppressWarnings("unused")
38-
public class FailsafeReportMojo extends AbstractSurefireReportMojo {
38+
public class FailsafeOnlyReport extends AbstractSurefireReport {
3939

4040
/**
4141
* The filename to use for the report.
4242
*/
43-
@Parameter(defaultValue = "failsafe-report", property = "outputName", required = true)
43+
@Parameter(defaultValue = "failsafe", property = "outputName", required = true)
4444
private String outputName;
4545

4646
/**
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
@Mojo(name = "report-only")
3535
@Execute(phase = LifecyclePhase.NONE)
3636
@SuppressWarnings("unused")
37-
public class SurefireReportOnlyMojo extends SurefireReportMojo {}
37+
public class SurefireOnlyReport extends SurefireReport {}
+2-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
@Mojo(name = "report", inheritByDefault = false)
3535
@Execute(lifecycle = "surefire", phase = LifecyclePhase.TEST)
3636
@SuppressWarnings("unused")
37-
public class SurefireReportMojo extends AbstractSurefireReportMojo {
37+
public class SurefireReport extends AbstractSurefireReport {
3838

3939
/**
4040
* The filename to use for the report.
4141
*/
42-
@Parameter(defaultValue = "surefire-report", property = "outputName", required = true)
42+
@Parameter(defaultValue = "surefire", property = "outputName", required = true)
4343
private String outputName;
4444

4545
/**

maven-surefire-report-plugin/src/site/apt/examples/changing-report-name.apt.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
Changing the Report Name
2727

2828
In order to configure the file name of the generated report (which is
29-
"<surefire-report>" by default), the <<outputName>> property should
29+
"<<<surefire>>>" by default), the <<<outputName>>> property should
3030
be set to the desired name.
3131

3232
+----+

maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static Test suite() {
3434
TestSuite suite = new TestSuite();
3535
suite.addTest(new JUnit4TestAdapter(Surefire597Test.class));
3636
suite.addTest(new JUnit4TestAdapter(SurefireSchemaValidationTest.class));
37-
suite.addTestSuite(SurefireReportMojoTest.class);
37+
suite.addTestSuite(SurefireReportTest.class);
3838
return suite;
3939
}
4040
}
+28-33
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @author <a href="mailto:[email protected]">Allan Ramirez</a>
4343
*/
4444
@SuppressWarnings("checkstyle:linelength")
45-
public class SurefireReportMojoTest extends AbstractMojoTestCase {
45+
public class SurefireReportTest extends AbstractMojoTestCase {
4646
private ArtifactStubFactory artifactStubFactory;
4747

4848
// Can be removed with Doxia 2.0.0
@@ -64,8 +64,8 @@ protected void tearDown() throws Exception {
6464
super.tearDown();
6565
}
6666

67-
protected SurefireReportMojo createReportMojo(File pluginXmlFile) throws Exception {
68-
SurefireReportMojo mojo = (SurefireReportMojo) lookupMojo("report", pluginXmlFile);
67+
protected SurefireReport createReportMojo(File pluginXmlFile) throws Exception {
68+
SurefireReport mojo = (SurefireReport) lookupMojo("report", pluginXmlFile);
6969
assertNotNull("Mojo found.", mojo);
7070

7171
LegacySupport legacySupport = lookup(LegacySupport.class);
@@ -82,7 +82,7 @@ protected SurefireReportMojo createReportMojo(File pluginXmlFile) throws Excepti
8282

8383
public void testBasicSurefireReport() throws Exception {
8484
File testPom = new File(getUnitBaseDir(), "basic-surefire-report-test/plugin-config.xml");
85-
SurefireReportMojo mojo = createReportMojo(testPom);
85+
SurefireReport mojo = createReportMojo(testPom);
8686
File outputDir = (File) getVariableValueFromObject(mojo, "outputDirectory");
8787
boolean showSuccess = (Boolean) getVariableValueFromObject(mojo, "showSuccess");
8888
File reportsDir = (File) getVariableValueFromObject(mojo, "reportsDirectory");
@@ -96,14 +96,14 @@ public void testBasicSurefireReport() throws Exception {
9696
new File(getBasedir() + "/src/test/resources/unit/basic-surefire-report-test/surefire-reports")
9797
.getAbsolutePath(),
9898
reportsDir.getAbsolutePath());
99-
assertEquals("surefire-report", outputName);
99+
assertEquals("surefire", outputName);
100100
assertEquals(
101101
new File(getBasedir() + "/target/site/unit/basic-surefire-report-test/xref-test").getAbsolutePath(),
102102
xrefLocation.getAbsolutePath());
103103
assertTrue(linkXRef);
104104

105105
mojo.execute();
106-
File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-test/surefire-report.html");
106+
File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-test/surefire.html");
107107
assertTrue(report.exists());
108108
String htmlContent = FileUtils.fileRead(report);
109109

@@ -119,12 +119,11 @@ private File getUnitBaseDir() throws UnsupportedEncodingException {
119119

120120
public void testBasicSurefireReportIfShowSuccessIsFalse() throws Exception {
121121
File testPom = new File(getUnitBaseDir(), "basic-surefire-report-success-false/plugin-config.xml");
122-
SurefireReportMojo mojo = createReportMojo(testPom);
122+
SurefireReport mojo = createReportMojo(testPom);
123123
boolean showSuccess = (Boolean) getVariableValueFromObject(mojo, "showSuccess");
124124
assertFalse(showSuccess);
125125
mojo.execute();
126-
File report =
127-
new File(getBasedir(), "target/site/unit/basic-surefire-report-success-false/surefire-report.html");
126+
File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-success-false/surefire.html");
128127
assertTrue(report.exists());
129128
String htmlContent = FileUtils.fileRead(report);
130129

@@ -134,12 +133,11 @@ public void testBasicSurefireReportIfShowSuccessIsFalse() throws Exception {
134133

135134
public void testBasicSurefireReportIfLinkXrefIsFalse() throws Exception {
136135
File testPom = new File(getUnitBaseDir(), "basic-surefire-report-linkxref-false/plugin-config.xml");
137-
SurefireReportMojo mojo = createReportMojo(testPom);
136+
SurefireReport mojo = createReportMojo(testPom);
138137
boolean linkXRef = (Boolean) getVariableValueFromObject(mojo, "linkXRef");
139138
assertFalse(linkXRef);
140139
mojo.execute();
141-
File report =
142-
new File(getBasedir(), "target/site/unit/basic-surefire-report-linkxref-false/surefire-report.html");
140+
File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-linkxref-false/surefire.html");
143141
assertTrue(report.exists());
144142
String htmlContent = FileUtils.fileRead(report);
145143

@@ -149,10 +147,9 @@ public void testBasicSurefireReportIfLinkXrefIsFalse() throws Exception {
149147

150148
public void testBasicSurefireReportIfReportingIsNull() throws Exception {
151149
File testPom = new File(getUnitBaseDir(), "basic-surefire-report-reporting-null/plugin-config.xml");
152-
SurefireReportMojo mojo = createReportMojo(testPom);
150+
SurefireReport mojo = createReportMojo(testPom);
153151
mojo.execute();
154-
File report =
155-
new File(getBasedir(), "target/site/unit/basic-surefire-report-reporting-null/surefire-report.html");
152+
File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-reporting-null/surefire.html");
156153
assertTrue(report.exists());
157154
String htmlContent = FileUtils.fileRead(report);
158155

@@ -163,10 +160,9 @@ public void testBasicSurefireReportIfReportingIsNull() throws Exception {
163160
@SuppressWarnings("checkstyle:methodname")
164161
public void testBasicSurefireReport_AnchorTestCases() throws Exception {
165162
File testPom = new File(getUnitBaseDir(), "basic-surefire-report-anchor-test-cases/plugin-config.xml");
166-
SurefireReportMojo mojo = createReportMojo(testPom);
163+
SurefireReport mojo = createReportMojo(testPom);
167164
mojo.execute();
168-
File report =
169-
new File(getBasedir(), "target/site/unit/basic-surefire-report-anchor-test-cases/surefire-report.html");
165+
File report = new File(getBasedir(), "target/site/unit/basic-surefire-report-anchor-test-cases/surefire.html");
170166
assertTrue(report.exists());
171167
String htmlContent = FileUtils.fileRead(report);
172168

@@ -180,9 +176,9 @@ public void testBasicSurefireReport_AnchorTestCases() throws Exception {
180176

181177
public void testSurefireReportSingleError() throws Exception {
182178
File testPom = new File(getUnitBaseDir(), "surefire-report-single-error/plugin-config.xml");
183-
SurefireReportMojo mojo = createReportMojo(testPom);
179+
SurefireReport mojo = createReportMojo(testPom);
184180
mojo.execute();
185-
File report = new File(getBasedir(), "target/site/unit/surefire-report-single-error/surefire-report.html");
181+
File report = new File(getBasedir(), "target/site/unit/surefire-report-single-error/surefire.html");
186182
assertTrue(report.exists());
187183
String htmlContent = FileUtils.fileRead(report);
188184

@@ -267,10 +263,10 @@ public void testSurefireReportSingleError() throws Exception {
267263

268264
public void testSurefireReportNestedClassTrimStackTrace() throws Exception {
269265
File testPom = new File(getUnitBaseDir(), "surefire-report-nestedClass-trimStackTrace/plugin-config.xml");
270-
SurefireReportMojo mojo = createReportMojo(testPom);
266+
SurefireReport mojo = createReportMojo(testPom);
271267
mojo.execute();
272-
File report = new File(
273-
getBasedir(), "target/site/unit/surefire-report-nestedClass-trimStackTrace/surefire-report.html");
268+
File report =
269+
new File(getBasedir(), "target/site/unit/surefire-report-nestedClass-trimStackTrace/surefire.html");
274270
assertTrue(report.exists());
275271
String htmlContent = FileUtils.fileRead(report);
276272

@@ -331,9 +327,9 @@ public void testSurefireReportNestedClassTrimStackTrace() throws Exception {
331327

332328
public void testSurefireReportNestedClass() throws Exception {
333329
File testPom = new File(getUnitBaseDir(), "surefire-report-nestedClass/plugin-config.xml");
334-
SurefireReportMojo mojo = createReportMojo(testPom);
330+
SurefireReport mojo = createReportMojo(testPom);
335331
mojo.execute();
336-
File report = new File(getBasedir(), "target/site/unit/surefire-report-nestedClass/surefire-report.html");
332+
File report = new File(getBasedir(), "target/site/unit/surefire-report-nestedClass/surefire.html");
337333
assertTrue(report.exists());
338334
String htmlContent = FileUtils.fileRead(report);
339335

@@ -418,10 +414,9 @@ public void testSurefireReportNestedClass() throws Exception {
418414

419415
public void testSurefireReportEnclosedTrimStackTrace() throws Exception {
420416
File testPom = new File(getUnitBaseDir(), "surefire-report-enclosed-trimStackTrace/plugin-config.xml");
421-
SurefireReportMojo mojo = createReportMojo(testPom);
417+
SurefireReport mojo = createReportMojo(testPom);
422418
mojo.execute();
423-
File report =
424-
new File(getBasedir(), "target/site/unit/surefire-report-enclosed-trimStackTrace/surefire-report.html");
419+
File report = new File(getBasedir(), "target/site/unit/surefire-report-enclosed-trimStackTrace/surefire.html");
425420
assertTrue(report.exists());
426421
String htmlContent = FileUtils.fileRead(report);
427422

@@ -482,9 +477,9 @@ public void testSurefireReportEnclosedTrimStackTrace() throws Exception {
482477

483478
public void testSurefireReportEnclosed() throws Exception {
484479
File testPom = new File(getUnitBaseDir(), "surefire-report-enclosed/plugin-config.xml");
485-
SurefireReportMojo mojo = createReportMojo(testPom);
480+
SurefireReport mojo = createReportMojo(testPom);
486481
mojo.execute();
487-
File report = new File(getBasedir(), "target/site/unit/surefire-report-enclosed/surefire-report.html");
482+
File report = new File(getBasedir(), "target/site/unit/surefire-report-enclosed/surefire.html");
488483
assertTrue(report.exists());
489484
String htmlContent = FileUtils.fileRead(report);
490485

@@ -579,7 +574,7 @@ public void testSurefireReportEnclosed() throws Exception {
579574

580575
public void testCustomTitleAndDescriptionReport() throws Exception {
581576
File testPom = new File(getUnitBaseDir(), "surefire-1183/plugin-config.xml");
582-
SurefireReportMojo mojo = createReportMojo(testPom);
577+
SurefireReport mojo = createReportMojo(testPom);
583578

584579
File outputDir = (File) getVariableValueFromObject(mojo, "outputDirectory");
585580
String outputName = (String) getVariableValueFromObject(mojo, "outputName");
@@ -590,11 +585,11 @@ public void testCustomTitleAndDescriptionReport() throws Exception {
590585
new File(getBasedir() + "/src/test/resources/unit/surefire-1183/acceptancetest-reports")
591586
.getAbsolutePath(),
592587
reportsDir.getAbsolutePath());
593-
assertEquals("acceptance-test-report", outputName);
588+
assertEquals("acceptance-test", outputName);
594589

595590
mojo.execute();
596591

597-
File report = new File(getBasedir(), "target/site/unit/surefire-1183/acceptance-test-report.html");
592+
File report = new File(getBasedir(), "target/site/unit/surefire-1183/acceptance-test.html");
598593

599594
assertTrue(report.exists());
600595

Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/**
3434
* @author <a href="mailto:[email protected]">Allan Ramirez</a>
3535
*/
36-
public class SurefireRepMavenProjectStub extends MavenProjectStub {
36+
public class SurefireReportMavenProjectStub extends MavenProjectStub {
3737
/**
3838
* {@inheritDoc}
3939
*/
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/**
2828
* @author <a href="mailto:[email protected]">Allan Ramirez</a>
2929
*/
30-
public class SurefireRepMavenProjectStub2 extends MavenProjectStub {
30+
public class SurefireReportMavenProjectStub2 extends MavenProjectStub {
3131
/**
3232
* {@inheritDoc}
3333
*/

0 commit comments

Comments
 (0)