check generated plugin.xml against reference plugin-expected.xml
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1210039 13f79535-47bb-0310-9956-ffa450edef68master
parent
c32d7e7b5c
commit
154592cb9a
|
|
@ -68,6 +68,13 @@
|
||||||
<artifactId>qdox</artifactId>
|
<artifactId>qdox</artifactId>
|
||||||
<version>1.11</version>
|
<version>1.11</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>xmlunit</groupId>
|
||||||
|
<artifactId>xmlunit</artifactId>
|
||||||
|
<version>1.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@ import org.apache.maven.tools.plugin.generator.Generator;
|
||||||
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
|
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
|
||||||
import org.codehaus.plexus.component.repository.ComponentDependency;
|
import org.codehaus.plexus.component.repository.ComponentDependency;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
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.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
@ -84,6 +87,9 @@ public class JavaMojoDescriptorExtractorTest
|
||||||
return new DefaultPluginToolsRequest( project, pluginDescriptor ).setEncoding( "UTF-8" );
|
return new DefaultPluginToolsRequest( project, pluginDescriptor ).setEncoding( "UTF-8" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate plugin.xml for a test resources directory content.
|
||||||
|
*/
|
||||||
protected PluginDescriptor generate( String directory )
|
protected PluginDescriptor generate( String directory )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
@ -104,11 +110,42 @@ public class JavaMojoDescriptorExtractorTest
|
||||||
return request.getPluginDescriptor();
|
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" )
|
@SuppressWarnings( "unchecked" )
|
||||||
protected List<MojoDescriptor> extract( String directory )
|
protected List<MojoDescriptor> extract( String directory )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
return generate( directory ).getMojos();
|
PluginDescriptor descriptor = generate( directory );
|
||||||
|
|
||||||
|
checkExpected( directory );
|
||||||
|
|
||||||
|
return descriptor.getMojos();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory()
|
public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory()
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -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>
|
||||||
Loading…
Reference in New Issue