use generics
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1337814 13f79535-47bb-0310-9956-ffa450edef68master
parent
369596166a
commit
fb6cee3d5c
|
|
@ -63,7 +63,7 @@ public abstract class AbstractGeneratorTestCase
|
||||||
mojoDescriptor.setImplementation( "org.apache.maven.tools.plugin.generator.TestMojo" );
|
mojoDescriptor.setImplementation( "org.apache.maven.tools.plugin.generator.TestMojo" );
|
||||||
mojoDescriptor.setDependencyResolutionRequired( "compile" );
|
mojoDescriptor.setDependencyResolutionRequired( "compile" );
|
||||||
|
|
||||||
List params = new ArrayList();
|
List<Parameter> params = new ArrayList<Parameter>();
|
||||||
|
|
||||||
Parameter param = new Parameter();
|
Parameter param = new Parameter();
|
||||||
param.setExpression( "${project.build.directory}" );
|
param.setExpression( "${project.build.directory}" );
|
||||||
|
|
@ -134,7 +134,7 @@ public abstract class AbstractGeneratorTestCase
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class generatorClass = Thread.currentThread().getContextClassLoader().loadClass( generatorClassName );
|
Class<?> generatorClass = Thread.currentThread().getContextClassLoader().loadClass( generatorClassName );
|
||||||
|
|
||||||
generator = (Generator) generatorClass.newInstance();
|
generator = (Generator) generatorClass.newInstance();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,10 @@ public class PluginDescriptorGeneratorTest
|
||||||
// Dependencies
|
// Dependencies
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
List dependencies = pluginDescriptor.getDependencies();
|
@SuppressWarnings( "unchecked" )
|
||||||
|
List<ComponentDependency> dependencies = pluginDescriptor.getDependencies();
|
||||||
|
|
||||||
checkDependency( "testGroup", "testArtifact", "0.0.0", (ComponentDependency) dependencies.get( 0 ) );
|
checkDependency( "testGroup", "testArtifact", "0.0.0", dependencies.get( 0 ) );
|
||||||
|
|
||||||
assertEquals( 1, dependencies.size() );
|
assertEquals( 1, dependencies.size() );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||||
|
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -35,7 +36,6 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -46,7 +46,7 @@ import java.util.Set;
|
||||||
public class DefaultMojoScannerTest
|
public class DefaultMojoScannerTest
|
||||||
extends TestCase
|
extends TestCase
|
||||||
{
|
{
|
||||||
private Map extractors;
|
private Map<String, MojoDescriptorExtractor> extractors;
|
||||||
|
|
||||||
private Build build;
|
private Build build;
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ public class DefaultMojoScannerTest
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
extractors = new HashMap();
|
extractors = new HashMap<String, MojoDescriptorExtractor>();
|
||||||
extractors.put( "one", new ScannerTestExtractor( "one" ) );
|
extractors.put( "one", new ScannerTestExtractor( "one" ) );
|
||||||
extractors.put( "two", new ScannerTestExtractor( "two" ) );
|
extractors.put( "two", new ScannerTestExtractor( "two" ) );
|
||||||
extractors.put( "three", new ScannerTestExtractor( "three" ) );
|
extractors.put( "three", new ScannerTestExtractor( "three" ) );
|
||||||
|
|
@ -89,7 +89,7 @@ public class DefaultMojoScannerTest
|
||||||
public void testSpecifiedExtractors()
|
public void testSpecifiedExtractors()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
Set activeExtractors = new HashSet();
|
Set<String> activeExtractors = new HashSet<String>();
|
||||||
activeExtractors.add( "one" );
|
activeExtractors.add( "one" );
|
||||||
activeExtractors.add( "" );
|
activeExtractors.add( "" );
|
||||||
activeExtractors.add( null );
|
activeExtractors.add( null );
|
||||||
|
|
@ -119,7 +119,7 @@ public class DefaultMojoScannerTest
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = createPluginDescriptor();
|
PluginDescriptor pluginDescriptor = createPluginDescriptor();
|
||||||
|
|
||||||
scanner.setActiveExtractors( Collections.EMPTY_SET );
|
scanner.setActiveExtractors( Collections.<String>emptySet() );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
scanner.populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
scanner.populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||||
|
|
@ -130,13 +130,13 @@ public class DefaultMojoScannerTest
|
||||||
// Ok
|
// Ok
|
||||||
}
|
}
|
||||||
|
|
||||||
checkResult( pluginDescriptor, Collections.EMPTY_SET );
|
checkResult( pluginDescriptor, Collections.<String>emptySet() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUnknownExtractor()
|
public void testUnknownExtractor()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
Set activeExtractors = new HashSet();
|
Set<String> activeExtractors = new HashSet<String>();
|
||||||
activeExtractors.add( "four" );
|
activeExtractors.add( "four" );
|
||||||
|
|
||||||
PluginDescriptor pluginDescriptor = createPluginDescriptor();
|
PluginDescriptor pluginDescriptor = createPluginDescriptor();
|
||||||
|
|
@ -153,7 +153,7 @@ public class DefaultMojoScannerTest
|
||||||
// Ok
|
// Ok
|
||||||
}
|
}
|
||||||
|
|
||||||
checkResult( pluginDescriptor, Collections.EMPTY_SET );
|
checkResult( pluginDescriptor, Collections.<String>emptySet() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private PluginDescriptor createPluginDescriptor()
|
private PluginDescriptor createPluginDescriptor()
|
||||||
|
|
@ -173,20 +173,20 @@ public class DefaultMojoScannerTest
|
||||||
* @param pluginDescriptor The {@link PluginDescriptor} to check.
|
* @param pluginDescriptor The {@link PluginDescriptor} to check.
|
||||||
* @param expectedGoals The goal names of the {@link MojoDescriptor}s.
|
* @param expectedGoals The goal names of the {@link MojoDescriptor}s.
|
||||||
*/
|
*/
|
||||||
protected void checkResult( PluginDescriptor pluginDescriptor, Collection expectedGoals )
|
protected void checkResult( PluginDescriptor pluginDescriptor, Collection<String> expectedGoals )
|
||||||
{
|
{
|
||||||
Set remainingGoals = new HashSet( expectedGoals );
|
Set<String> remainingGoals = new HashSet<String>( expectedGoals );
|
||||||
List descriptors = pluginDescriptor.getMojos();
|
@SuppressWarnings( "unchecked" )
|
||||||
|
List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
|
||||||
|
|
||||||
if ( descriptors == null )
|
if ( descriptors == null )
|
||||||
{
|
{
|
||||||
// TODO Maybe getMojos should be more user frendly and not return null
|
// TODO Maybe getMojos should be more user friendly and not return null
|
||||||
descriptors = Collections.EMPTY_LIST;
|
descriptors = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator i = descriptors.iterator(); i.hasNext(); )
|
for ( MojoDescriptor desc : descriptors )
|
||||||
{
|
{
|
||||||
MojoDescriptor desc = (MojoDescriptor) i.next();
|
|
||||||
assertEquals( pluginDescriptor, desc.getPluginDescriptor() );
|
assertEquals( pluginDescriptor, desc.getPluginDescriptor() );
|
||||||
assertTrue( "Unexpected goal in PluginDescriptor: " + desc.getGoal(),
|
assertTrue( "Unexpected goal in PluginDescriptor: " + desc.getGoal(),
|
||||||
remainingGoals.remove( desc.getGoal() ) );
|
remainingGoals.remove( desc.getGoal() ) );
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,13 @@ public class ScannerTestExtractor
|
||||||
this.goal = goal;
|
this.goal = goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
public List<MojoDescriptor> execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||||
throws InvalidPluginDescriptorException, ExtractionException
|
throws InvalidPluginDescriptorException, ExtractionException
|
||||||
{
|
{
|
||||||
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List execute( PluginToolsRequest request )
|
public List<MojoDescriptor> execute( PluginToolsRequest request )
|
||||||
throws ExtractionException, InvalidPluginDescriptorException
|
throws ExtractionException, InvalidPluginDescriptorException
|
||||||
{
|
{
|
||||||
MojoDescriptor desc = new MojoDescriptor();
|
MojoDescriptor desc = new MojoDescriptor();
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,12 @@ public class TestExtractor
|
||||||
implements MojoDescriptorExtractor
|
implements MojoDescriptorExtractor
|
||||||
{
|
{
|
||||||
|
|
||||||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
public List<MojoDescriptor> execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||||
{
|
{
|
||||||
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List execute( PluginToolsRequest request )
|
public List<MojoDescriptor> execute( PluginToolsRequest request )
|
||||||
{
|
{
|
||||||
MojoDescriptor desc = new MojoDescriptor();
|
MojoDescriptor desc = new MojoDescriptor();
|
||||||
desc.setPluginDescriptor( request.getPluginDescriptor() );
|
desc.setPluginDescriptor( request.getPluginDescriptor() );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue