Author: epunzalan
Date: Thu Apr 6 01:25:14 2006
New Revision: 391932
URL: http://svn.apache.org/viewcvs?rev=391932&view=rev
Log:
PR: MIDEA-43
More plugin tests
Added:
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/macro-plugin-config.xml
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/min-plugin-config.xml
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaTest.java
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/dir-exclusion-plugin-config.xml
Modified:
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java
Added:
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/macro-plugin-config.xml
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/macro-plugin-config.xml?rev=391932&view=auto
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/macro-plugin-config.xml
(added)
+++
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/macro-plugin-config.xml
Thu Apr 6 01:25:14 2006
@@ -0,0 +1,55 @@
+<!--
+ ~
+ ~ Copyright 2005-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-idea-plugin</artifactId>
+ <configuration>
+
+ <executedProject
implementation="org.apache.maven.plugin.idea.stubs.SimpleMavenProjectStub"/>
+ <localRepo>${localRepository}</localRepo>
+ <ideaVersion>4</ideaVersion>
+ <overwrite>false</overwrite>
+
+ <reactorProjects>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ </reactorProjects>
+ <linkModules>true</linkModules>
+ <useFullNames>false</useFullNames>
+ <downloadSources>false</downloadSources>
+ <sourceClassifier>sources</sourceClassifier>
+ <downloadJavadocs>false</downloadJavadocs>
+ <javadocClassifier>javadoc</javadocClassifier>
+ <dependenciesAsLibraries>false</dependenciesAsLibraries>
+ <libraries>
+ <library>
+ <name>junit</name>
+ <sources>file://$USER_HOME$/defined/sources</sources>
+ <classes>file://$USER_HOME$/defined/classes</classes>
+ </library>
+ </libraries>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added:
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/min-plugin-config.xml
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/min-plugin-config.xml?rev=391932&view=auto
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/min-plugin-config.xml
(added)
+++
maven/plugins/trunk/maven-idea-plugin/src/test/idea-plugin-configs/min-plugin-config.xml
Thu Apr 6 01:25:14 2006
@@ -0,0 +1,48 @@
+<!--
+ ~
+ ~ Copyright 2005-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-idea-plugin</artifactId>
+ <configuration>
+
+ <executedProject
implementation="org.apache.maven.plugin.idea.stubs.SimpleMavenProjectStub"/>
+ <localRepo>${localRepository}</localRepo>
+ <ideaVersion>4</ideaVersion>
+ <overwrite>false</overwrite>
+
+ <reactorProjects>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ </reactorProjects>
+ <linkModules>true</linkModules>
+ <useFullNames>false</useFullNames>
+ <downloadSources>false</downloadSources>
+ <sourceClassifier>sources</sourceClassifier>
+ <downloadJavadocs>false</downloadJavadocs>
+ <javadocClassifier>javadoc</javadocClassifier>
+ <dependenciesAsLibraries>false</dependenciesAsLibraries>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Modified:
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java?rev=391932&r1=391931&r2=391932&view=diff
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java
(original)
+++
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java
Thu Apr 6 01:25:14 2006
@@ -2,6 +2,7 @@
import org.dom4j.Document;
import org.dom4j.Element;
+import org.apache.maven.plugin.idea.stubs.TestCounter;
import java.io.File;
import java.util.ArrayList;
@@ -34,6 +35,40 @@
throws Exception
{
executeMojo( "src/test/module-plugin-configs/min-plugin-config.xml" );
+ }
+
+ public void testExcludeDirectoryConfig()
+ throws Exception
+ {
+ File projectBasedir = new File( "target/test-harness/" + (
TestCounter.currentCount() + 1 ) );
+
+ projectBasedir.mkdirs();
+
+ File excluded = new File( projectBasedir, "excluded" );
+ excluded.mkdirs();
+ File sub = new File( excluded, "sub" );
+ sub.mkdirs();
+ File sub2 = new File( excluded, "sub2" );
+ sub2.mkdirs();
+ File subsub1 = new File( sub, "sub1");
+ subsub1.mkdirs();
+
+ Document imlDocument = executeMojo(
"src/test/module-plugin-configs/dir-exclusion-plugin-config.xml" );
+
+ Element component = findComponent( imlDocument.getRootElement(),
"NewModuleRootManager" );
+
+ boolean excludedDirFound = false;
+ Element content = findElement( component, "content" );
+ for ( Iterator excludes = content.elementIterator( "excludeFolder" );
excludes.hasNext(); )
+ {
+ Element exclude = (Element) excludes.next();
+
+ if ( "file://$MODULE_DIR$/excluded".equals(
exclude.attributeValue( "url" ) ) )
+ {
+ excludedDirFound = true;
+ }
+ }
+ assertTrue( "Test excluded dir", excludedDirFound );
}
public void testWarMinConfig()
Added:
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaTest.java
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaTest.java?rev=391932&view=auto
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaTest.java
(added)
+++
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaTest.java
Thu Apr 6 01:25:14 2006
@@ -0,0 +1,97 @@
+package org.apache.maven.plugin.idea;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.idea.stubs.TestCounter;
+import org.dom4j.io.SAXReader;
+import org.dom4j.Document;
+import org.dom4j.Element;
+
+import java.io.File;
+
+/*
+ *
+ * Copyright 2005-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.
+ *
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class IdeaTest
+ extends AbstractMojoTestCase
+{
+ public void testIdea()
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(),
"src/test/idea-plugin-configs/min-plugin-config.xml" );
+
+ Mojo mojo = lookupMojo( "idea", pluginXmlFile );
+
+ mojo.execute();
+
+ File basedir = new File( "target/test-harness/" +
TestCounter.currentCount() );
+
+ String artifactId = "plugin-test-" + TestCounter.currentCount();
+
+ File iprFile = new File( basedir, artifactId + ".ipr" );
+ assertTrue( "Test creation of project files", iprFile.exists() );
+
+ File imlFile = new File( basedir, artifactId + ".iml" );
+ assertTrue( "Test creation of project files", imlFile.exists() );
+
+ File iwsFile = new File( basedir, artifactId + ".iws" );
+ assertTrue( "Test creation of project files", iwsFile.exists() );
+ }
+
+ public void testIdeaWithMacro()
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(),
"src/test/idea-plugin-configs/macro-plugin-config.xml" );
+
+ Mojo mojo = lookupMojo( "idea", pluginXmlFile );
+
+ mojo.execute();
+
+ int testCounter = TestCounter.currentCount();
+
+ File basedir = new File( "target/test-harness/" +
TestCounter.currentCount() );
+
+ String artifactId = "plugin-test-" + testCounter;
+
+ File iprFile = new File( basedir, artifactId + ".ipr" );
+ assertTrue( "Test creation of project files", iprFile.exists() );
+
+ File imlFile = new File( basedir, artifactId + ".iml" );
+ assertTrue( "Test creation of project files", imlFile.exists() );
+
+ File iwsFile = new File( basedir, artifactId + ".iws" );
+ assertTrue( "Test creation of project files", iwsFile.exists() );
+
+ File outputFile = new File( "target/test-harness/" + testCounter +
"/plugin-test-" + testCounter + ".ipr" );
+
+ SAXReader reader = new SAXReader();
+
+ Document iprDocument = reader.read( outputFile );
+
+ Element macros = iprDocument.getRootElement().element(
"UsedPathMacros" );
+
+ assertEquals( "Test creation of macros", 1, macros.elements( "macro"
).size() );
+
+ Element macro = macros.element( "macro" );
+
+ assertEquals( "Test macro name", "USER_HOME", macro.attributeValue(
"name" ) );
+ }
+}
Modified:
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java?rev=391932&r1=391931&r2=391932&view=diff
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java
(original)
+++
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java
Thu Apr 6 01:25:14 2006
@@ -105,6 +105,11 @@
collectedProjects = list;
}
+ public boolean isExecutionRoot()
+ {
+ return true;
+ }
+
public List getDependencies()
{
List dependencies = new ArrayList();
Added:
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/dir-exclusion-plugin-config.xml
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/dir-exclusion-plugin-config.xml?rev=391932&view=auto
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/dir-exclusion-plugin-config.xml
(added)
+++
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/dir-exclusion-plugin-config.xml
Thu Apr 6 01:25:14 2006
@@ -0,0 +1,45 @@
+<!--
+ ~
+ ~ Copyright 2005-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-idea-plugin</artifactId>
+ <configuration>
+ <executedProject
implementation="org.apache.maven.plugin.idea.stubs.SimpleMavenProjectStub"/>
+ <localRepo>${localRepository}</localRepo>
+ <overwrite>false</overwrite>
+ <reactorProjects>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ <reactorProject
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+ </reactorProjects>
+ <linkModules>true</linkModules>
+ <useFullNames>false</useFullNames>
+ <downloadSources>false</downloadSources>
+ <sourceClassifier>sources</sourceClassifier>
+ <downloadJavadocs>false</downloadJavadocs>
+ <javadocClassifier>javadoc</javadocClassifier>
+ <dependenciesAsLibraries>false</dependenciesAsLibraries>
+ <exclude>excluded</exclude>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file