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