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/04 11:33:50 UTC
svn commit: r391261 - in /maven/plugins/trunk/maven-idea-plugin/src:
main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java
Author: epunzalan
Date: Tue Apr 4 02:33:49 2006
New Revision: 391261
URL: http://svn.apache.org/viewcvs?rev=391261&view=rev
Log:
PR: MIDEA-43
More test assertions
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=391261&r1=391260&r2=391261&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 02:33:49 2006
@@ -692,13 +692,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() );
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=391261&r1=391260&r2=391261&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 02:33:49 2006
@@ -32,52 +32,72 @@
public void testJarMinConfig()
throws Exception
{
- List expectedDeps = new ArrayList();
- expectedDeps.add( "jar://E:/localRepository/org.apache.maven/maven-model/2.0.1/maven-model-2.0.1.jar!/" );
- expectedDeps.add( "jar://E:/localRepository/junit/junit/3.8.1/junit-3.8.1.jar!/" );
+ executeMojo( "src/test/module-plugin-configs/min-plugin-config.xml" );
+ }
- Document imlDocument = executeMojo( "src/test/module-plugin-configs/min-plugin-config.xml" );
+ public void testWarMinConfig()
+ 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" );
- Element component = findComponent( imlDocument.getRootElement(), "NewModuleRootManager" );
+ Document imlDocument = executeMojo( "src/test/module-plugin-configs/min-war-plugin-config.xml" );
- List orderEntryList = findElementsByName( component, "orderEntry" );
+ Element root = imlDocument.getRootElement();
- for ( Iterator orderEntries = orderEntryList.iterator(); orderEntries.hasNext(); )
- {
- Element orderEntry = (Element) orderEntries.next();
+ assertEquals( "Test Project type", "J2EE_WEB_MODULE", root.attributeValue( "type" ) );
- if ( "module-library".equals( orderEntry.attributeValue( "type" ) ) )
- {
- Element library = (Element) orderEntry.elementIterator( "library" ).next();
-
- Element classes = (Element) library.elementIterator( "CLASSES" ).next();
+ Element component = findComponent( root, "WebModuleBuildComponent" );
- Element root = (Element) classes.elementIterator( "root" ).next();
+ 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, "WebModuleProperties" );
+
+ Element deployDescriptor = component.element( "deploymentDescriptor" );
+ assertEquals( "Test deployment descriptor version", "2.3", deployDescriptor.attributeValue( "version" ) );
+ assertEquals( "Test deployment descriptor name", "web.xml", deployDescriptor.attributeValue( "name" ) );
+ assertEquals( "Test deployment descriptor optional", "false", deployDescriptor.attributeValue( "optional" ) );
+ assertEquals( "Test deployment descriptor file",
+ "file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml",
+ deployDescriptor.attributeValue( "url" ) );
+
+ Element webroots = component.element( "webroots" );
+ Element webroot = webroots.element( "root" );
+ assertEquals( "Test webroot relative location", "/", webroot.attributeValue( "relative" ) );
+ assertEquals( "Test webroot url", "file://$MODULE_DIR$/src/main/webapp", webroot.attributeValue( "url" ) );
- assertTrue( "Dependency is present", expectedDeps.contains( root.attributeValue( "url" ) ) );
+ List containerElementList = findElementsByName( component, "containerElement" );
+ for ( Iterator containerElements = containerElementList.iterator(); containerElements.hasNext(); )
+ {
+ Element containerElement = (Element) containerElements.next();
- expectedDeps.remove( root.attributeValue( "url" ) );
- }
+ assertEquals( "Test container element type", "library", containerElement.attributeValue( "type" ) );
+ assertEquals( "Test container element level", "module", containerElement.attributeValue( "level" ) );
+ assertTrue( "Test library url", containerElement.element( "url" ).getText().startsWith( "jar://" ) );
+
+ Element attribute = findElementByNameAttribute( containerElement, "attribute", "method" );
+ assertEquals( "Test library method", "1", 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 dependencies are present", expectedDeps.size() == 0 );
+ assertTrue( "All libraries are present", expectedLibs.size() == 0 );
}
- public void nottestWarMinConfig()
+ protected Document executeMojo( String pluginXml )
throws Exception
{
List expectedDeps = new ArrayList();
expectedDeps.add( "jar://E:/localRepository/org.apache.maven/maven-model/2.0.1/maven-model-2.0.1.jar!/" );
expectedDeps.add( "jar://E:/localRepository/junit/junit/3.8.1/junit-3.8.1.jar!/" );
- Document imlDocument = executeMojo( "src/test/module-plugin-configs/min-war-plugin-config.xml" );
-
- assertTrue( "All dependencies are present", expectedDeps.size() == 0 );
- }
-
- protected Document executeMojo( String pluginXml )
- throws Exception
- {
Document imlDocument = super.executeMojo( "module", pluginXml, "iml" );
Element component = findComponent( imlDocument.getRootElement(), "NewModuleRootManager" );
@@ -110,6 +130,28 @@
fail( "Unknown sourceFolder 'isTestSource' attribute value: " + isTestSource );
}
}
+
+ List orderEntryList = findElementsByName( component, "orderEntry" );
+
+ for ( Iterator orderEntries = orderEntryList.iterator(); orderEntries.hasNext(); )
+ {
+ Element orderEntry = (Element) orderEntries.next();
+
+ if ( "module-library".equals( orderEntry.attributeValue( "type" ) ) )
+ {
+ Element library = (Element) orderEntry.elementIterator( "library" ).next();
+
+ Element classes = (Element) library.elementIterator( "CLASSES" ).next();
+
+ Element root = (Element) classes.elementIterator( "root" ).next();
+
+ assertTrue( "Dependency is present", expectedDeps.contains( root.attributeValue( "url" ) ) );
+
+ expectedDeps.remove( root.attributeValue( "url" ) );
+ }
+ }
+
+ assertTrue( "All dependencies are present", expectedDeps.size() == 0 );
return imlDocument;
}