Improved plugin tests and show how to use exclusion filters

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
vmassol
2004-05-12 15:21:59 +00:00
parent 62172d92b3
commit 2fe93d6595
6 changed files with 59 additions and 4 deletions

View File

@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.1//EN"
"http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
<module name="Checker">
<property name="severity" value="error"/>
<module name="TreeWalker">
<module name="IllegalInstantiation">
<property name="classes" value="java.lang.Boolean"/>
</module>
</module>
<module name="SuppressionFilter">
<property name="file" value="${basedir}/suppressions.xml"/>
</module>
</module>

View File

@@ -15,20 +15,30 @@
* limitations under the License.
*/
-->
<project xmlns:util="jelly:util"
xmlns:j="jelly:core">
<project
xmlns:util="jelly:util"
xmlns:j="jelly:core"
xmlns:x="jelly:xml">
<goal name="testPlugin" prereqs="clean,test-checkstyle-report">
</goal>
<goal name="test-checkstyle-report">
<!-- work around maven checkstyle being inherited :( -->
<j:set var="maven.checkstyle.properties" value=""/>
<attainGoal name="checkstyle:report"/>
<j:set var="expectedFile" value="${maven.gen.docs}/checkstyle-report.xml"/>
<util:file var="file" name="${expectedFile}" />
<j:if test="${!(file.exists())}">
<fail>${expectedFile} not generated</fail>
</j:if>
<!-- Verify that there are no Boolean instantiation errors as we have
excluded the SuppressionFilterSample java file from the checks -->
<util:file var="rawFile" name="${maven.build.dir}/checkstyle-raw-report.xml"/>
<x:parse var="doc" xml="${rawFile}"/>
<x:if select="$doc//file[contains(@name,'SuppressionFilterSample')]/error[contains(@source,'IllegalInstantiationCheck')]">
<fail>Should not have generated an error as we have a suppression filter set on SuppressionFilterSample</fail>
</x:if>
</goal>
</project>

View File

@@ -16,3 +16,5 @@
# required so it can be called from reactor
maven.checkstyle.header.file = ${basedir}/LICENSE.txt
maven.checkstyle.properties=${basedir}/checkstyle.xml

View File

@@ -2,5 +2,7 @@ package org.apache.maven;
public class Dummy
{
// Voluntarily missing static keyword in order to trigger the
// VisibilityModifier check (only static members must be private).
public String badChecky = "error";
}

View File

@@ -0,0 +1,11 @@
package org.apache.maven;
import java.lang.Boolean;
public class SuppressionFilterSample
{
// Voluntarily instantiate a boolean in order to have the
// IllegalInstantiationCheck check fail. We let it pass using a
// suppression filter in order to test that feature.
public Boolean forbidden = new Boolean(true);
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
<suppressions>
<suppress checks="IllegalInstantiation"
files="org.apache.maven.SuppressionFilterSample.java"/>
</suppressions>