transformed unit test to a more complete one

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1215322 13f79535-47bb-0310-9956-ffa450edef68
master
Herve Boutemy 2011-12-16 22:28:37 +00:00
parent d39092e447
commit 14fa7efb74
5 changed files with 156 additions and 100 deletions

View File

@ -155,22 +155,6 @@ public class JavaMojoDescriptorExtractorTest
return descriptor.getMojos();
}
public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory()
throws Exception
{
List<MojoDescriptor> results = extract( "source" );
assertEquals( "Extracted mojos", 2, results.size() );
for ( MojoDescriptor mojoDescriptor : results )
{
assertEquals( 1, mojoDescriptor.getParameters().size() );
Parameter parameter = (Parameter) mojoDescriptor.getParameters().get( 0 );
assertEquals( "project", parameter.getName() );
assertEquals( "java.lang.String[]", parameter.getType() );
}
}
public void testShouldPropagateImplementationParameter()
throws Exception
{

View File

@ -1,48 +0,0 @@
package source;
/*
* 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.
*/
import org.apache.maven.plugin.AbstractMojo;
/**
* Create an IDEA project file from a Maven project.
*
* @goal ideaOne
* @requiresDependencyResolution
*/
public class JavaExtractorTestOne
extends AbstractMojo
{
/**
* Maven project used to generate IDEA project files.
*
* @parameter
* @required
*/
protected String[] project;
public JavaExtractorTestOne()
{
}
public void execute()
{
}
}

View File

@ -1,4 +1,4 @@
package source;
package source.jdoc;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -20,34 +20,40 @@ package source;
*/
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.tools.plugin.scanner.MojoScanner;
/**
* Create an IDEA project file from a Maven project.
* Test default values.
*
* @goal ideaTwo
* @requiresDependencyResolution compile
* @goal default-values
*/
public class JavaExtractorTestTwo
public class Default
extends AbstractMojo
{
/**
* Maven project used to generate IDEA project files.
* A parameter.
*
* @parameter
* @required
*/
private String[] project;
protected String[] parameter;
public JavaExtractorTestTwo()
/**
* An attribute not published as parameter.
*/
protected String[] attribute;
/**
* A component.
*
* @component
*/
private MojoScanner component;
public Default()
{
}
public void execute()
{
if ( getLog() != null )
{
getLog().info( "projects: " + project );
}
}
}

View File

@ -0,0 +1,84 @@
package source.jdoc;
/*
* 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.
*/
import java.io.File;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.tools.plugin.scanner.MojoScanner;
/**
* Test defining every javadoc annotation.
*
* @goal full-annotations
* @aggregator
* @configurator "role-hint"
* @execute phase="site-deploy" lifecycle="site"
* @executionStrategy always
* @inheritByDefault false
* @instantiationStrategy singleton
* @phase install
* @requiresDependencyResolution compile+runtime
* @requiresDependencyCollection test
* @requiresDirectInvocation true
* @requiresOnline true
* @requiresProject false
* @requiresReports true
* @threadSafe
* @since now
* @deprecated deprecation text test
*/
public class Full
extends AbstractMojo
{
/**
* A parameter.
*
* @parameter
*/
protected String[] parameter;
/**
* @parameter alias="myAlias" expression="${aSystemProperty}" default-value="${anExpression}"
* @readonly
* @required
* @since tomorrow
* @deprecated after tomorrow
*/
private File file;
/**
* A component.
*
* @component role="role" roleHint="hint"
* @readonly
* @required
* @since tomorrow
* @deprecated after tomorrow
*/
private MojoScanner component;
public Full()
{
}
public void execute()
{
}
}

View File

@ -30,54 +30,84 @@
<inheritedByDefault>true</inheritedByDefault>
<mojos>
<mojo>
<goal>ideaOne</goal>
<description>Create an IDEA project file from a Maven project.</description>
<requiresDependencyResolution>runtime</requiresDependencyResolution>
<goal>default-values</goal>
<description>Test default values.</description>
<requiresDirectInvocation>false</requiresDirectInvocation>
<requiresProject>true</requiresProject>
<requiresReports>false</requiresReports>
<aggregator>false</aggregator>
<requiresOnline>false</requiresOnline>
<inheritedByDefault>true</inheritedByDefault>
<implementation>source.JavaExtractorTestOne</implementation>
<implementation>source.jdoc.Default</implementation>
<language>java</language>
<instantiationStrategy>per-lookup</instantiationStrategy>
<executionStrategy>once-per-session</executionStrategy>
<threadSafe>false</threadSafe>
<parameters>
<parameter>
<name>project</name>
<name>parameter</name>
<type>java.lang.String[]</type>
<required>true</required>
<required>false</required>
<editable>true</editable>
<description>Maven project used to generate IDEA project files.</description>
<description>A parameter.</description>
</parameter>
</parameters>
<requirements>
<requirement>
<role>org.apache.maven.tools.plugin.scanner.MojoScanner</role>
<field-name>component</field-name>
</requirement>
</requirements>
</mojo>
<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>
<goal>full-annotations</goal>
<description>Test defining every javadoc annotation.</description>
<requiresDependencyResolution>compile+runtime</requiresDependencyResolution>
<requiresDirectInvocation>true</requiresDirectInvocation>
<requiresProject>false</requiresProject>
<requiresReports>true</requiresReports>
<aggregator>true</aggregator>
<requiresOnline>true</requiresOnline>
<inheritedByDefault>false</inheritedByDefault>
<phase>install</phase>
<executePhase>site-deploy</executePhase>
<executeLifecycle>site</executeLifecycle>
<implementation>source.jdoc.Full</implementation>
<language>java</language>
<instantiationStrategy>per-lookup</instantiationStrategy>
<configurator>&quot;role-hint&quot;</configurator>
<instantiationStrategy>singleton</instantiationStrategy>
<executionStrategy>once-per-session</executionStrategy>
<threadSafe>false</threadSafe>
<deprecated>deprecation text test</deprecated>
<requiresDependencyCollection>test</requiresDependencyCollection>
<threadSafe>true</threadSafe>
<parameters>
<parameter>
<name>project</name>
<type>java.lang.String[]</type>
<name>file</name>
<alias>myAlias</alias>
<type>java.io.File</type>
<deprecated>after tomorrow</deprecated>
<required>true</required>
<editable>false</editable>
<description></description>
</parameter>
<parameter>
<name>parameter</name>
<type>java.lang.String[]</type>
<required>false</required>
<editable>true</editable>
<description>Maven project used to generate IDEA project files.</description>
<description>A parameter.</description>
</parameter>
</parameters>
<configuration>
<file implementation="java.io.File" default-value="${anExpression}">${aSystemProperty}</file>
</configuration>
<requirements>
<requirement>
<role>role</role>
<role-hint>hint</role-hint>
<field-name>component</field-name>
</requirement>
</requirements>
</mojo>
</mojos>
<dependencies/>