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:
21
checkstyle/src/plugin-test/checkstyle.xml
Normal file
21
checkstyle/src/plugin-test/checkstyle.xml
Normal 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>
|
||||
@@ -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>
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
9
checkstyle/src/plugin-test/suppressions.xml
Normal file
9
checkstyle/src/plugin-test/suppressions.xml
Normal 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>
|
||||
Reference in New Issue
Block a user