Author: hboutemy
Date: Sun Dec 4 01:05:04 2011
New Revision: 1210039
URL: http://svn.apache.org/viewvc?rev=1210039&view=rev
Log:
check generated plugin.xml against reference plugin-expected.xml
Added:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/java-1.5/plugin-expected.xml
(with props)
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source/plugin-expected.xml
(with props)
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source2/plugin-expected.xml
(with props)
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source3/plugin-expected.xml
(with props)
Modified:
maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java
Modified: maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml?rev=1210039&r1=1210038&r2=1210039&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml Sun Dec 4
01:05:04 2011
@@ -68,6 +68,13 @@
<artifactId>qdox</artifactId>
<version>1.11</version>
</dependency>
+
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java?rev=1210039&r1=1210038&r2=1210039&view=diff
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java
(original)
+++
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java
Sun Dec 4 01:05:04 2011
@@ -33,6 +33,9 @@ import org.apache.maven.tools.plugin.gen
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
import org.codehaus.plexus.component.repository.ComponentDependency;
import org.codehaus.plexus.util.FileUtils;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.w3c.dom.Document;
import java.io.File;
import java.net.URL;
@@ -84,6 +87,9 @@ public class JavaMojoDescriptorExtractor
return new DefaultPluginToolsRequest( project, pluginDescriptor
).setEncoding( "UTF-8" );
}
+ /**
+ * generate plugin.xml for a test resources directory content.
+ */
protected PluginDescriptor generate( String directory )
throws Exception
{
@@ -104,11 +110,42 @@ public class JavaMojoDescriptorExtractor
return request.getPluginDescriptor();
}
+ /**
+ * compare mojos from generated plugin.xml against plugin-expected.xml
+ */
+ protected void checkExpected( String directory )
+ throws Exception
+ {
+ File testDirectory = new File( root, directory );
+
+ XMLUnit.setIgnoreWhitespace( true );
+ XMLUnit.setIgnoreComments( true );
+
+ Document expected =
+ XMLUnit.buildControlDocument( FileUtils.fileRead( new File(
testDirectory, "plugin-expected.xml" ), "UTF-8" ) );
+ Document actual =
+ XMLUnit.buildTestDocument( FileUtils.fileRead( new File(
testDirectory, "plugin.xml" ), "UTF-8" ) );
+
+ Diff diff = XMLUnit.compareXML( expected, actual );
+
+ if ( !diff.identical() )
+ {
+ fail( "generated plugin.xml is not identital as
plugin-expected.xml for " + directory + ": " + diff );
+ }
+ }
+
+ /**
+ * extract plugin descriptor for test resources directory and check
against plugin-expected.xml
+ */
@SuppressWarnings( "unchecked" )
protected List<MojoDescriptor> extract( String directory )
throws Exception
{
- return generate( directory ).getMojos();
+ PluginDescriptor descriptor = generate( directory );
+
+ checkExpected( directory );
+
+ return descriptor.getMojos();
}
public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory()
Added:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/java-1.5/plugin-expected.xml
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/java-1.5/plugin-expected.xml?rev=1210039&view=auto
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/java-1.5/plugin-expected.xml
(added)
+++
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/java-1.5/plugin-expected.xml
Sun Dec 4 01:05:04 2011
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<plugin>
+ <name></name>
+ <description></description>
+ <groupId></groupId>
+ <artifactId></artifactId>
+ <version></version>
+ <goalPrefix>test</goalPrefix>
+ <isolatedRealm>false</isolatedRealm>
+ <inheritedByDefault>true</inheritedByDefault>
+ <mojos>
+ <mojo>
+ <goal>test</goal>
+ <description>Test for gleaning of source files with Java 1.5
features</description>
+ <requiresDirectInvocation>false</requiresDirectInvocation>
+ <requiresProject>true</requiresProject>
+ <requiresReports>false</requiresReports>
+ <aggregator>false</aggregator>
+ <requiresOnline>false</requiresOnline>
+ <inheritedByDefault>true</inheritedByDefault>
+ <implementation>MyMojo</implementation>
+ <language>java</language>
+ <instantiationStrategy>per-lookup</instantiationStrategy>
+ <executionStrategy>once-per-session</executionStrategy>
+ <threadSafe>false</threadSafe>
+ <parameters/>
+ </mojo>
+ </mojos>
+ <dependencies/>
+</plugin>
\ No newline at end of file
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/java-1.5/plugin-expected.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/java-1.5/plugin-expected.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/java-1.5/plugin-expected.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source/plugin-expected.xml
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source/plugin-expected.xml?rev=1210039&view=auto
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source/plugin-expected.xml
(added)
+++
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source/plugin-expected.xml
Sun Dec 4 01:05:04 2011
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<plugin>
+ <name></name>
+ <description></description>
+ <groupId></groupId>
+ <artifactId></artifactId>
+ <version></version>
+ <goalPrefix>test</goalPrefix>
+ <isolatedRealm>false</isolatedRealm>
+ <inheritedByDefault>true</inheritedByDefault>
+ <mojos>
+ <mojo>
+ <goal>ideaTwo</goal>
+ <description>Create an IDEA project file from a Maven
project.</description>
+ <requiresDependencyResolution>compile</requiresDependencyResolution>
+ <requiresDirectInvocation>false</requiresDirectInvocation>
+ <requiresProject>true</requiresProject>
+ <requiresReports>false</requiresReports>
+ <aggregator>false</aggregator>
+ <requiresOnline>false</requiresOnline>
+ <inheritedByDefault>true</inheritedByDefault>
+ <implementation>source.JavaExtractorTestTwo</implementation>
+ <language>java</language>
+ <instantiationStrategy>per-lookup</instantiationStrategy>
+ <executionStrategy>once-per-session</executionStrategy>
+ <threadSafe>false</threadSafe>
+ <parameters>
+ <parameter>
+ <name>project</name>
+ <type>java.lang.String[]</type>
+ <required>true</required>
+ <editable>true</editable>
+ <description>Maven project used to generate IDEA project
files.</description>
+ </parameter>
+ </parameters>
+ </mojo>
+ <mojo>
+ <goal>ideaOne</goal>
+ <description>Create an IDEA project file from a Maven
project.</description>
+ <requiresDependencyResolution>runtime</requiresDependencyResolution>
+ <requiresDirectInvocation>false</requiresDirectInvocation>
+ <requiresProject>true</requiresProject>
+ <requiresReports>false</requiresReports>
+ <aggregator>false</aggregator>
+ <requiresOnline>false</requiresOnline>
+ <inheritedByDefault>true</inheritedByDefault>
+ <implementation>source.JavaExtractorTestOne</implementation>
+ <language>java</language>
+ <instantiationStrategy>per-lookup</instantiationStrategy>
+ <executionStrategy>once-per-session</executionStrategy>
+ <threadSafe>false</threadSafe>
+ <parameters>
+ <parameter>
+ <name>project</name>
+ <type>java.lang.String[]</type>
+ <required>true</required>
+ <editable>true</editable>
+ <description>Maven project used to generate IDEA project
files.</description>
+ </parameter>
+ </parameters>
+ </mojo>
+ </mojos>
+ <dependencies/>
+</plugin>
\ No newline at end of file
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source/plugin-expected.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source/plugin-expected.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source/plugin-expected.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source2/plugin-expected.xml
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source2/plugin-expected.xml?rev=1210039&view=auto
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source2/plugin-expected.xml
(added)
+++
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source2/plugin-expected.xml
Sun Dec 4 01:05:04 2011
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<plugin>
+ <name></name>
+ <description></description>
+ <groupId></groupId>
+ <artifactId></artifactId>
+ <version></version>
+ <goalPrefix>test</goalPrefix>
+ <isolatedRealm>false</isolatedRealm>
+ <inheritedByDefault>true</inheritedByDefault>
+ <mojos>
+ <mojo>
+ <goal>ideaThree</goal>
+ <description>Tests the implementation argument of the parameter
annotation.</description>
+ <requiresDependencyResolution>compile</requiresDependencyResolution>
+ <requiresDirectInvocation>false</requiresDirectInvocation>
+ <requiresProject>true</requiresProject>
+ <requiresReports>false</requiresReports>
+ <aggregator>false</aggregator>
+ <requiresOnline>false</requiresOnline>
+ <inheritedByDefault>true</inheritedByDefault>
+ <implementation>source2.JavaExtractorTestThree</implementation>
+ <language>java</language>
+ <instantiationStrategy>per-lookup</instantiationStrategy>
+ <executionStrategy>once-per-session</executionStrategy>
+ <requiresDependencyCollection>test</requiresDependencyCollection>
+ <threadSafe>true</threadSafe>
+ <parameters>
+ <parameter>
+ <name>bla</name>
+ <type>source2.Bla</type>
+ <implementation>source2.sub.MyBla</implementation>
+ <required>true</required>
+ <editable>true</editable>
+ <description></description>
+ </parameter>
+ </parameters>
+ </mojo>
+ </mojos>
+ <dependencies/>
+</plugin>
\ No newline at end of file
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source2/plugin-expected.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source2/plugin-expected.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source2/plugin-expected.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source3/plugin-expected.xml
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source3/plugin-expected.xml?rev=1210039&view=auto
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source3/plugin-expected.xml
(added)
+++
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source3/plugin-expected.xml
Sun Dec 4 01:05:04 2011
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<plugin>
+ <name></name>
+ <description></description>
+ <groupId></groupId>
+ <artifactId></artifactId>
+ <version></version>
+ <goalPrefix>test</goalPrefix>
+ <isolatedRealm>false</isolatedRealm>
+ <inheritedByDefault>true</inheritedByDefault>
+ <mojos/>
+ <dependencies/>
+</plugin>
\ No newline at end of file
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source3/plugin-expected.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source3/plugin-expected.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/resources/source3/plugin-expected.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain