diff --git a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
index 8b4f5e80..2ad40153 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
@@ -35,7 +35,6 @@
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.project.ProjectBuildingRequest;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
@@ -49,11 +48,6 @@
public abstract class AbstractPmdReportTestCase extends AbstractMojoTestCase {
private ArtifactStubFactory artifactStubFactory;
- /**
- * The current project to be test.
- */
- private MavenProject testMavenProject;
-
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -64,38 +58,10 @@ protected void setUp() throws Exception {
}
/**
- * Get the current Maven project
+ * Generate the report and return the generated file.
*
- * @return the maven project
- */
- protected MavenProject getTestMavenProject() {
- return testMavenProject;
- }
-
- /**
- * Get the generated report as file in the test maven project.
- *
- * @param name the name of the report.
- * @return the generated report as file
- * @throws IOException if the return file doesnt exist
- */
- protected File getGeneratedReport(String name) throws IOException {
- String outputDirectory =
- getBasedir() + "/target/test/unit/" + getTestMavenProject().getArtifactId();
-
- File report = new File(outputDirectory, name);
- if (!report.exists()) {
- throw new IOException("File not found. Attempted: " + report);
- }
-
- return report;
- }
-
- /**
- * Generate the report and return the generated file
- *
- * @param goal the mojo goal.
- * @param pluginXml the name of the xml file in "src/test/resources/plugin-configs/".
+ * @param goal the mojo goal
+ * @param pluginXml the name of the xml file in "src/test/resources/plugin-configs/"
* @return the generated HTML file
* @throws Exception if any
*/
@@ -133,13 +99,9 @@ protected AbstractPmdReport createReportMojo(String goal, File pluginXmlFile) th
protected File generateReport(AbstractPmdReport mojo, File pluginXmlFile) throws Exception {
mojo.execute();
- ProjectBuilder builder = lookup(ProjectBuilder.class);
-
ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
buildingRequest.setRepositorySession(lookup(LegacySupport.class).getRepositorySession());
- testMavenProject = builder.build(pluginXmlFile, buildingRequest).getProject();
-
File outputDir = mojo.getReportOutputDirectory();
String filename = mojo.getOutputPath() + ".html";
@@ -147,38 +109,38 @@ protected File generateReport(AbstractPmdReport mojo, File pluginXmlFile) throws
}
/**
- * Read the contents of the specified file object into a string
+ * Read the contents of the specified file into a string.
*/
protected String readFile(File file) throws IOException {
return new String(Files.readAllBytes(file.toPath()));
}
/**
- * Checks, whether the string contained is contained in
- * the given text ignoring case.
+ * Checks whether the string contained is contained in
+ * the given text, ignoring case.
*
* @param text the string in which the search is executed
- * @param contains the string, the should be searched
- * @return true if the string is contained, otherwise false.
+ * @param contains the string to be searched for
+ * @return true if the text contains the string, otherwise false
*/
public static boolean lowerCaseContains(String text, String contains) {
return text.toLowerCase(Locale.ROOT).contains(contains.toLowerCase(Locale.ROOT));
}
private MojoExecution getMockMojoExecution() {
- MojoDescriptor md = new MojoDescriptor();
- md.setGoal(getGoal());
+ MojoDescriptor mojoDescriptor = new MojoDescriptor();
+ mojoDescriptor.setGoal(getGoal());
- MojoExecution me = new MojoExecution(md);
+ MojoExecution execution = new MojoExecution(mojoDescriptor);
- PluginDescriptor pd = new PluginDescriptor();
- Plugin p = new Plugin();
- p.setGroupId("org.apache.maven.plugins");
- p.setArtifactId("maven-pmd-plugin");
- pd.setPlugin(p);
- md.setPluginDescriptor(pd);
+ PluginDescriptor pluginDescriptor = new PluginDescriptor();
+ Plugin plugin = new Plugin();
+ plugin.setGroupId("org.apache.maven.plugins");
+ plugin.setArtifactId("maven-pmd-plugin");
+ pluginDescriptor.setPlugin(plugin);
+ mojoDescriptor.setPluginDescriptor(pluginDescriptor);
- return me;
+ return execution;
}
protected abstract String getGoal();