Author: epunzalan
Date: Tue Apr  4 19:32:19 2006
New Revision: 391466

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

Added tests on ejb and ear project types

Added:
    
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EarMavenProjectStub.java
    
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EjbMavenProjectStub.java
    
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ear-plugin-config.xml
    
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ejb-plugin-config.xml
Modified:
    
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
    
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java?rev=391466&r1=391465&r2=391466&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
 Tue Apr  4 19:32:19 2006
@@ -272,7 +272,7 @@
             {
                 Resource resource = (Resource) i.next();
                 String directory = resource.getDirectory();
-                if ( resource.getTargetPath() == null && 
resource.isFiltering() == false )
+                if ( resource.getTargetPath() == null && 
!resource.isFiltering() )
                 {
                     addSourceFolder( content, directory, false );
                 }
@@ -288,7 +288,7 @@
             {
                 Resource resource = (Resource) i.next();
                 String directory = resource.getDirectory();
-                if ( resource.getTargetPath() == null && 
resource.isFiltering() == false )
+                if ( resource.getTargetPath() == null && 
!resource.isFiltering() )
                 {
                     addSourceFolder( content, directory, true );
                 }
@@ -536,13 +536,7 @@
 
             Element containerElement = createElement( component, 
"containerElement" );
 
-            boolean linkAsModule = false;
-            if ( linkModules )
-            {
-                linkAsModule = isReactorProject( artifact.getGroupId(), 
artifact.getArtifactId() );
-            }
-
-            if ( linkAsModule )
+            if ( linkModules && isReactorProject( artifact.getGroupId(), 
artifact.getArtifactId() ) )
             {
                 containerElement.addAttribute( "type", "module" );
                 containerElement.addAttribute( "name", 
artifact.getArtifactId() );
@@ -864,17 +858,6 @@
             getLog().debug( e );
             return null;
         }
-    }
-
-    private void addResources( Element component, String directory )
-    {
-        Element dep = createElement( component, "orderEntry" );
-        dep.addAttribute( "type", "module-library" );
-        dep = createElement( dep, "library" );
-
-        Element el = createElement( dep, "CLASSES" );
-        el = createElement( el, "root" );
-        el.addAttribute( "url", getModuleFileUrl( directory ) );
     }
 
     /**

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=391466&r1=391465&r2=391466&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
 Tue Apr  4 19:32:19 2006
@@ -91,6 +91,76 @@
         assertTrue( "All libraries are present", expectedLibs.size() == 0 );
     }
 
+    public void testEjbMinConfig()
+        throws Exception
+    {
+        List expectedLibs = new ArrayList();
+        expectedLibs.add( "/WEB-INF/lib/maven-model-2.0.1.jar" );
+        expectedLibs.add( "/WEB-INF/lib/junit-3.8.1.jar" );
+
+        Document imlDocument = executeMojo( 
"src/test/module-plugin-configs/min-ejb-plugin-config.xml" );
+
+        Element root = imlDocument.getRootElement();
+
+        assertEquals( "Test Project type", "J2EE_EJB_MODULE", 
root.attributeValue( "type" ) );
+
+        Element component = findComponent( root, "EjbModuleBuildComponent" );
+
+        Element setting = findElement( component, "setting" );
+        assertTrue( "Test exploded url setting", "EXPLODED_URL".equals( 
setting.attributeValue( "name" ) ) );
+        assertTrue( "Test exploded url value",
+                    setting.attributeValue( "value" ).startsWith( 
"file://$MODULE_DIR$/target/" ) );
+
+        component = findComponent( root, "EjbModuleProperties" );
+
+        Element deployDescriptor = component.element( "deploymentDescriptor" );
+        assertEquals( "Test deployment descriptor version", "2.x", 
deployDescriptor.attributeValue( "version" ) );
+        assertEquals( "Test deployment descriptor name", "ejb-jar.xml", 
deployDescriptor.attributeValue( "name" ) );
+        assertEquals( "Test deployment descriptor optional", "false", 
deployDescriptor.attributeValue( "optional" ) );
+        assertEquals( "Test deployment descriptor file",
+                      
"file://$MODULE_DIR$/src/main/resources/META-INF/ejb-jar.xml",
+                      deployDescriptor.attributeValue( "url" ) );
+
+        List containerElementList = findElementsByName( component, 
"containerElement" );
+        for ( Iterator containerElements = containerElementList.iterator(); 
containerElements.hasNext(); )
+        {
+            Element containerElement = (Element) containerElements.next();
+
+            assertEquals( "Test container element type", "library", 
containerElement.attributeValue( "type" ) );
+            assertEquals( "Test container element level", "module", 
containerElement.attributeValue( "level" ) );
+
+            Element attribute = findElementByNameAttribute( containerElement, 
"attribute", "method" );
+            assertEquals( "Test library method", "2", 
attribute.attributeValue( "value" ) );
+
+            attribute = findElementByNameAttribute( containerElement, 
"attribute", "URI" );
+            String attributeValue = attribute.attributeValue( "value" );
+            assertTrue( "Test library URI", expectedLibs.contains( 
attributeValue ) );
+            expectedLibs.remove( attributeValue );
+        }
+
+        assertTrue( "All libraries are present", expectedLibs.size() == 0 );
+    }
+
+    public void testEarMinConfig()
+        throws Exception
+    {
+        Document imlDocument = executeMojo( 
"src/test/module-plugin-configs/min-ear-plugin-config.xml" );
+
+        Element root = imlDocument.getRootElement();
+
+        assertEquals( "Test Project type", "J2EE_APPLICATION_MODULE", 
root.attributeValue( "type" ) );
+
+        Element component = findComponent( root, "ApplicationModuleProperties" 
);
+
+        Element deployDescriptor = component.element( "deploymentDescriptor" );
+        assertEquals( "Test deployment descriptor version", "1.3", 
deployDescriptor.attributeValue( "version" ) );
+        assertEquals( "Test deployment descriptor name", "application.xml", 
deployDescriptor.attributeValue( "name" ) );
+        assertEquals( "Test deployment descriptor optional", "false", 
deployDescriptor.attributeValue( "optional" ) );
+        assertEquals( "Test deployment descriptor file",
+                      "file://$MODULE_DIR$/target/application.xml",
+                      deployDescriptor.attributeValue( "url" ) );
+    }
+
     protected Document executeMojo( String pluginXml )
         throws Exception
     {

Added: 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EarMavenProjectStub.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EarMavenProjectStub.java?rev=391466&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EarMavenProjectStub.java
 (added)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EarMavenProjectStub.java
 Tue Apr  4 19:32:19 2006
@@ -0,0 +1,29 @@
+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.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class EarMavenProjectStub
+    extends SimpleMavenProjectStub
+{
+    public String getPackaging()
+    {
+        return "ear";
+    }
+}

Added: 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EjbMavenProjectStub.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EjbMavenProjectStub.java?rev=391466&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EjbMavenProjectStub.java
 (added)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/EjbMavenProjectStub.java
 Tue Apr  4 19:32:19 2006
@@ -0,0 +1,29 @@
+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.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class EjbMavenProjectStub
+    extends SimpleMavenProjectStub
+{
+    public String getPackaging()
+    {
+        return "ejb";
+    }
+}

Added: 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ear-plugin-config.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ear-plugin-config.xml?rev=391466&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ear-plugin-config.xml
 (added)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ear-plugin-config.xml
 Tue Apr  4 19:32:19 2006
@@ -0,0 +1,42 @@
+<!--
+  ~  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.EarMavenProjectStub"/>
+          <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>true</dependenciesAsLibraries>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ejb-plugin-config.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ejb-plugin-config.xml?rev=391466&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ejb-plugin-config.xml
 (added)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/min-ejb-plugin-config.xml
 Tue Apr  4 19:32:19 2006
@@ -0,0 +1,42 @@
+<!--
+  ~  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.EjbMavenProjectStub"/>
+          <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>true</dependenciesAsLibraries>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file


Reply via email to