You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ep...@apache.org on 2006/04/19 10:18:35 UTC
svn commit: r395167 - in /maven/plugins/trunk/maven-checkstyle-plugin: ./
src/test/java/org/apache/maven/plugin/checkstyle/
src/test/java/org/apache/maven/plugin/checkstyle/stubs/
src/test/plugin-configs/ src/test/test-sources/
Author: epunzalan
Date: Wed Apr 19 01:18:32 2006
New Revision: 395167
URL: http://svn.apache.org/viewcvs?rev=395167&view=rev
Log:
PR: MCHECKSTYLE-39
Added test-harness tests with min configs
Added:
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java
maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/
maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/min-plugin-config.xml
maven/plugins/trunk/maven-checkstyle-plugin/src/test/test-sources/
maven/plugins/trunk/maven-checkstyle-plugin/src/test/test-sources/TestJavaObject.java
Modified:
maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
Modified: maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/pom.xml?rev=395167&r1=395166&r2=395167&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/pom.xml Wed Apr 19 01:18:32 2006
@@ -60,5 +60,11 @@
<artifactId>checkstyle-optional</artifactId>
<version>4.1</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Added: 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=395167&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java Wed Apr 19 01:18:32 2006
@@ -0,0 +1,72 @@
+package org.apache.maven.plugin.checkstyle;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.reporting.MavenReport;
+
+import java.io.File;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class CheckstyleReportTest
+ extends AbstractMojoTestCase
+{
+ public void testMinConfiguration()
+ throws Exception
+ {
+ File htmlFile = generateReport( "min-plugin-config.xml" );
+ }
+
+ private File generateReport( String pluginXml )
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/" + pluginXml );
+
+ Mojo mojo = lookupMojo( "checkstyle", pluginXmlFile );
+
+ assertNotNull( "Mojo found.", mojo );
+
+ mojo.execute();
+
+ File outputFile = (File) getVariableValueFromObject( mojo, "outputFile" );
+ assertNotNull( "Test output file", outputFile );
+ assertTrue( "Test output file exists", outputFile.exists() );
+
+ String cacheFile = (String) getVariableValueFromObject( mojo, "cacheFile" );
+ assertNotNull( "Test cache file", cacheFile );
+ assertTrue( "Test cache file exists", new File( cacheFile ).exists() );
+
+ MavenReport reportMojo = (MavenReport) mojo;
+ File outputDir = reportMojo.getReportOutputDirectory();
+
+ Boolean rss = (Boolean) getVariableValueFromObject( mojo, "enableRSS" );
+ if ( rss.booleanValue() )
+ {
+ File rssFile = new File( outputDir, "checkstyle.rss" );
+ assertTrue( "Test rss file exists", rssFile.exists() );
+ }
+
+ String filename = reportMojo.getOutputName() + ".html";
+ File outputHtml = new File( outputDir, filename );
+ assertTrue( "Test output html file exists", outputHtml.exists() );
+
+ return outputHtml;
+ }
+}
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java?rev=395167&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java Wed Apr 19 01:18:32 2006
@@ -0,0 +1,72 @@
+package org.apache.maven.plugin.checkstyle.stubs;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Organization;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.util.List;
+import java.util.Collections;
+import java.io.File;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class MinMavenProjectStub
+ extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
+{
+ public List getCompileClasspathElements()
+ throws DependencyResolutionRequiredException
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ public File getBasedir()
+ {
+ return new File( PlexusTestCase.getBasedir() );
+ }
+
+ public List getReportPlugins()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ public Organization getOrganization()
+ {
+ Organization organization = new Organization();
+
+ organization.setName( "maven-plugin-tests" );
+
+ return organization;
+ }
+
+ public String getInceptionYear()
+ {
+ return "2006";
+ }
+
+ public Build getBuild()
+ {
+ Build build = new Build();
+
+ build.setDirectory( PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/min" );
+
+ return build;
+ }
+}
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/min-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/min-plugin-config.xml?rev=395167&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/min-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/min-plugin-config.xml Wed Apr 19 01:18:32 2006
@@ -0,0 +1,44 @@
+<!--
+ ~ 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/min</outputDirectory>
+ <enableRulesSummary>true</enableRulesSummary>
+ <enableSeveritySummary>true</enableSeveritySummary>
+ <enableFilesSummary>true</enableFilesSummary>
+ <enableRSS>true</enableRSS>
+ <includes>**/*.java</includes>
+ <configLocation>config/sun_checks.xml</configLocation>
+ <format>sun</format>
+ <!--headerLocation>${basedir}/LICENSE.txt</headerLocation-->
+ <cacheFile>${basedir}/target/test-harness/checkstyle/min/checkstyle-cachefile</cacheFile>
+ <outputFile>${basedir}/target/test-harness/checkstyle/min/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/test-sources/TestJavaObject.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/src/test/test-sources/TestJavaObject.java?rev=395167&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/test-sources/TestJavaObject.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/test-sources/TestJavaObject.java Wed Apr 19 01:18:32 2006
@@ -0,0 +1,9 @@
+public class TestJavaObject {
+ public void doSomething() {
+
+ }
+
+ public Object getSomething() {
+
+ }
+}
\ No newline at end of file