Author: epunzalan Date: Thu Apr 20 02:02:24 2006 New Revision: 395540 URL: http://svn.apache.org/viewcvs?rev=395540&view=rev Log: PR: MCHECKSTYLE-39
Added more test cases for the checkstyle:checkstyle goal Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-files-plugin-config.xml maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-rules-plugin-config.xml maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-severity-plugin-config.xml Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java?rev=395540&r1=395539&r2=395540&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java Thu Apr 20 02:02:24 2006 @@ -16,10 +16,11 @@ * limitations under the License. */ +import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.reporting.MavenReport; -import org.apache.maven.artifact.DependencyResolutionRequiredException; +import org.codehaus.plexus.util.FileUtils; import java.io.File; @@ -63,6 +64,24 @@ File htmlFile = generateReport( "useFile-plugin-config.xml" ); } + public void testNoRulesSummary() + throws Exception + { + File htmlFile = generateReport( "no-rules-plugin-config.xml" ); + } + + public void testNoSeveritySummary() + throws Exception + { + File htmlFile = generateReport( "no-severity-plugin-config.xml" ); + } + + public void testNoFilesSummary() + throws Exception + { + File htmlFile = generateReport( "no-files-plugin-config.xml" ); + } + public void testFailOnError() { try @@ -134,6 +153,40 @@ String filename = reportMojo.getOutputName() + ".html"; File outputHtml = new File( outputDir, filename ); assertTrue( "Test output html file exists", outputHtml.exists() ); + String htmlString = FileUtils.fileRead( outputHtml ); + + boolean searchHeaderFound = ( htmlString.indexOf( "<h2>Rules</h2>" ) > 0 ); + Boolean rules = (Boolean) getVariableValueFromObject( mojo, "enableRulesSummary" ); + if ( rules.booleanValue() ) + { + assertTrue( "Test for Rules Summary", searchHeaderFound ); + } + else + { + assertFalse( "Test for Rules Summary", searchHeaderFound ); + } + + searchHeaderFound = ( htmlString.indexOf( "<h2>Summary</h2>" ) > 0 ); + Boolean severity = (Boolean) getVariableValueFromObject( mojo, "enableSeveritySummary" ); + if ( severity.booleanValue() ) + { + assertTrue( "Test for Severity Summary", searchHeaderFound ); + } + else + { + assertFalse( "Test for Severity Summary", searchHeaderFound ); + } + + searchHeaderFound = ( htmlString.indexOf( "<h2>Files</h2>" ) > 0 ); + Boolean files = (Boolean) getVariableValueFromObject( mojo, "enableFilesSummary" ); + if ( files.booleanValue() ) + { + assertTrue( "Test for Files Summary", searchHeaderFound ); + } + else + { + assertFalse( "Test for Files Summary", searchHeaderFound ); + } return outputHtml; } Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-files-plugin-config.xml URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-files-plugin-config.xml?rev=395540&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-files-plugin-config.xml (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-files-plugin-config.xml Thu Apr 20 02:02:24 2006 @@ -0,0 +1,45 @@ +<!-- + ~ Copyright 2001-2006 The Apache Software Foundation. + ~ + ~ Licensed 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. + --> + +<project> + <build> + <plugins> + <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <outputDirectory>${basedir}/target/test-harness/checkstyle/no-files</outputDirectory> + <enableRulesSummary>true</enableRulesSummary> + <enableSeveritySummary>true</enableSeveritySummary> + <enableFilesSummary>false</enableFilesSummary> + <enableRSS>true</enableRSS> + <includes>**/*.java</includes> + <configLocation>config/sun_checks.xml</configLocation> + <format>sun</format> + <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> + <cacheFile>${basedir}/target/test-harness/checkstyle/no-files/checkstyle-cachefile</cacheFile> + <outputFile>${basedir}/target/test-harness/checkstyle/no-files/checkstyle-result.xml</outputFile> + <outputFileFormat>xml</outputFileFormat> + <failsOnError>false</failsOnError> + <sourceDirectory>${basedir}/src/test/test-sources</sourceDirectory> + <project implementation="org.apache.maven.plugin.checkstyle.stubs.MinMavenProjectStub"/> + <consoleOutput>false</consoleOutput> + <linkXRef>true</linkXRef> + <xrefLocation>${basedir}/target/site/xref</xrefLocation> + </configuration> + </plugin> + </plugins> + </build> +</project> Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-rules-plugin-config.xml URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-rules-plugin-config.xml?rev=395540&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-rules-plugin-config.xml (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-rules-plugin-config.xml Thu Apr 20 02:02:24 2006 @@ -0,0 +1,45 @@ +<!-- + ~ Copyright 2001-2006 The Apache Software Foundation. + ~ + ~ Licensed 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. + --> + +<project> + <build> + <plugins> + <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <outputDirectory>${basedir}/target/test-harness/checkstyle/no-rules</outputDirectory> + <enableRulesSummary>false</enableRulesSummary> + <enableSeveritySummary>true</enableSeveritySummary> + <enableFilesSummary>true</enableFilesSummary> + <enableRSS>true</enableRSS> + <includes>**/*.java</includes> + <configLocation>config/sun_checks.xml</configLocation> + <format>sun</format> + <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> + <cacheFile>${basedir}/target/test-harness/checkstyle/no-rules/checkstyle-cachefile</cacheFile> + <outputFile>${basedir}/target/test-harness/checkstyle/no-rules/checkstyle-result.xml</outputFile> + <outputFileFormat>xml</outputFileFormat> + <failsOnError>false</failsOnError> + <sourceDirectory>${basedir}/src/test/test-sources</sourceDirectory> + <project implementation="org.apache.maven.plugin.checkstyle.stubs.MinMavenProjectStub"/> + <consoleOutput>false</consoleOutput> + <linkXRef>true</linkXRef> + <xrefLocation>${basedir}/target/site/xref</xrefLocation> + </configuration> + </plugin> + </plugins> + </build> +</project> Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-severity-plugin-config.xml URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-severity-plugin-config.xml?rev=395540&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-severity-plugin-config.xml (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/no-severity-plugin-config.xml Thu Apr 20 02:02:24 2006 @@ -0,0 +1,45 @@ +<!-- + ~ Copyright 2001-2006 The Apache Software Foundation. + ~ + ~ Licensed 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. + --> + +<project> + <build> + <plugins> + <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <outputDirectory>${basedir}/target/test-harness/checkstyle/no-severity</outputDirectory> + <enableRulesSummary>true</enableRulesSummary> + <enableSeveritySummary>false</enableSeveritySummary> + <enableFilesSummary>true</enableFilesSummary> + <enableRSS>true</enableRSS> + <includes>**/*.java</includes> + <configLocation>config/sun_checks.xml</configLocation> + <format>sun</format> + <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> + <cacheFile>${basedir}/target/test-harness/checkstyle/no-severity/checkstyle-cachefile</cacheFile> + <outputFile>${basedir}/target/test-harness/checkstyle/no-severity/checkstyle-result.xml</outputFile> + <outputFileFormat>xml</outputFileFormat> + <failsOnError>false</failsOnError> + <sourceDirectory>${basedir}/src/test/test-sources</sourceDirectory> + <project implementation="org.apache.maven.plugin.checkstyle.stubs.MinMavenProjectStub"/> + <consoleOutput>false</consoleOutput> + <linkXRef>true</linkXRef> + <xrefLocation>${basedir}/target/site/xref</xrefLocation> + </configuration> + </plugin> + </plugins> + </build> +</project>