diff --git a/pom.xml b/pom.xml
index 6e1b505a..118d9af4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,8 +91,10 @@ under the License.
8
6.48.0
1.7.36
- 3.12.0
- 3.3.0
+ 1.0.0.v20140518
+ 3.12.1
+ 3.4.1
+ 3.3.0
2022-05-31T17:37:31Z
@@ -203,18 +205,24 @@ under the License.
doxia-site-renderer requires transitively dom4j 1.1 which provides a very old version of jaxen (same jar).
PMD requires a newer version of jaxen, which is not compatible.
-->
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
org.apache.maven.reporting
maven-reporting-api
- 3.1.0
+ 3.1.1
org.apache.maven.reporting
maven-reporting-impl
- 3.1.0
+ 3.2.0
org.apache.maven.shared
@@ -243,11 +251,43 @@ under the License.
com.github.tomakehurst
wiremock
-
- 1.49
+ 1.58
+ test
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+
+
+ org.eclipse.aether
+ aether-api
+ ${aetherVersion}
+ test
+
+
+ org.eclipse.aether
+ aether-impl
+ ${aetherVersion}
+ test
+
+
+ org.eclipse.aether
+ aether-connector-basic
+ ${aetherVersion}
+ test
+
+
+ org.eclipse.aether
+ aether-transport-wagon
+ ${aetherVersion}
+ test
+
+
+ org.apache.maven.wagon
+ wagon-http-lightweight
+ 3.5.2
test
diff --git a/src/it/MPMD-128-xref-link/pom.xml b/src/it/MPMD-128-xref-link/pom.xml
index f3728ce1..17434948 100644
--- a/src/it/MPMD-128-xref-link/pom.xml
+++ b/src/it/MPMD-128-xref-link/pom.xml
@@ -57,7 +57,7 @@ under the License.
org.apache.maven.plugins
maven-jxr-plugin
- 2.3
+ @jxrPluginVersion@
diff --git a/src/it/MPMD-172/pom.xml b/src/it/MPMD-172/pom.xml
index dd59737f..8f892d5c 100644
--- a/src/it/MPMD-172/pom.xml
+++ b/src/it/MPMD-172/pom.xml
@@ -39,7 +39,7 @@ under the License.
org.apache.maven.plugins
maven-jxr-plugin
- 2.4
+ @jxrPluginVersion@
org.apache.maven.plugins
diff --git a/src/it/MPMD-253-xref-link-multi-module/pom.xml b/src/it/MPMD-253-xref-link-multi-module/pom.xml
index d9d0f85a..3fd048ef 100644
--- a/src/it/MPMD-253-xref-link-multi-module/pom.xml
+++ b/src/it/MPMD-253-xref-link-multi-module/pom.xml
@@ -59,7 +59,7 @@ under the License.
org.apache.maven.plugins
maven-jxr-plugin
- 2.3
+ @jxrPluginVersion@
diff --git a/src/it/MPMD-270-325-JDK11/pom.xml b/src/it/MPMD-270-325-JDK11/pom.xml
index e79e7007..296ef7dc 100644
--- a/src/it/MPMD-270-325-JDK11/pom.xml
+++ b/src/it/MPMD-270-325-JDK11/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/MPMD-280-JDK12/pom.xml b/src/it/MPMD-280-JDK12/pom.xml
index d7046e7b..071d4255 100644
--- a/src/it/MPMD-280-JDK12/pom.xml
+++ b/src/it/MPMD-280-JDK12/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/MPMD-289-format-html-check/pom.xml b/src/it/MPMD-289-format-html-check/pom.xml
index 9d44fe0c..b7233d10 100644
--- a/src/it/MPMD-289-format-html-check/pom.xml
+++ b/src/it/MPMD-289-format-html-check/pom.xml
@@ -30,6 +30,10 @@ under the License.
Then report format is html, xml format should still be created so that the check goal still works.
+
+ UTF-8
+
+
@@ -41,7 +45,6 @@ under the License.
false
true
4
- UTF-8
100
false
html
diff --git a/src/it/MPMD-295-JDK13/pom.xml b/src/it/MPMD-295-JDK13/pom.xml
index 4e8161a8..5d7e0e51 100644
--- a/src/it/MPMD-295-JDK13/pom.xml
+++ b/src/it/MPMD-295-JDK13/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/MPMD-302-JDK14/pom.xml b/src/it/MPMD-302-JDK14/pom.xml
index 9b7c1c7c..86f42591 100644
--- a/src/it/MPMD-302-JDK14/pom.xml
+++ b/src/it/MPMD-302-JDK14/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/MPMD-302-JDK15/pom.xml b/src/it/MPMD-302-JDK15/pom.xml
index 8db2e8b3..6c3514c1 100644
--- a/src/it/MPMD-302-JDK15/pom.xml
+++ b/src/it/MPMD-302-JDK15/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/MPMD-304-toolchain-support/pom.xml b/src/it/MPMD-304-toolchain-support/pom.xml
index 5ea8c4c1..c9770a33 100644
--- a/src/it/MPMD-304-toolchain-support/pom.xml
+++ b/src/it/MPMD-304-toolchain-support/pom.xml
@@ -54,7 +54,6 @@ under the License.
false
true
${java.version}
- UTF-8
10
diff --git a/src/it/MPMD-312-JDK16/pom.xml b/src/it/MPMD-312-JDK16/pom.xml
index 14983bfc..0f51ed63 100644
--- a/src/it/MPMD-312-JDK16/pom.xml
+++ b/src/it/MPMD-312-JDK16/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/MPMD-312-JDK17/pom.xml b/src/it/MPMD-312-JDK17/pom.xml
index 3064ae2c..08123052 100644
--- a/src/it/MPMD-312-JDK17/pom.xml
+++ b/src/it/MPMD-312-JDK17/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/MPMD-332-JDK18/pom.xml b/src/it/MPMD-332-JDK18/pom.xml
index 5f45389e..c447a319 100644
--- a/src/it/MPMD-332-JDK18/pom.xml
+++ b/src/it/MPMD-332-JDK18/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/MPMD-348-JDK19/pom.xml b/src/it/MPMD-348-JDK19/pom.xml
index 32ea2ecd..8cdbf784 100644
--- a/src/it/MPMD-348-JDK19/pom.xml
+++ b/src/it/MPMD-348-JDK19/pom.xml
@@ -58,7 +58,6 @@ under the License.
4
true
${java.version}
- UTF-8
100
diff --git a/src/it/empty-rulesets/pom.xml b/src/it/empty-rulesets/pom.xml
index aa727dd3..9ec4f56f 100644
--- a/src/it/empty-rulesets/pom.xml
+++ b/src/it/empty-rulesets/pom.xml
@@ -52,7 +52,6 @@ under the License.
true
4
1.7
- UTF-8
100
**/*Bean.java
diff --git a/src/it/mpmd-168-empty-report/pom.xml b/src/it/mpmd-168-empty-report/pom.xml
index 1d0f0380..aaf54f0d 100644
--- a/src/it/mpmd-168-empty-report/pom.xml
+++ b/src/it/mpmd-168-empty-report/pom.xml
@@ -31,6 +31,10 @@ under the License.
Verify the "skipEmptyReport" parameter.
+
+ UTF-8
+
+
@@ -51,7 +55,6 @@ under the License.
true
25
- UTF-8
false
false
@@ -74,7 +77,7 @@ under the License.
org.apache.maven.plugins
maven-jxr-plugin
- 2.3
+ @jxrPluginVersion@
diff --git a/src/it/mpmd-168/pom.xml b/src/it/mpmd-168/pom.xml
index 7573801f..dda7dfff 100644
--- a/src/it/mpmd-168/pom.xml
+++ b/src/it/mpmd-168/pom.xml
@@ -31,6 +31,10 @@ under the License.
Verify the "skipEmptyReport" parameter.
+
+ UTF-8
+
+
@@ -51,7 +55,6 @@ under the License.
true
25
- UTF-8
false
false
true
@@ -74,7 +77,7 @@ under the License.
org.apache.maven.plugins
maven-jxr-plugin
- 2.3
+ @jxrPluginVersion@
diff --git a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
index afdce988..fcc9c2d1 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
@@ -49,7 +49,6 @@
import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.PathTool;
-import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import net.sourceforge.pmd.PMDVersion;
@@ -73,14 +72,6 @@ public abstract class AbstractPmdReport
@Parameter( property = "project.build.directory", required = true )
protected File targetDirectory;
- /**
- * The output directory for the final HTML report. Note that this parameter is only evaluated if the goal is run
- * directly from the command line or during the default lifecycle. If the goal is run indirectly as part of a site
- * generation, the output directory configured in the Maven Site Plugin is used instead.
- */
- @Parameter( property = "project.reporting.outputDirectory", required = true )
- protected File outputDirectory;
-
/**
* Set the output format type, in addition to the HTML report. Must be one of: "none", "csv", "xml", "txt" or the
* full class name of the PMD renderer to use. See the net.sourceforge.pmd.renderers package javadoc for available
@@ -172,22 +163,6 @@ public abstract class AbstractPmdReport
@Deprecated
protected boolean aggregate;
- /**
- * The file encoding to use when reading the Java sources.
- *
- * @since 2.3
- */
- @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
- private String sourceEncoding;
-
- /**
- * The file encoding when writing non-HTML reports.
- *
- * @since 2.5
- */
- @Parameter( property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}" )
- private String outputEncoding;
-
/**
* Whether to include the xml files generated by PMD/CPD in the site.
*
@@ -271,12 +246,6 @@ public abstract class AbstractPmdReport
// Read-only parameters
// ----------------------------------------------------------------------
- /**
- * The project to analyse.
- */
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
- protected MavenProject project;
-
/**
* The projects in the reactor for aggregation report.
*/
@@ -290,12 +259,6 @@ public abstract class AbstractPmdReport
@Parameter( defaultValue = "${session}", required = true, readonly = true )
protected MavenSession session;
- /**
- * Site rendering component for generating the HTML report.
- */
- @Component
- private Renderer siteRenderer;
-
@Component
private ToolchainManager toolchainManager;
@@ -588,32 +551,6 @@ public boolean canGenerateReport()
return true;
}
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getOutputDirectory()
- {
- return outputDirectory.getAbsolutePath();
- }
-
- protected String getSourceEncoding()
- {
- return sourceEncoding;
- }
-
- /**
- * Gets the effective reporting output files encoding.
- *
- * @return The effective reporting output file encoding, never null
.
- * @since 2.5
- */
- @Override
- protected String getOutputEncoding()
- {
- return ( outputEncoding != null ) ? outputEncoding : ReaderFactory.UTF_8;
- }
-
protected String determineCurrentRootLogLevel()
{
String logLevel = System.getProperty( "org.slf4j.simpleLogger.defaultLogLevel" );
@@ -694,9 +631,9 @@ protected Collection getAggregatedProjects()
/**
* Recursively add the modules of the aggregatedProject to the set of aggregatedModules.
- *
+ *
* @param aggregatedProject the project being aggregated
- * @param reactorProjectsMap map of (still) available reactor projects
+ * @param reactorProjectsMap map of (still) available reactor projects
* @throws MavenReportException if any
*/
private Set modulesForAggregatedProject( MavenProject aggregatedProject,
diff --git a/src/main/java/org/apache/maven/plugins/pmd/CpdReport.java b/src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
index 7bb71f54..1943c330 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
@@ -19,7 +19,6 @@
* under the License.
*/
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Locale;
@@ -34,8 +33,6 @@
import org.apache.maven.reporting.MavenReportException;
import org.apache.maven.shared.utils.logging.MessageUtils;
import org.apache.maven.toolchain.Toolchain;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.WriterFactory;
import net.sourceforge.pmd.cpd.JavaTokenizer;
import net.sourceforge.pmd.cpd.renderer.CPDRenderer;
@@ -134,36 +131,16 @@ public String getDescription( Locale locale )
public void executeReport( Locale locale )
throws MavenReportException
{
+ ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
try
{
- execute( locale );
+ Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader() );
+
+ generateMavenSiteReport( locale );
}
finally
{
- if ( getSink() != null )
- {
- getSink().close();
- }
- }
- }
-
- private void execute( Locale locale )
- throws MavenReportException
- {
- if ( !skip && canGenerateReport() )
- {
- ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader() );
-
- generateMavenSiteReport( locale );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( origLoader );
- }
-
+ Thread.currentThread().setContextClassLoader( origLoader );
}
}
@@ -230,7 +207,7 @@ private void executeCpd()
request.setMinimumTokens( minimumTokens );
request.setLanguage( language );
request.setLanguageProperties( languageProperties );
- request.setSourceEncoding( determineEncoding( !filesToProcess.isEmpty() ) );
+ request.setSourceEncoding( getInputEncoding() );
request.addFiles( filesToProcess.keySet() );
request.setShowPmdLog( showPmdLog );
@@ -257,7 +234,7 @@ private void executeCpd()
}
catch ( UnsupportedEncodingException e )
{
- throw new MavenReportException( "Encoding '" + getSourceEncoding() + "' is not supported.", e );
+ throw new MavenReportException( "Encoding '" + getInputEncoding() + "' is not supported.", e );
}
catch ( IOException e )
{
@@ -272,27 +249,6 @@ private void generateMavenSiteReport( Locale locale )
gen.generate( cpdResult.getDuplications() );
}
- private String determineEncoding( boolean showWarn )
- throws UnsupportedEncodingException
- {
- String encoding = WriterFactory.FILE_ENCODING;
- if ( StringUtils.isNotEmpty( getSourceEncoding() ) )
- {
-
- encoding = getSourceEncoding();
- // test encoding as CPD will convert exception into a RuntimeException
- WriterFactory.newWriter( new ByteArrayOutputStream(), encoding );
-
- }
- else if ( showWarn )
- {
- getLog().warn( "File encoding has not been set, using platform encoding " + WriterFactory.FILE_ENCODING
- + ", i.e. build is platform dependent!" );
- encoding = WriterFactory.FILE_ENCODING;
- }
- return encoding;
- }
-
/**
* {@inheritDoc}
*/
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
index b373bee0..9b0f202b 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -51,7 +51,6 @@
import org.codehaus.plexus.resource.loader.FileResourceCreationException;
import org.codehaus.plexus.resource.loader.FileResourceLoader;
import org.codehaus.plexus.resource.loader.ResourceNotFoundException;
-import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import net.sourceforge.pmd.renderers.Renderer;
@@ -287,35 +286,16 @@ public void setRulesets( String[] rulesets )
public void executeReport( Locale locale )
throws MavenReportException
{
+ ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
try
{
- execute( locale );
+ Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader() );
+
+ generateMavenSiteReport( locale );
}
finally
{
- if ( getSink() != null )
- {
- getSink().close();
- }
- }
- }
-
- private void execute( Locale locale )
- throws MavenReportException
- {
- if ( !skip && canGenerateReport() )
- {
- ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader() );
-
- generateMavenSiteReport( locale );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( origLoader );
- }
+ Thread.currentThread().setContextClassLoader( origLoader );
}
}
@@ -382,7 +362,7 @@ private void executePmd()
request.setLanguageAndVersion( language, targetJdk );
request.setRulesets( resolveRulesets() );
request.setAuxClasspath( typeResolution ? determineAuxClasspath() : null );
- request.setSourceEncoding( getSourceEncoding() );
+ request.setSourceEncoding( getInputEncoding() );
request.addFiles( filesToProcess.keySet() );
request.setMinimumPriority( minimumPriority );
request.setSuppressMarker( suppressMarker );
@@ -412,22 +392,6 @@ private void executePmd()
pmdResult = PmdExecutor.execute( request );
}
- protected String getSourceEncoding()
- {
- String encoding = super.getSourceEncoding();
- if ( StringUtils.isEmpty( encoding ) )
- {
- encoding = ReaderFactory.FILE_ENCODING;
- if ( !filesToProcess.isEmpty() )
- {
- getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
- + ", i.e. build is platform dependent!" );
- }
- }
- return encoding;
- }
-
-
/**
* Resolves the configured rulesets and copies them as files into the {@link #rulesetsTargetDirectory}.
*
diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm
index 6b91235a..99014e7d 100644
--- a/src/site/apt/usage.apt.vm
+++ b/src/site/apt/usage.apt.vm
@@ -74,7 +74,7 @@ Configuration
The reports will link directly to the cross-referenced source if you enable this with the <<>> parameter.
See the {{{http://maven.apache.org/plugins/maven-jxr-plugin/}JXR plugin}} for more details.
- If your source uses a non-default encoding, you can use the <<>> parameter to tell Maven which
+ If your source uses a non-default encoding, you can use the <<>> parameter to tell Maven which
encoding to use when reading the java source. Note also the ability to exclude source which you want
to ignore.
@@ -95,7 +95,7 @@ Configuration
${project.version}
true
- utf-8
+ utf-8
100
1.5
diff --git a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTest.java
deleted file mode 100644
index 3656d0d1..00000000
--- a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.apache.maven.plugins.pmd;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Locale;
-
-import org.apache.maven.doxia.site.decoration.DecorationModel;
-import org.apache.maven.doxia.siterenderer.DocumentContent;
-import org.apache.maven.doxia.siterenderer.RendererException;
-import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
-import org.apache.maven.execution.DefaultMavenExecutionRequest;
-import org.apache.maven.execution.MavenExecutionRequest;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.Mojo;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.codehaus.plexus.util.ReflectionUtils;
-import org.codehaus.plexus.util.WriterFactory;
-
-/**
- * @author Vincent Siveton
- * @version $Id$
- * @since 2.5
- */
-public abstract class AbstractPmdReportTest
- extends AbstractMojoTestCase
-{
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- CapturingPrintStream.init( true );
- }
-
- /**
- * Renderer the sink from the report mojo.
- *
- * @param mojo not null
- * @param outputHtml not null
- * @throws RendererException if any
- * @throws IOException if any
- */
- protected void renderer( AbstractPmdReport mojo, File outputHtml )
- throws RendererException, IOException
- {
- SiteRenderingContext context = new SiteRenderingContext();
- context.setDecoration( new DecorationModel() );
- context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
- context.setLocale( Locale.ENGLISH );
-
- outputHtml.getParentFile().mkdirs();
-
- try ( Writer writer = WriterFactory.newXmlWriter( outputHtml ) )
- {
- mojo.getSiteRenderer().mergeDocumentIntoSite( writer, (DocumentContent) mojo.getSink(), context );
- }
- }
-
- /**
- * 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
.
- */
- public static boolean lowerCaseContains( String text, String contains )
- {
- return text.toLowerCase( Locale.ROOT ).contains( contains.toLowerCase( Locale.ROOT ) );
- }
-
- @Override
- protected Mojo lookupMojo( String goal, File pom ) throws Exception
- {
- Mojo mojo = super.lookupMojo( goal, pom );
- return mockMavenSession( mojo );
- }
-
- private Mojo mockMavenSession(Mojo mojo) throws IllegalAccessException {
- String basedir = getBasedir();
- if ( ReflectionUtils.getFieldByNameIncludingSuperclasses( "session", mojo.getClass() ) != null )
- {
- MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest() {
- public String getBaseDirectory() {
- return basedir;
- };
- };
- ReflectionUtils.setVariableValueInObject( mojo, "session",
- new MavenSession( null, null, executionRequest, null ) );
- }
- return mojo;
- }
-}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
new file mode 100644
index 00000000..f0d5524c
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
@@ -0,0 +1,168 @@
+package org.apache.maven.plugins.pmd;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.Locale;
+
+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.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;
+import org.eclipse.aether.repository.LocalRepository;
+
+/**
+ * @author Vincent Siveton
+ * @version $Id$
+ * @since 2.5
+ */
+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();
+ CapturingPrintStream.init( true );
+
+ artifactStubFactory = new DependencyArtifactStubFactory( getTestFile( "target" ), true, false );
+ artifactStubFactory.getWorkingDir().mkdirs();
+ }
+
+ /**
+ * Get the current Maven project
+ *
+ * @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/".
+ * @return the generated HTML file
+ * @throws Exception if any
+ */
+ protected File generateReport( String goal, String pluginXml )
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(), "src/test/resources/unit/" + pluginXml );
+ AbstractPmdReport mojo = createReportMojo( goal, pluginXmlFile );
+ return generateReport( mojo, pluginXmlFile );
+ }
+
+ protected AbstractPmdReport createReportMojo( String goal, File pluginXmlFile )
+ throws Exception
+ {
+ AbstractPmdReport mojo = (AbstractPmdReport) lookupMojo( goal, pluginXmlFile );
+ assertNotNull( "Mojo not found.", mojo );
+
+ LegacySupport legacySupport = lookup( LegacySupport.class );
+ legacySupport.setSession( newMavenSession( new MavenProjectStub() ) );
+ DefaultRepositorySystemSession repoSession =
+ (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
+ repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, new LocalRepository( artifactStubFactory.getWorkingDir() ) ) );
+
+ setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+ setVariableValueToObject( mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories() );
+ return mojo;
+ }
+
+ 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.getOutputName() + ".html";
+
+ return new File( outputDir, filename );
+ }
+
+ /**
+ * Read the contents of the specified file object into a string
+ */
+ protected String readFile( File pmdTestDir, String fileName ) throws IOException
+ {
+ return new String( Files.readAllBytes( pmdTestDir.toPath().resolve( fileName ) ) );
+ }
+
+
+ /**
+ * 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
.
+ */
+ public static boolean lowerCaseContains( String text, String contains )
+ {
+ return text.toLowerCase( Locale.ROOT ).contains( contains.toLowerCase( Locale.ROOT ) );
+ }
+}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
index 4970975e..efb3d581 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
@@ -37,7 +37,7 @@
* @version $Id$
*/
public class CpdReportTest
- extends AbstractPmdReportTest
+ extends AbstractPmdReportTestCase
{
/**
* {@inheritDoc}
@@ -59,22 +59,15 @@ protected void setUp()
public void testDefaultConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "cpd", "default-configuration/cpd-default-configuration-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check if the CPD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/cpd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
// check the contents of cpd.html
- String str = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/cpd.html" ) );
+ String str = readFile( generatedReport );
assertTrue( lowerCaseContains( str, "AppSample.java" ) );
assertTrue( lowerCaseContains( str, "App.java" ) );
assertTrue( lowerCaseContains( str, "public String dup( String str )" ) );
@@ -93,11 +86,7 @@ public void testDefaultConfiguration()
public void testTxtFormat()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ generateReport( "cpd", "custom-configuration/cpd-txt-format-configuration-plugin-config.xml" );
// check if the CPD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/cpd.xml" );
@@ -121,35 +110,20 @@ public void testTxtFormat()
public void testCustomConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "cpd", "custom-configuration/cpd-custom-configuration-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check if the CPD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/cpd.csv" );
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
+ String str = readFile( generatedReport );
// Contents that should NOT be in the report
- String str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) );
assertFalse( lowerCaseContains( str, "/Sample.java" ) );
-
- str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) );
assertFalse( lowerCaseContains( str, "public void duplicateMethod( int i )" ) );
-
// Contents that should be in the report
- str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) );
assertTrue( lowerCaseContains( str, "AnotherSample.java" ) );
-
- str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) );
assertTrue( lowerCaseContains( str, "public static void main( String[] args )" ) );
-
- str = readFile( new File( getBasedir(), "target/test/unit/custom-configuration/target/site/cpd.html" ) );
assertTrue( lowerCaseContains( str, "private String unusedMethod(" ) );
}
@@ -164,10 +138,10 @@ public void testInvalidFormat()
try
{
File testPom =
- new File( getBasedir(), "src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- setVariableValueToObject( mojo, "compileSourceRoots", mojo.project.getCompileSourceRoots() );
- mojo.execute();
+ new File( getBasedir(), "src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml" );
+ AbstractPmdReport mojo = createReportMojo( "cpd", testPom );
+ setVariableValueToObject( mojo, "compileSourceRoots", mojo.getProject().getCompileSourceRoots() );
+ generateReport( mojo, testPom );
fail( "MavenReportException must be thrown" );
}
@@ -205,20 +179,17 @@ private String readFile( File file )
public void testWriteNonHtml()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- assertNotNull( mojo );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-default-configuration-plugin-config.xml" );
- File tReport = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
+ // check if the CPD files were generated
+ File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
+ assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document pmdCpdDocument = builder.parse( tReport );
+ Document pmdCpdDocument = builder.parse( generatedFile );
assertNotNull( pmdCpdDocument );
- String str = readFile( tReport );
+ String str = readFile( generatedFile );
assertTrue( lowerCaseContains( str, "AppSample.java" ) );
assertTrue( lowerCaseContains( str, "App.java" ) );
assertTrue( lowerCaseContains( str, "public String dup( String str )" ) );
@@ -232,21 +203,16 @@ public void testWriteNonHtml()
public void testIncludeXmlInSite()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/cpd-report-include-xml-in-site-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- assertNotNull( mojo );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-report-include-xml-in-site-plugin-config.xml" );
- File tReport = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
- assertTrue( FileUtils.fileExists( tReport.getAbsolutePath() ) );
+ File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
+ assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document pmdCpdDocument = builder.parse( tReport );
+ Document pmdCpdDocument = builder.parse( generatedFile );
assertNotNull( pmdCpdDocument );
- String str = readFile( tReport );
+ String str = readFile( generatedFile );
assertTrue( str.contains( "" ) );
File siteReport = new File( getBasedir(), "target/test/unit/default-configuration/target/site/cpd.xml" );
@@ -260,28 +226,19 @@ public void testIncludeXmlInSite()
public void testSkipEmptyReportConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(), "src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
-
// verify the generated files do not exist because PMD was skipped
- File generatedFile = new File( getBasedir(), "target/test/unit/empty-report/target/site/cpd.html" );
- assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+ File generatedReport = generateReport( "cpd", "empty-report/cpd-skip-empty-report-plugin-config.xml" );
+ assertFalse( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
}
public void testEmptyReportConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(), "src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
-
// verify the generated files do exist, even if there are no violations
- File generatedFile = new File( getBasedir(), "target/test/unit/empty-report/target/site/cpd.html" );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- String str = readFile( new File( getBasedir(), "target/test/unit/empty-report/target/site/cpd.html" ) );
+ File generatedReport = generateReport( "cpd", "empty-report/cpd-empty-report-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
+
+ String str = readFile( generatedReport );
assertFalse( lowerCaseContains( str, "Hello.java" ) );
assertTrue( str.contains( "CPD found no problems in your source code." ) );
}
@@ -294,11 +251,7 @@ public void testCpdEncodingConfiguration()
{
System.setProperty( "file.encoding", "UTF-16" );
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-default-configuration-plugin-config.xml" );
// check if the CPD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
@@ -315,43 +268,33 @@ public void testCpdEncodingConfiguration()
public void testCpdJavascriptConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(), "src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-javascript-plugin-config.xml" );
- // verify the generated file to exist and violations are reported
- File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- String str = readFile( generatedFile );
- assertTrue( lowerCaseContains( str, "Sample.js" ) );
- assertTrue( lowerCaseContains( str, "SampleDup.js" ) );
+ // verify the generated file to exist and violations are reported
+ File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
+ assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+ String str = readFile( generatedFile );
+ assertTrue( lowerCaseContains( str, "Sample.js" ) );
+ assertTrue( lowerCaseContains( str, "SampleDup.js" ) );
}
public void testCpdJspConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(), "src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml" );
- CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-jsp-plugin-config.xml" );
- // verify the generated file to exist and violations are reported
- File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- String str = readFile( generatedFile );
- assertTrue( lowerCaseContains( str, "sample.jsp" ) );
- assertTrue( lowerCaseContains( str, "sampleDup.jsp" ) );
+ // verify the generated file to exist and violations are reported
+ File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
+ assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+ String str = readFile( generatedFile );
+ assertTrue( lowerCaseContains( str, "sample.jsp" ) );
+ assertTrue( lowerCaseContains( str, "sampleDup.jsp" ) );
}
public void testExclusionsConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml" );
- final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml" );
// verify the generated file to exist and no duplications are reported
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml" );
diff --git a/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java b/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java
index b70ae8eb..31adb8c2 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java
@@ -26,24 +26,20 @@
* @version $Id$
*/
public class CpdViolationCheckMojoTest
- extends AbstractPmdReportTest
+ extends AbstractPmdReportTestCase
{
public void testDefaultConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
- final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-default-configuration-plugin-config.xml" );
// clear the output from previous pmd:cpd execution
CapturingPrintStream.init( true );
try
{
- testPom =
+ File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-default-configuration-plugin-config.xml" );
final CpdViolationCheckMojo cpdViolationMojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom );
@@ -65,13 +61,9 @@ public void testNotFailOnViolation()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
- final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-default-configuration-plugin-config.xml" );
- testPom =
+ File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/cpd-check-notfailonviolation-plugin-config.xml" );
final CpdViolationCheckMojo cpdViolationMojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom );
@@ -102,13 +94,9 @@ public void testException()
public void testExclusionsConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
- final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
- mojo.execute();
+ generateReport( "cpd", "default-configuration/cpd-default-configuration-plugin-config.xml" );
- testPom =
+ File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/cpd-check-cpd-exclusions-configuration-plugin-config.xml" );
final CpdViolationCheckMojo cpdViolationMojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom );
diff --git a/src/test/java/org/apache/maven/plugins/pmd/DependencyArtifactStubFactory.java b/src/test/java/org/apache/maven/plugins/pmd/DependencyArtifactStubFactory.java
new file mode 100644
index 00000000..7cd70cdc
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/pmd/DependencyArtifactStubFactory.java
@@ -0,0 +1,69 @@
+package org.apache.maven.plugins.pmd;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.plugin.testing.ArtifactStubFactory;
+
+public class DependencyArtifactStubFactory
+ extends ArtifactStubFactory
+{
+ private boolean flattenedPath = true;
+
+ public DependencyArtifactStubFactory( File theWorkingDir, boolean theCreateFiles, boolean flattenedPath )
+ {
+ this( theWorkingDir, theCreateFiles );
+ this.flattenedPath = flattenedPath;
+ }
+
+ public DependencyArtifactStubFactory( File theWorkingDir, boolean theCreateFiles )
+ {
+ super( theWorkingDir, theCreateFiles );
+ }
+
+ @Override
+ public Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String scope,
+ String type, String classifier, boolean optional )
+ throws IOException
+ {
+ File workingDir = getWorkingDir();
+
+ if ( !flattenedPath )
+ {
+ // don't use flatten directories, won't happen at runtime
+ String path = groupId.replace( '.', '/' ) + '/' +
+ artifactId + '/' +
+ ArtifactUtils.toSnapshotVersion( versionRange.getRecommendedVersion().toString() );
+ setWorkingDir( new File( workingDir, path ) );
+ }
+
+ Artifact artifact =
+ super.createArtifact( groupId, artifactId, versionRange, scope, type, classifier, optional );
+
+ setWorkingDir( workingDir );
+
+ return artifact;
+ }
+}
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index c8ddae3f..d53ba481 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -44,7 +44,7 @@
* @version $Id$
*/
public class PmdReportTest
- extends AbstractPmdReportTest
+ extends AbstractPmdReportTestCase
{
/**
@@ -66,11 +66,8 @@ public void testDefaultConfiguration()
"src/test/resources/unit/default-configuration/jxr-files" ),
new File( getBasedir(), "target/test/unit/default-configuration/target/site" ) );
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "default-configuration/default-configuration-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check if the PMD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" );
@@ -80,12 +77,8 @@ public void testDefaultConfiguration()
generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd/rulesets/maven-pmd-plugin-default.xml" );
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
// check if there's a link to the JXR files
- String str = readFile( generatedFile );
+ String str = readFile( generatedReport );
assertTrue( str.contains( "/xref/def/configuration/App.html#L31" ) );
@@ -123,17 +116,10 @@ public void testDefaultConfigurationNotRenderRuleViolationPriority()
"src/test/resources/unit/default-configuration/jxr-files" ),
new File( getBasedir(), "target/test/unit/default-configuration/target/site" ) );
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
- File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
- String str = readFile( generatedFile );
+ String str = readFile( generatedReport );
// check that there's no priority column
assertFalse( str.contains( "Priority | " ) );
@@ -141,30 +127,23 @@ public void testDefaultConfigurationNotRenderRuleViolationPriority()
public void testDefaultConfigurationNoRenderViolationsByPriority()
throws Exception
- {
- FileUtils.copyDirectoryStructure( new File( getBasedir(),
- "src/test/resources/unit/default-configuration/jxr-files" ),
- new File( getBasedir(), "target/test/unit/default-configuration/target/site" ) );
+ {
+ FileUtils.copyDirectoryStructure( new File( getBasedir(),
+ "src/test/resources/unit/default-configuration/jxr-files" ),
+ new File( getBasedir(), "target/test/unit/default-configuration/target/site" ) );
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
-
- File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
- String str = readFile( generatedFile );
-
- // there should be no section Violations By Priority
- assertFalse( str.contains( "Violations By Priority" ) );
- assertFalse( str.contains( "Priority 3" ) );
- assertFalse( str.contains( "Priority 4" ) );
- // the file App.java is mentioned once: in the files section
- assertEquals( 1, StringUtils.countMatches( str, "def/configuration/App.java" ) );
- }
+ File generatedReport = generateReport( "pmd", "default-configuration/pmd-report-no-render-violations-by-priority.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
+
+ String str = readFile( generatedReport );
+
+ // there should be no section Violations By Priority
+ assertFalse( str.contains( "Violations By Priority" ) );
+ assertFalse( str.contains( "Priority 3" ) );
+ assertFalse( str.contains( "Priority 4" ) );
+ // the file App.java is mentioned once: in the files section
+ assertEquals( 1, StringUtils.countMatches( str, "def/configuration/App.java" ) );
+ }
public void testDefaultConfigurationWithAnalysisCache()
@@ -174,11 +153,7 @@ public void testDefaultConfigurationWithAnalysisCache()
"src/test/resources/unit/default-configuration/jxr-files" ),
new File( getBasedir(), "target/test/unit/pmd-with-analysis-cache-plugin-config/target/site" ) );
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ generateReport( "pmd", "default-configuration/pmd-with-analysis-cache-plugin-config.xml" );
// check if the PMD analysis cache file has been generated
File cacheFile = new File( getBasedir(), "target/test/unit/pmd-with-analysis-cache-plugin-config/target/pmd/pmd.cache" );
@@ -188,11 +163,8 @@ public void testDefaultConfigurationWithAnalysisCache()
public void testJavascriptConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "default-configuration/javascript-configuration-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check if the PMD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" );
@@ -208,11 +180,7 @@ public void testJavascriptConfiguration()
generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd/rulesets/errorprone.xml" );
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
- String str = readFile( generatedFile );
+ String str = readFile( generatedReport );
assertTrue( str.contains( "Avoid using global variables" ) );
}
@@ -226,7 +194,7 @@ public void testFileURL()
File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
+ PmdReport mojo = (PmdReport) createReportMojo( "pmd", testPom );
// Additional test case for MPMD-174 (https://issues.apache.org/jira/browse/MPMD-174).
int port = determineFreePort();
@@ -257,7 +225,8 @@ public void testFileURL()
URL url3 = getClass().getClassLoader().getResource( "rulesets/java/imports.xml" );
mojo.setRulesets( new String[] { url.toString(), url2.toString(), url3.toString(), sonarExportRulesetUrl } );
- mojo.execute();
+ File generatedReport = generateReport( mojo, testPom );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check if the PMD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" );
@@ -278,12 +247,8 @@ public void testFileURL()
"target/test/unit/default-configuration/target/pmd/rulesets/export_format_pmd_language_java_name_Sonar_2520way.xml" );
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
// check if there's a link to the JXR files
- String str = readFile( generatedFile );
+ String str = readFile( generatedReport );
assertTrue( str.contains( "/xref/def/configuration/App.html#L31" ) );
@@ -309,12 +274,8 @@ private int determineFreePort()
public void testCustomConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml" );
-
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "custom-configuration/custom-configuration-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check the generated files
File generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/pmd.csv" );
@@ -323,12 +284,8 @@ public void testCustomConfiguration()
generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/pmd/rulesets/custom.xml" );
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
// check if custom ruleset was applied
- String str = readFile( generatedFile );
+ String str = readFile( generatedReport );
// codestyle.xml/ControlStatementBraces:
assertTrue( lowerCaseContains( str, "This statement should have braces" ) );
@@ -353,9 +310,8 @@ public void testCustomConfiguration()
public void testSkipConfiguration()
throws Exception
{
- File testPom = new File( getBasedir(), "src/test/resources/unit/custom-configuration/skip-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "custom-configuration/skip-plugin-config.xml" );
+ assertFalse( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// verify the generated files do not exist because PMD was skipped
File generatedFile = new File( getBasedir(), "target/test/unit/skip-configuration/target/pmd.csv" );
@@ -364,9 +320,6 @@ public void testSkipConfiguration()
generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/custom.xml" );
assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/site/pmd.html" );
- assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
// the fact, the PMD execution has been skipped, should be logged
String output = CapturingPrintStream.getOutput();
assertTrue ( output.contains( "Skipping PMD execution" ) );
@@ -375,27 +328,19 @@ public void testSkipConfiguration()
public void testSkipEmptyReportConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(), "src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
-
// verify the generated files do not exist because PMD was skipped
- File generatedFile = new File( getBasedir(), "target/test/unit/empty-report/target/site/pmd.html" );
- assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+ File generatedReport = generateReport( "pmd", "empty-report/skip-empty-report-plugin-config.xml" );
+ assertFalse( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
}
public void testEmptyReportConfiguration()
throws Exception
{
- File testPom = new File( getBasedir(), "src/test/resources/unit/empty-report/empty-report-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "empty-report/empty-report-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// verify the generated files do exist, even if there are no violations
- File generatedFile = new File( getBasedir(), "target/test/unit/empty-report/target/site/pmd.html" );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- String str = readFile( generatedFile );
+ String str = readFile( generatedReport );
assertFalse( lowerCaseContains( str, "Hello.java" ) );
assertEquals( 1, StringUtils.countMatches( str, "PMD found no problems in your source code." ) );
// no sections files or violations by priority
@@ -409,10 +354,10 @@ public void testInvalidFormat()
try
{
File testPom =
- new File( getBasedir(), "src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- setVariableValueToObject( mojo, "compileSourceRoots", mojo.project.getCompileSourceRoots() );
- mojo.executeReport( Locale.ENGLISH );
+ new File( getBasedir(), "src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml" );
+ AbstractPmdReport mojo = createReportMojo( "pmd", testPom );
+ setVariableValueToObject( mojo, "compileSourceRoots", mojo.getProject().getCompileSourceRoots() );
+ generateReport( mojo, testPom );
fail( "Must throw MavenReportException." );
}
@@ -427,10 +372,7 @@ public void testInvalidTargetJdk()
{
try
{
- File testPom =
- new File( getBasedir(), "src/test/resources/unit/invalid-format/invalid-target-jdk-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ generateReport( "pmd", "empty-report/invalid-format/invalid-target-jdk-plugin-config.xml" );
fail( "Must throw MavenReportException." );
}
@@ -447,12 +389,9 @@ public void testInvalidTargetJdk()
public void testIncludeXmlInSite()
throws Exception
{
- File testPom = new File( getBasedir(), "src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "default-configuration/pmd-report-include-xml-in-site-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
- File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
// verify the pmd file is included in site
File generatedXmlFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.xml" );
assertTrue( FileUtils.fileExists( generatedXmlFile.getAbsolutePath() ) );
@@ -517,11 +456,8 @@ public void testLocationTemp()
public void testSuppressMarkerConfiguration()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "default-configuration/pmd-with-suppressMarker-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check if the PMD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" );
@@ -534,12 +470,8 @@ public void testSuppressMarkerConfiguration()
// but it appears as suppressed
assertTrue( str.contains( "suppressiontype=\"nopmd\" msg=\"Avoid unused private fields such as 'unusedVar2'.\"" ));
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
// check if there's a link to the JXR files
- str = readFile( generatedFile );
+ str = readFile( generatedReport );
assertTrue( str.contains( "/xref/def/configuration/AppSample.html#L27" ) );
// suppressed violation
@@ -549,11 +481,8 @@ public void testSuppressMarkerConfiguration()
public void testSuppressMarkerConfigurationWithoutRendering()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check if the PMD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" );
@@ -566,12 +495,8 @@ public void testSuppressMarkerConfigurationWithoutRendering()
// but it appears as suppressed
assertTrue( str.contains( "suppressiontype=\"nopmd\" msg=\"Avoid unused private fields such as 'unusedVar2'.\"" ));
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
// check if there's a link to the JXR files
- str = readFile( generatedFile );
+ str = readFile( generatedReport );
assertTrue( str.contains( "/xref/def/configuration/AppSample.html#L27" ) );
// suppressed violations are not rendered
@@ -579,12 +504,10 @@ public void testSuppressMarkerConfigurationWithoutRendering()
}
public void testJspConfiguration()
- throws Exception
+ throws Exception
{
- File testPom = new File( getBasedir(),
- "src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ File generatedReport = generateReport( "pmd", "default-configuration/jsp-configuration-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
// check if the PMD files were generated
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" );
@@ -606,24 +529,17 @@ public void testJspConfiguration()
generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd/rulesets/security.xml" );
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
-
- String str = readFile( generatedFile );
+ String str = readFile( generatedReport );
assertTrue(str.contains("JSP file should use UTF-8 encoding"));
assertTrue(str.contains("Using unsanitized JSP expression can lead to Cross Site Scripting (XSS) attacks"));
assertTrue(str.contains("Avoid having style information in JSP files."));
}
public void testPMDProcessingError()
- throws Exception
+ throws Exception
{
- File testPom = new File( getBasedir(),
- "src/test/resources/unit/processing-error/pmd-processing-error-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
try {
- mojo.execute();
+ generateReport( "pmd", "processing-error/pmd-processing-error-plugin-config.xml" );
fail("Expected exception");
} catch (RuntimeException e) {
assertTrue( e.getMessage().endsWith( "Found 1 PMD processing errors" ) );
@@ -631,13 +547,11 @@ public void testPMDProcessingError()
}
public void testPMDProcessingErrorWithDetailsSkipped()
- throws Exception
+ throws Exception
{
- File testPom = new File( getBasedir(),
- "src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
+ File generatedReport = generateReport( "pmd", "processing-error/pmd-processing-error-skip-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
- mojo.execute();
String output = CapturingPrintStream.getOutput();
assertTrue ( output.contains( "There are 1 PMD processing errors:" ) );
@@ -648,22 +562,17 @@ public void testPMDProcessingErrorWithDetailsSkipped()
// The parse exception must be in the XML report
assertTrue( str.contains( "ParseException: Encountered \"\" at line 23, column 5." ) );
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- str = readFile( generatedFile );
+ str = readFile( generatedReport );
// The parse exception must also be in the HTML report
assertTrue( str.contains( "ParseException: Encountered \"\" at line 23, column 5." ) );
}
public void testPMDProcessingErrorWithDetailsNoReport()
- throws Exception
+ throws Exception
{
- File testPom = new File( getBasedir(),
- "src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
+ File generatedReport = generateReport( "pmd", "processing-error/pmd-processing-error-no-report-plugin-config.xml" );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
- mojo.execute();
String output = CapturingPrintStream.getOutput();
assertTrue ( output.contains( "There are 1 PMD processing errors:" ) );
@@ -674,43 +583,36 @@ public void testPMDProcessingErrorWithDetailsNoReport()
// The parse exception must be in the XML report
assertTrue( str.contains( "ParseException: Encountered \"\" at line 23, column 5." ) );
- generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
- renderer( mojo, generatedFile );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- str = readFile( generatedFile );
+ str = readFile( generatedReport );
// The parse exception must NOT be in the HTML report, since reportProcessingErrors is false
assertFalse( str.contains( "ParseException: Encountered \"\" at line 23, column 5." ) );
}
- public void testPMDExcludeRootsShouldExcludeSubdirectories() throws Exception {
- File testPom = new File(getBasedir(), "src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml");
- PmdReport mojo = (PmdReport) lookupMojo ("pmd", testPom);
- mojo.execute();
+ public void testPMDExcludeRootsShouldExcludeSubdirectories()
+ throws Exception
+ {
+ generateReport( "pmd", "exclude-roots/pmd-exclude-roots-plugin-config.xml" );
File generatedFile = new File( getBasedir(), "target/test/unit/exclude-roots/target/pmd.xml" );
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
String str = readFile( generatedFile );
- assertTrue( "Seems like all directories are excluded now", str.contains("ForLoopShouldBeWhileLoop") );
+ assertTrue( "Seems like all directories are excluded now", str.contains( "ForLoopShouldBeWhileLoop" ) );
assertFalse( "Exclusion of an exact source directory not working", str.contains( "OverrideBothEqualsAndHashcode" ) );
assertFalse( "Exclusion of basedirectory with subdirectories not working (MPMD-178)", str.contains( "JumbledIncrementer") );
}
public void testViolationExclusion()
- throws Exception
- {
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml" );
- final PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ throws Exception
+ {
+ generateReport( "pmd", "default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml" );
- File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" );
- assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
- String str = readFile( generatedFile );
+ File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" );
+ assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+ String str = readFile( generatedFile );
- assertEquals(0, StringUtils.countMatches(str, "CustomRule" ) );
@@ -785,11 +680,11 @@ public void testPmdReportResolveRulesets()
File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml" );
- PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
+ PmdReport mojo = (PmdReport) createReportMojo( "pmd", testPom );
mojo.rulesets[3] = sonarExportRulesetUrl;
mojo.rulesets[4] = myRulesetUrl;
mojo.rulesets[5] = notAInternalRulesetUrl;
- mojo.execute();
+ generateReport( mojo, testPom );
// these are the rulesets, that have been copied to target/pmd/rulesets
File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/pmd/rulesets/custom-rules.xml" );
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoTest.java
index d5815813..e97fc8ad 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoTest.java
@@ -28,17 +28,13 @@
* @version $Id$
*/
public class PmdViolationCheckMojoTest
- extends AbstractPmdReportTest
+ extends AbstractPmdReportTestCase
{
public void testDefaultConfiguration()
throws Exception
{
- File testPomPmd =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" );
- final PmdReport pmdMojo = (PmdReport) lookupMojo( "pmd", testPomPmd );
- pmdMojo.execute();
+ generateReport( "pmd", "default-configuration/default-configuration-plugin-config.xml" );
// clear the output from previous pmd:pmd execution
CapturingPrintStream.init( true );
@@ -66,13 +62,9 @@ public void testDefaultConfiguration()
public void testNotFailOnViolation()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" );
- final PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ generateReport( "pmd", "default-configuration/default-configuration-plugin-config.xml" );
- testPom =
+ File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-notfailonviolation-plugin-config.xml" );
final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo( "check", testPom );
@@ -84,13 +76,9 @@ public void testNotFailOnViolation()
public void testMaxAllowedViolations()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" );
- final PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ generateReport( "pmd", "default-configuration/default-configuration-plugin-config.xml" );
- testPom =
+ File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-notfailmaxviolation-plugin-config.xml" );
final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo( "check", testPom );
@@ -125,13 +113,9 @@ public void testMaxAllowedViolations()
public void testFailurePriority()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" );
- final PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ generateReport( "pmd", "default-configuration/default-configuration-plugin-config.xml" );
- testPom =
+ File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-failonpriority-plugin-config.xml" );
PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo( "check", testPom );
@@ -185,13 +169,9 @@ public void testException()
public void testViolationExclusion()
throws Exception
{
- File testPom =
- new File( getBasedir(),
- "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" );
- final PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
- mojo.execute();
+ generateReport( "pmd", "default-configuration/default-configuration-plugin-config.xml" );
- testPom =
+ File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-pmd-exclusions-configuration-plugin-config.xml" );
final PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo( "check", testPom );
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
index 90033500..4fe1d674 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
@@ -30,14 +30,13 @@
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Scm;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
/**
* @author Maria Odea Ching
* @version $Id$
*/
public class CustomConfigurationMavenProjectStub
- extends MavenProjectStub
+ extends PmdProjectStub
{
private Build build;
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
index 3093e14d..daac7959 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
@@ -30,14 +30,13 @@
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Scm;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
/**
* @author Maria Odea Ching
* @version $Id$
*/
public class DefaultConfigurationMavenProjectStub
- extends MavenProjectStub
+ extends PmdProjectStub
{
private List reportPlugins = new ArrayList<>();
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
index 293ecf93..f7003139 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
@@ -29,14 +29,13 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.Scm;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
/**
* @author Maria Odea Ching
* @version $Id$
*/
public class InvalidFormatMavenProjectStub
- extends MavenProjectStub
+ extends PmdProjectStub
{
private Build build;
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java
new file mode 100644
index 00000000..0b8f6f93
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java
@@ -0,0 +1,42 @@
+package org.apache.maven.plugins.pmd.stubs;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+public abstract class PmdProjectStub
+ extends MavenProjectStub
+{
+ @Override
+ public List getRemoteArtifactRepositories()
+ {
+ ArtifactRepository repository = new MavenArtifactRepository( "central", "https://repo1.maven.org/maven2",
+ new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );
+
+ return Collections.singletonList( repository );
+ }
+}
diff --git a/src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml b/src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml
index e9631341..35955898 100644
--- a/src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml
+++ b/src/test/resources/unit/custom-configuration/cpd-custom-configuration-plugin-config.xml
@@ -36,6 +36,7 @@ under the License.
${basedir}/target/test/unit/custom-configuration/target/site
${basedir}/target/test/unit/custom-configuration/target
+ ${localRepository}
csv
false
${basedir}/target/test/unit/custom-configuration/target/site/xref
@@ -46,7 +47,7 @@ under the License.
${basedir}/src/test/resources/unit/custom-configuration/
- UTF-8
+ UTF-8
diff --git a/src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml b/src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml
index 5ea54155..eb7d1fe3 100644
--- a/src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml
+++ b/src/test/resources/unit/custom-configuration/cpd-txt-format-configuration-plugin-config.xml
@@ -36,14 +36,14 @@ under the License.
${basedir}/target/test/unit/custom-configuration/target/site
${basedir}/target/test/unit/custom-configuration/target
+ ${localRepository}
txt
false
30
-
${basedir}/src/test/resources/unit/custom-configuration/
- UTF-8
+ UTF-8
diff --git a/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml b/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
index b99ab019..8cfd6ef5 100644
--- a/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
+++ b/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
@@ -36,17 +36,18 @@ under the License.
${basedir}/target/test/unit/custom-configuration/target/site
${basedir}/target/test/unit/custom-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/custom-configuration/target/pmd/rulesets
csv
true
${basedir}/target/test/unit/custom-configuration/target/site/xref
- ISO-8859-1
+ ISO-8859-1
rulesets/java/maven-pmd-plugin-default.xml
${basedir}/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml
1.4
- 4
+ 4
**/Sample.java
**/AnotherSample.java
@@ -54,7 +55,6 @@ under the License.
${basedir}/src/test/resources/unit/custom-configuration/
- UTF-8
diff --git a/src/test/resources/unit/custom-configuration/skip-plugin-config.xml b/src/test/resources/unit/custom-configuration/skip-plugin-config.xml
index 0705d31c..6f6f159e 100644
--- a/src/test/resources/unit/custom-configuration/skip-plugin-config.xml
+++ b/src/test/resources/unit/custom-configuration/skip-plugin-config.xml
@@ -40,9 +40,9 @@ under the License.
csv
true
${basedir}/target/test/unit/skip-configuration/target/site/xref
- ISO-8859-1
+ ISO-8859-1
1.4
- 4
+ 4
true
diff --git a/src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml
index 4df189f0..e57fe5d3 100644
--- a/src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml
@@ -36,15 +36,15 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
100
-
${basedir}/src/test/resources/unit/default-configuration/
- UTF-8
+ UTF-8
diff --git a/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml
index ae0d7803..66b45328 100644
--- a/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml
@@ -40,12 +40,10 @@ under the License.
false
${basedir}/target/test/unit/default-configuration/target/site/xref
100
-
${basedir}/src/test/resources/unit/default-configuration/
-
- UTF-8
+ UTF-8
diff --git a/src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml
index 3d7ad68f..f7e045ad 100644
--- a/src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-javascript-plugin-config.xml
@@ -35,6 +35,7 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
@@ -43,11 +44,10 @@ under the License.
**/*.js
-
${basedir}/src/test/resources/unit/default-configuration/
- UTF-8
+ UTF-8
diff --git a/src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml
index 27ce2204..6ad62d0b 100644
--- a/src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-jsp-plugin-config.xml
@@ -35,6 +35,7 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
@@ -43,11 +44,10 @@ under the License.
**/*.jsp
-
${basedir}/src/test/resources/unit/default-configuration/
- UTF-8
+ UTF-8
diff --git a/src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml
index 83a5d455..85ea1918 100644
--- a/src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-report-cpd-exclusions-configuration-plugin-config.xml
@@ -36,15 +36,15 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
100
-
${basedir}/src/test/resources/unit/default-configuration/
- UTF-8
+ UTF-8
${basedir}/src/test/resources/unit/excludes/my-exclude-cpd.properties
diff --git a/src/test/resources/unit/default-configuration/cpd-report-include-xml-in-site-plugin-config.xml b/src/test/resources/unit/default-configuration/cpd-report-include-xml-in-site-plugin-config.xml
index cccb881c..7920f0a4 100644
--- a/src/test/resources/unit/default-configuration/cpd-report-include-xml-in-site-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/cpd-report-include-xml-in-site-plugin-config.xml
@@ -36,15 +36,15 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
xml
false
${basedir}/target/test/unit/default-configuration/target/site/xref
100
-
${basedir}/src/test/resources/unit/default-configuration/
- UTF-8
+ UTF-8
true
xml
diff --git a/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
index f476e09c..36e22ec5 100644
--- a/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
@@ -36,12 +36,12 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- UTF-8
-
+ UTF-8
${basedir}/src/test/resources/unit/default-configuration/
diff --git a/src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml
index a9f7c56c..24457540 100644
--- a/src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/javascript-configuration-plugin-config.xml
@@ -36,9 +36,10 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
- UTF-8
+ UTF-8
javascript
/category/ecmascript/bestpractices.xml
diff --git a/src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml
index 53b026a9..0de51597 100644
--- a/src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/jsp-configuration-plugin-config.xml
@@ -36,9 +36,10 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
- UTF-8
+ UTF-8
jsp
/category/jsp/bestpractices.xml
diff --git a/src/test/resources/unit/default-configuration/pmd-report-custom-rules.xml b/src/test/resources/unit/default-configuration/pmd-report-custom-rules.xml
index 04c2c55f..b5f9c4dd 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-custom-rules.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-custom-rules.xml
@@ -36,6 +36,7 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
${basedir}/src/test/resources/unit/default-configuration/rulesets/custom-rules.xml
@@ -43,7 +44,7 @@ under the License.
xml
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- UTF-8
+ UTF-8
${basedir}/src/test/resources/unit/default-configuration/
diff --git a/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml
index 1963d899..e62b70ce 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml
@@ -36,11 +36,11 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
- UTF-8
+ UTF-8
true
-
diff --git a/src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml b/src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml
index e224833b..a9db808a 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-no-render-violations-by-priority.xml
@@ -36,15 +36,15 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- UTF-8
+ UTF-8
${basedir}/src/test/resources/unit/default-configuration/
-
false
diff --git a/src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml
index 002ee55f..f2633ce2 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-not-render-rule-priority-plugin-config.xml
@@ -36,16 +36,15 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- UTF-8
-
+ UTF-8
${basedir}/src/test/resources/unit/default-configuration/
-
false
diff --git a/src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml
index 3071f8ea..246d4952 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-pmd-exclusions-configuration-plugin-config.xml
@@ -36,12 +36,12 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- UTF-8
-
+ UTF-8
${basedir}/src/test/resources/unit/default-configuration/
diff --git a/src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml b/src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml
index 351ef8e4..a36a855f 100644
--- a/src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml
+++ b/src/test/resources/unit/default-configuration/pmd-report-resolve-rulesets.xml
@@ -36,6 +36,7 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
${basedir}/src/test/resources/unit/default-configuration/rulesets/custom-rules.xml
@@ -49,7 +50,7 @@ under the License.
xml
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- UTF-8
+ UTF-8
${basedir}/src/test/resources/unit/default-configuration/
diff --git a/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml
index 142bc62e..df2c0f19 100644
--- a/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml
@@ -36,14 +36,14 @@ under the License.
${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/site
${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target
+ ${localRepository}
${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/pmd/rulesets
xml
true
${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/site/xref
- UTF-8
+ UTF-8
true
${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/pmd/pmd.cache
-
${basedir}/src/test/resources/unit/default-configuration/
diff --git a/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml
index 1f94bf20..9ed62576 100644
--- a/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-no-render-plugin-config.xml
@@ -36,15 +36,14 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- UTF-8
-
+ UTF-8
SUPPRESSME
false
-
${basedir}/src/test/resources/unit/default-configuration/
diff --git a/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml
index 88d8a937..c5116dd9 100644
--- a/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml
+++ b/src/test/resources/unit/default-configuration/pmd-with-suppressMarker-plugin-config.xml
@@ -36,14 +36,13 @@ under the License.
${basedir}/target/test/unit/default-configuration/target/site
${basedir}/target/test/unit/default-configuration/target
+ ${localRepository}
${basedir}/target/test/unit/default-configuration/target/pmd/rulesets
xml
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- UTF-8
-
+ UTF-8
SUPPRESSME
-
${basedir}/src/test/resources/unit/default-configuration/
diff --git a/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml b/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml
index 6db11397..be2b5348 100644
--- a/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml
+++ b/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml
@@ -36,10 +36,11 @@ under the License.
${basedir}/target/test/unit/empty-report/target/site
${basedir}/target/test/unit/empty-report/target
+ ${localRepository}
${basedir}/src/test/resources/unit/empty-report/java/
- UTF-8
+ UTF-8
100
diff --git a/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml b/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml
index 93f4887b..9109cda4 100644
--- a/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml
+++ b/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml
@@ -39,7 +39,7 @@ under the License.
${basedir}/src/test/resources/unit/empty-report/java/
- UTF-8
+ UTF-8
100
true
diff --git a/src/test/resources/unit/empty-report/empty-report-plugin-config.xml b/src/test/resources/unit/empty-report/empty-report-plugin-config.xml
index 56e3bc11..c1c6ea8e 100644
--- a/src/test/resources/unit/empty-report/empty-report-plugin-config.xml
+++ b/src/test/resources/unit/empty-report/empty-report-plugin-config.xml
@@ -36,11 +36,12 @@ under the License.
${basedir}/target/test/unit/empty-report/target/site
${basedir}/target/test/unit/empty-report/target
+ ${localRepository}
${basedir}/target/test/unit/empty-report/target/pmd/rulesets
${basedir}/src/test/resources/unit/empty-report/java/
- UTF-8
+ UTF-8
diff --git a/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml b/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml
index 41e1aef7..2aeff05f 100644
--- a/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml
+++ b/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml
@@ -40,7 +40,7 @@ under the License.
${basedir}/src/test/resources/unit/empty-report/java/
- UTF-8
+ UTF-8
true
diff --git a/src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml b/src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml
index 94359745..ac800c73 100644
--- a/src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml
+++ b/src/test/resources/unit/exclude-roots/pmd-exclude-roots-plugin-config.xml
@@ -36,17 +36,16 @@ under the License.
${basedir}/target/test/unit/exclude-roots/target/site
${basedir}/target/test/unit/exclude-roots/target
+ ${localRepository}
${basedir}/target/test/unit/exclude-roots/target/pmd/rulesets
xml
- UTF-8
-
+ UTF-8
${basedir}/src/test/resources/unit/exclude-roots/src
${basedir}/src/test/resources/unit/exclude-roots/baseroot/src1
${basedir}/src/test/resources/unit/exclude-roots/baseroot/src2
${basedir}/src/test/resources/unit/exclude-roots/othersrc
-
${basedir}/src/test/resources/unit/exclude-roots/baseroot
${basedir}/src/test/resources/unit/exclude-roots/othersrc
diff --git a/src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml b/src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml
index 9d5958a0..e6ccad46 100644
--- a/src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml
+++ b/src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml
@@ -40,7 +40,7 @@ under the License.
xhtml
false
${basedir}/target/test/unit/invalid-format/target/site/xref
- ISO-8859-1
+ ISO-8859-1
diff --git a/src/test/resources/unit/invalid-format/invalid-target-jdk-plugin-config.xml b/src/test/resources/unit/invalid-format/invalid-target-jdk-plugin-config.xml
index 30dc6358..39f78a77 100644
--- a/src/test/resources/unit/invalid-format/invalid-target-jdk-plugin-config.xml
+++ b/src/test/resources/unit/invalid-format/invalid-target-jdk-plugin-config.xml
@@ -41,8 +41,7 @@ under the License.
1.x
true
${basedir}/target/test/unit/default-configuration/target/site/xref
- ISO-8859-1
-
+ ISO-8859-1
${basedir}/src/test/resources/unit/default-configuration/
diff --git a/src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml b/src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml
index 7db20a11..ba7f86f9 100644
--- a/src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml
+++ b/src/test/resources/unit/processing-error/pmd-processing-error-no-report-plugin-config.xml
@@ -36,9 +36,10 @@ under the License.
${basedir}/target/test/unit/parse-error/target/site
${basedir}/target/test/unit/parse-error/target
+ ${localRepository}
${basedir}/target/test/unit/parse-error/target/pmd/rulesets
xml
- UTF-8
+ UTF-8
true
false
diff --git a/src/test/resources/unit/processing-error/pmd-processing-error-plugin-config.xml b/src/test/resources/unit/processing-error/pmd-processing-error-plugin-config.xml
index 0a2a10ee..f08cee46 100644
--- a/src/test/resources/unit/processing-error/pmd-processing-error-plugin-config.xml
+++ b/src/test/resources/unit/processing-error/pmd-processing-error-plugin-config.xml
@@ -38,7 +38,7 @@ under the License.
${basedir}/target/test/unit/parse-error/target
${basedir}/target/test/unit/parse-error/target/pmd/rulesets
xml
- UTF-8
+ UTF-8
false
${basedir}/src/test/resources/unit/processing-error/src
diff --git a/src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml b/src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml
index 9974a8ff..686d7052 100644
--- a/src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml
+++ b/src/test/resources/unit/processing-error/pmd-processing-error-skip-plugin-config.xml
@@ -36,9 +36,10 @@ under the License.
${basedir}/target/test/unit/parse-error/target/site
${basedir}/target/test/unit/parse-error/target
+ ${localRepository}
${basedir}/target/test/unit/parse-error/target/pmd/rulesets
xml
- UTF-8
+ UTF-8
true
${basedir}/src/test/resources/unit/processing-error/src