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/11 13:47:39 UTC
svn commit: r393194 - in /maven/sandbox/plugins/maven-changelog-plugin/src:
main/java/org/apache/maven/changelog/ test/java/org/apache/maven/changelog/
test/java/org/apache/maven/changelog/stubs/
test/plugin-configs/dev-activity/ test/plugin-configs/fi...
Author: epunzalan
Date: Tue Apr 11 04:47:35 2006
New Revision: 393194
URL: http://svn.apache.org/viewcvs?rev=393194&view=rev
Log:
PR: MCHANGELOG-34
Added test harness for dev-activity and file-activity mojos
Added:
maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/DeveloperActivityReportTest.java
maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityReportTest.java
maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/stubs/DevelopersStub.java
maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/
maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/min-plugin-config.xml
maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/no-source-plugin-config.xml
maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/
maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/min-plugin-config.xml
maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/no-source-plugin-config.xml
Modified:
maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/DeveloperActivityReport.java
Modified: maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/DeveloperActivityReport.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/DeveloperActivityReport.java?rev=393194&r1=393193&r2=393194&view=diff
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/DeveloperActivityReport.java (original)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/main/java/org/apache/maven/changelog/DeveloperActivityReport.java Tue Apr 11 04:47:35 2006
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
import org.apache.maven.model.Developer;
import org.apache.maven.scm.ChangeFile;
import org.apache.maven.scm.ChangeSet;
@@ -210,46 +209,6 @@
sink.text( ":" + countFilesChanged( set.getChangeSets() ) );
sink.paragraph_();
- }
-
- /**
- * counts the total commits made to the given sets
- *
- * @param sets collection of sets to count all the commits
- * @return total number of commits for the given sets
- */
- private long getCommits( Collection sets )
- {
- long commits = 0;
-
- for ( Iterator i = sets.iterator(); i.hasNext(); )
- {
- ChangeLogSet set = (ChangeLogSet) i.next();
-
- commits += set.getChangeSets().size();
- }
-
- return commits;
- }
-
- /**
- * counts the total number of files changed
- *
- * @param sets collection of sets to count all the files changed
- * @return total number of files changed
- */
- private long getFilesChanged( Collection sets )
- {
- long count = 0;
-
- for ( Iterator i = sets.iterator(); i.hasNext(); )
- {
- ChangeLogSet set = (ChangeLogSet) i.next();
-
- count += countFilesChanged( set.getChangeSets() );
- }
-
- return count;
}
/**
Added: maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/DeveloperActivityReportTest.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/DeveloperActivityReportTest.java?rev=393194&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/DeveloperActivityReportTest.java (added)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/DeveloperActivityReportTest.java Tue Apr 11 04:47:35 2006
@@ -0,0 +1,107 @@
+package org.apache.maven.changelog;
+
+/*
+ * 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.changelog.stubs.ScmManagerStub;
+import org.apache.maven.scm.manager.ScmManager;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class DeveloperActivityReportTest
+ extends AbstractMojoTestCase
+{
+ private ScmManager scmManager;
+
+ public void testNoSource()
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(),
+ "src/test/plugin-configs/dev-activity/no-source-plugin-config.xml" );
+
+ Mojo mojo = lookupMojo( "dev-activity", pluginXmlFile );
+
+ assertNotNull( "Mojo found.", mojo );
+
+ this.setVariableValueToObject( mojo, "manager", scmManager );
+
+ mojo.execute();
+
+ File outputDir = (File) getVariableValueFromObject( mojo, "outputDirectory" );
+
+ File outputHtml = new File( outputDir, "dev-activity.html" );
+
+ assertTrue( "Test html generated", outputHtml.exists() );
+ }
+
+ public void testMinConfig()
+ throws Exception
+ {
+ File outputXML = new File( getBasedir(), "src/test/changelog-xml/min-changelog.xml" );
+
+ // force reuse of existing changelog cache
+ outputXML.setLastModified( System.currentTimeMillis() );
+
+ executeMojo( "min-plugin-config.xml" );
+ }
+
+ private void executeMojo( String pluginXml )
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/dev-activity/" + pluginXml );
+
+ Mojo mojo = lookupMojo( "dev-activity", pluginXmlFile );
+
+ assertNotNull( "Mojo found.", mojo );
+
+ this.setVariableValueToObject( mojo, "manager", scmManager );
+
+ mojo.execute();
+
+ File outputXML = (File) getVariableValueFromObject( mojo, "outputXML" );
+
+ String encoding = (String) getVariableValueFromObject( mojo, "outputEncoding" );
+
+ assertTrue( "Test if changelog.xml is created", outputXML.exists() );
+
+ String changelogXml = FileUtils.fileRead( outputXML );
+
+ assertTrue( "Test for xml header", changelogXml.startsWith( "<?xml version=\"1.0\" encoding=\"" +
+ encoding + "\"?>" ) );
+
+ assertTrue( "Test for xml footer", changelogXml.endsWith( "</changelog>" ) );
+
+ File outputDir = (File) getVariableValueFromObject( mojo, "outputDirectory" );
+
+ File outputHtml = new File( outputDir, "dev-activity.html" );
+
+ assertTrue( "Test html generated", outputHtml.exists() );
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ scmManager = new ScmManagerStub();
+ }
+}
Added: maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityReportTest.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityReportTest.java?rev=393194&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityReportTest.java (added)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/FileActivityReportTest.java Tue Apr 11 04:47:35 2006
@@ -0,0 +1,107 @@
+package org.apache.maven.changelog;
+
+/*
+ * 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.scm.manager.ScmManager;
+import org.apache.maven.changelog.stubs.ScmManagerStub;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class FileActivityReportTest
+ extends AbstractMojoTestCase
+{
+ private ScmManager scmManager;
+
+ public void testNoSource()
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(),
+ "src/test/plugin-configs/file-activity/no-source-plugin-config.xml" );
+
+ Mojo mojo = lookupMojo( "file-activity", pluginXmlFile );
+
+ assertNotNull( "Mojo found.", mojo );
+
+ this.setVariableValueToObject( mojo, "manager", scmManager );
+
+ mojo.execute();
+
+ File outputDir = (File) getVariableValueFromObject( mojo, "outputDirectory" );
+
+ File outputHtml = new File( outputDir, "file-activity.html" );
+
+ assertTrue( "Test html generated", outputHtml.exists() );
+ }
+
+ public void testMinConfig()
+ throws Exception
+ {
+ File outputXML = new File( getBasedir(), "src/test/changelog-xml/min-changelog.xml" );
+
+ // force reuse of existing changelog cache
+ outputXML.setLastModified( System.currentTimeMillis() );
+
+ executeMojo( "min-plugin-config.xml" );
+ }
+
+ private void executeMojo( String pluginXml )
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/file-activity/" + pluginXml );
+
+ Mojo mojo = lookupMojo( "file-activity", pluginXmlFile );
+
+ assertNotNull( "Mojo found.", mojo );
+
+ this.setVariableValueToObject( mojo, "manager", scmManager );
+
+ mojo.execute();
+
+ File outputXML = (File) getVariableValueFromObject( mojo, "outputXML" );
+
+ String encoding = (String) getVariableValueFromObject( mojo, "outputEncoding" );
+
+ assertTrue( "Test if changelog.xml is created", outputXML.exists() );
+
+ String changelogXml = FileUtils.fileRead( outputXML );
+
+ assertTrue( "Test for xml header", changelogXml.startsWith( "<?xml version=\"1.0\" encoding=\"" +
+ encoding + "\"?>" ) );
+
+ assertTrue( "Test for xml footer", changelogXml.endsWith( "</changelog>" ) );
+
+ File outputDir = (File) getVariableValueFromObject( mojo, "outputDirectory" );
+
+ File outputHtml = new File( outputDir, "file-activity.html" );
+
+ assertTrue( "Test html generated", outputHtml.exists() );
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ scmManager = new ScmManagerStub();
+ }
+}
Added: maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/stubs/DevelopersStub.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/stubs/DevelopersStub.java?rev=393194&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/stubs/DevelopersStub.java (added)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/test/java/org/apache/maven/changelog/stubs/DevelopersStub.java Tue Apr 11 04:47:35 2006
@@ -0,0 +1,48 @@
+package org.apache.maven.changelog.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.Developer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class DevelopersStub
+ extends ArrayList
+{
+ public DevelopersStub()
+ {
+ super();
+
+ List developers = new ArrayList();
+
+ Developer developer = new Developer();
+ developer.setName( "Edwin Punzalan" );
+ developer.setId( "edwin" );
+ developers.add( developer );
+
+ developer = new Developer();
+ developer.setName( "Keogh Edrich Punzalan" );
+ developer.setId( "keogh" );
+ developers.add( developer );
+
+ super.addAll( developers );
+ }
+}
Added: maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/min-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/min-plugin-config.xml?rev=393194&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/min-plugin-config.xml (added)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/min-plugin-config.xml Tue Apr 11 04:47:35 2006
@@ -0,0 +1,41 @@
+<!--
+ ~ 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-changelog-plugin</artifactId>
+ <configuration>
+ <type>range</type>
+ <range>-1</range>
+ <dateFormat>yyyy-MM-dd</dateFormat>
+ <basedir>${basedir}/src/main/java</basedir>
+ <outputXML>${basedir}/src/test/changelog-xml/min-changelog.xml</outputXML>
+ <outputXMLExpiration>3600</outputXMLExpiration>
+ <outputEncoding>ISO-8859-1</outputEncoding>
+ <scmUrl>scm://</scmUrl>
+ <outputDirectory>site</outputDirectory>
+ <offline>false</offline>
+ <connectionType>connection</connectionType>
+ <project implementation="org.apache.maven.changelog.stubs.MavenProjectStub"/>
+ <settings implementation="org.apache.maven.changelog.stubs.SettingsStub"/>
+ <developers implementation="org.apache.maven.changelog.stubs.DevelopersStub"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/no-source-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/no-source-plugin-config.xml?rev=393194&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/no-source-plugin-config.xml (added)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/dev-activity/no-source-plugin-config.xml Tue Apr 11 04:47:35 2006
@@ -0,0 +1,41 @@
+<!--
+ ~ 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-changelog-plugin</artifactId>
+ <configuration>
+ <type>range</type>
+ <range>-1</range>
+ <dateFormat>yyyy-MM-dd</dateFormat>
+ <basedir>${basedir}/src/main/no-dir</basedir>
+ <outputXML>changelog.xml</outputXML>
+ <outputXMLExpiration>60</outputXMLExpiration>
+ <outputEncoding>ISO-8859-1</outputEncoding>
+ <scmUrl>scm://</scmUrl>
+ <outputDirectory>site</outputDirectory>
+ <offline>false</offline>
+ <connectionType>connection</connectionType>
+ <project implementation="org.apache.maven.changelog.stubs.MavenProjectStub"/>
+ <settings implementation="org.apache.maven.changelog.stubs.SettingsStub"/>
+ <developers implementation="org.apache.maven.changelog.stubs.DevelopersStub"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/min-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/min-plugin-config.xml?rev=393194&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/min-plugin-config.xml (added)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/min-plugin-config.xml Tue Apr 11 04:47:35 2006
@@ -0,0 +1,40 @@
+<!--
+ ~ 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-changelog-plugin</artifactId>
+ <configuration>
+ <type>range</type>
+ <range>-1</range>
+ <dateFormat>yyyy-MM-dd</dateFormat>
+ <basedir>${basedir}/src/main/java</basedir>
+ <outputXML>changelog.xml</outputXML>
+ <outputXMLExpiration>60</outputXMLExpiration>
+ <outputEncoding>ISO-8859-1</outputEncoding>
+ <scmUrl>scm://</scmUrl>
+ <outputDirectory>site</outputDirectory>
+ <offline>false</offline>
+ <connectionType>connection</connectionType>
+ <project implementation="org.apache.maven.changelog.stubs.MavenProjectStub"/>
+ <settings implementation="org.apache.maven.changelog.stubs.SettingsStub"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/no-source-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/no-source-plugin-config.xml?rev=393194&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/no-source-plugin-config.xml (added)
+++ maven/sandbox/plugins/maven-changelog-plugin/src/test/plugin-configs/file-activity/no-source-plugin-config.xml Tue Apr 11 04:47:35 2006
@@ -0,0 +1,40 @@
+<!--
+ ~ 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-changelog-plugin</artifactId>
+ <configuration>
+ <type>range</type>
+ <range>-1</range>
+ <dateFormat>yyyy-MM-dd</dateFormat>
+ <basedir>${basedir}/src/main/no-dir</basedir>
+ <outputXML>changelog.xml</outputXML>
+ <outputXMLExpiration>60</outputXMLExpiration>
+ <outputEncoding>ISO-8859-1</outputEncoding>
+ <scmUrl>scm://</scmUrl>
+ <outputDirectory>site</outputDirectory>
+ <offline>false</offline>
+ <connectionType>connection</connectionType>
+ <project implementation="org.apache.maven.changelog.stubs.MavenProjectStub"/>
+ <settings implementation="org.apache.maven.changelog.stubs.SettingsStub"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>