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/06 07:24:33 UTC

svn commit: r391904 - in /maven/plugins/trunk/maven-idea-plugin/src/test: java/org/apache/maven/plugin/idea/ java/org/apache/maven/plugin/idea/stubs/ module-plugin-configs/

Author: epunzalan
Date: Wed Apr  5 22:24:31 2006
New Revision: 391904

URL: http://svn.apache.org/viewcvs?rev=391904&view=rev
Log:
PR: MIDEA-43

Added tests for the library parameter

Added:
    maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/LibraryMavenProjectStub.java
    maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-exclude-plugin-config.xml
    maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-plugin-config.xml
Modified:
    maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java

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=391904&r1=391903&r2=391904&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 Wed Apr  5 22:24:31 2006
@@ -3,10 +3,10 @@
 import org.dom4j.Document;
 import org.dom4j.Element;
 
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 /*
  *  Copyright 2005-2006 The Apache Software Foundation.
@@ -294,6 +294,64 @@
         }
 
         assertTrue( "Test presence of idea module", moduleFound );
+    }
+
+    public void testProjectWithLibrariesConfigurations()
+        throws Exception
+    {
+        Document imlDocument = executeMojo( "src/test/module-plugin-configs/library-plugin-config.xml" );
+
+        Element component = findComponent( imlDocument.getRootElement(), "NewModuleRootManager" );
+
+        boolean libraryFound = false;
+        for ( Iterator orderEntries = component.elementIterator( "orderEntry" ); orderEntries.hasNext(); )
+        {
+            Element orderEntry = (Element) orderEntries.next();
+            Element library = orderEntry.element( "library" );
+            if ( library != null )
+            {
+                String name = library.attributeValue( "name" );
+                if ( name != null && name.equals( "test-library" ) )
+                {
+                    libraryFound = true;
+
+                    String url = library.element( "CLASSES" ).element( "root" ).attributeValue( "url" );
+                    assertEquals( "Test user provided class path", "file:///user/defined/classes", url );
+
+                    url = library.element( "SOURCES" ).element( "root" ).attributeValue( "url" );
+                    assertEquals( "Test user provided source path", "file:///user/defined/sources", url );
+                }
+            }
+        }
+        assertTrue( "Test if configured library was found", libraryFound );
+    }
+
+    public void testProjectWithLibraryExcludeConfigurations()
+        throws Exception
+    {
+        Document imlDocument = executeMojo( "src/test/module-plugin-configs/library-exclude-plugin-config.xml" );
+
+        Element component = findComponent( imlDocument.getRootElement(), "NewModuleRootManager" );
+
+        for ( Iterator orderEntries = component.elementIterator( "orderEntry" ); orderEntries.hasNext(); )
+        {
+            Element orderEntry = (Element) orderEntries.next();
+            Element library = orderEntry.element( "library" );
+            if ( library != null )
+            {
+                Element classes = library.element( "CLASSES" );
+                if ( classes != null )
+                {
+                    Element root = classes.element( "root" );
+                    String url = root.attributeValue( "url" );
+
+                    if ( url.indexOf( "test-library" ) >= 0 )
+                    {
+                        fail( "test-library must be excluded" );
+                    }
+                }
+            }
+        }
     }
 
     protected Document executeMojo( String pluginXml )

Added: maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/LibraryMavenProjectStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/LibraryMavenProjectStub.java?rev=391904&view=auto
==============================================================================
--- maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/LibraryMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/LibraryMavenProjectStub.java Wed Apr  5 22:24:31 2006
@@ -0,0 +1,37 @@
+package org.apache.maven.plugin.idea.stubs;
+
+/*
+ *
+ *  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.
+ *
+ */
+
+import java.util.List;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class LibraryMavenProjectStub
+    extends SimpleMavenProjectStub
+{
+    public List getTestArtifacts()
+    {
+        List testArtifacts = super.getTestArtifacts();
+
+        testArtifacts.add( createArtifact( "test-library", "test-library", "1.0" ) );
+
+        return testArtifacts;
+    }
+}

Added: maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-exclude-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-exclude-plugin-config.xml?rev=391904&view=auto
==============================================================================
--- maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-exclude-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-exclude-plugin-config.xml Wed Apr  5 22:24:31 2006
@@ -0,0 +1,50 @@
+<!--
+  ~
+  ~  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.LibraryMavenProjectStub"/>
+          <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>
+          <libraries>
+            <library>
+              <name>test-library</name>
+              <exclude>true</exclude>
+            </library>
+          </libraries>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Added: maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-plugin-config.xml?rev=391904&view=auto
==============================================================================
--- maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/library-plugin-config.xml Wed Apr  5 22:24:31 2006
@@ -0,0 +1,51 @@
+<!--
+  ~
+  ~  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.LibraryMavenProjectStub"/>
+          <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>
+          <libraries>
+            <library>
+              <name>test-library</name>
+              <sources>file:///user/defined/sources</sources>
+              <classes>file:///user/defined/classes</classes>
+            </library>
+          </libraries>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file