[MPLUGIN-150] Update to QDox 1.9.2
o Updated dependency and added tests that would fail without the update git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@792653 13f79535-47bb-0310-9956-ffa450edef68master
parent
074cf5ba40
commit
a6b3580c3e
|
|
@ -74,7 +74,7 @@
|
|||
<dependency>
|
||||
<groupId>com.thoughtworks.qdox</groupId>
|
||||
<artifactId>qdox</artifactId>
|
||||
<version>1.9.1</version>
|
||||
<version>1.9.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -27,11 +27,10 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -41,13 +40,26 @@ public class JavaMojoDescriptorExtractorTest
|
|||
extends TestCase
|
||||
{
|
||||
|
||||
public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory()
|
||||
private File fileOf( String classpathResource )
|
||||
{
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
URL resource = cl.getResource( classpathResource );
|
||||
|
||||
File result = null;
|
||||
if ( resource != null )
|
||||
{
|
||||
result = FileUtils.toFile( resource );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List extract( String directory )
|
||||
throws Exception
|
||||
{
|
||||
JavaMojoDescriptorExtractor extractor = new JavaMojoDescriptorExtractor();
|
||||
|
||||
File sourceFile = fileOf( "dir-flag.txt" );
|
||||
System.out.println( "found source file: " + sourceFile );
|
||||
|
||||
File dir = sourceFile.getParentFile();
|
||||
|
||||
|
|
@ -57,14 +69,20 @@ public class JavaMojoDescriptorExtractorTest
|
|||
MavenProject project = new MavenProject( model );
|
||||
|
||||
project.setFile( new File( dir, "pom.xml" ) );
|
||||
project.addCompileSourceRoot( new File( dir, "source" ).getPath() );
|
||||
project.addCompileSourceRoot( new File( dir, directory ).getPath() );
|
||||
|
||||
PluginDescriptor pluginDescriptor = new PluginDescriptor();
|
||||
pluginDescriptor.setGoalPrefix( "test" );
|
||||
|
||||
PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
|
||||
PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor ).setEncoding( "UTF-8" );
|
||||
|
||||
List results = extractor.execute( request );
|
||||
return extractor.execute( request );
|
||||
}
|
||||
|
||||
public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory()
|
||||
throws Exception
|
||||
{
|
||||
List results = extract( "source" );
|
||||
|
||||
assertEquals( "Extracted mojos", 2, results.size() );
|
||||
|
||||
|
|
@ -81,27 +99,8 @@ public class JavaMojoDescriptorExtractorTest
|
|||
public void testShouldPropagateImplementationParameter()
|
||||
throws Exception
|
||||
{
|
||||
JavaMojoDescriptorExtractor extractor = new JavaMojoDescriptorExtractor();
|
||||
List results = extract( "source2" );
|
||||
|
||||
File sourceFile = fileOf( "dir-flag.txt" );
|
||||
System.out.println( "found source file: " + sourceFile );
|
||||
|
||||
File dir = sourceFile.getParentFile();
|
||||
|
||||
Model model = new Model();
|
||||
model.setArtifactId( "maven-unitTesting-plugin" );
|
||||
|
||||
MavenProject project = new MavenProject( model );
|
||||
|
||||
project.setFile( new File( dir, "pom.xml" ) );
|
||||
project.addCompileSourceRoot( new File( dir, "source2" ).getPath() );
|
||||
|
||||
PluginDescriptor pluginDescriptor = new PluginDescriptor();
|
||||
pluginDescriptor.setGoalPrefix( "test" );
|
||||
|
||||
PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
|
||||
|
||||
List results = extractor.execute( request );
|
||||
assertEquals( 1, results.size() );
|
||||
|
||||
MojoDescriptor mojoDescriptor = (MojoDescriptor) results.get( 0 );
|
||||
|
|
@ -115,32 +114,6 @@ public class JavaMojoDescriptorExtractorTest
|
|||
assertEquals( "Implementation parameter", "source2.sub.MyBla", parameter.getImplementation() );
|
||||
}
|
||||
|
||||
private File fileOf( String classpathResource )
|
||||
{
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
URL resource = cl.getResource( classpathResource );
|
||||
|
||||
File result = null;
|
||||
if ( resource != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
/*
|
||||
* FIXME: URL encoding and HTML form encoding are not the same. Use FileUtils.toFile(URL) from
|
||||
* plexus-utils once PLXUTILS-56 is released.
|
||||
*/
|
||||
// URLDecoder.decode necessary for JDK 1.5+, where spaces are escaped to %20
|
||||
result = new File( URLDecoder.decode( resource.getPath(), "UTF-8" ) );
|
||||
}
|
||||
catch ( UnsupportedEncodingException e )
|
||||
{
|
||||
throw new Error( "Broken JVM, UTF-8 must be supported", e );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the mojo descriptor extractor will ignore any annotations that are found.
|
||||
*
|
||||
|
|
@ -149,29 +122,21 @@ public class JavaMojoDescriptorExtractorTest
|
|||
public void testAnnotationInPlugin()
|
||||
throws Exception
|
||||
{
|
||||
JavaMojoDescriptorExtractor extractor = new JavaMojoDescriptorExtractor();
|
||||
List results = extract( "source3" );
|
||||
|
||||
File sourceFile = fileOf( "dir-flag.txt" );
|
||||
|
||||
File dir = sourceFile.getParentFile();
|
||||
|
||||
Model model = new Model();
|
||||
model.setArtifactId( "maven-unitTesting-plugin" );
|
||||
|
||||
MavenProject project = new MavenProject( model );
|
||||
|
||||
project.setFile( new File( dir, "pom.xml" ) );
|
||||
project.addCompileSourceRoot( new File( dir, "source3" ).getPath() );
|
||||
|
||||
PluginDescriptor pluginDescriptor = new PluginDescriptor();
|
||||
pluginDescriptor.setGoalPrefix( "test" );
|
||||
|
||||
PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
|
||||
|
||||
List results = extractor.execute( request );
|
||||
assertEquals( 0, results.size() );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the mojo descriptor extractor will successfully parse sources with Java 1.5 language features like
|
||||
* generics.
|
||||
*/
|
||||
public void testJava15SyntaxParsing()
|
||||
throws Exception
|
||||
{
|
||||
List results = extract( "java-1.5" );
|
||||
|
||||
assertEquals( 1, results.size() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
public enum MyEnum
|
||||
{
|
||||
|
||||
@Deprecated()
|
||||
SOME_VALUE,
|
||||
|
||||
// cf. MPLUGIN-151
|
||||
@SuppressWarnings("all")
|
||||
ANOTHER_VALUE,
|
||||
|
||||
@SuppressWarnings(value = { "all" })
|
||||
YET_ANOTHER_VALUE;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import java.util.*;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
|
||||
/**
|
||||
* Test for gleaning of source files with Java 1.5 features
|
||||
*
|
||||
* @goal test
|
||||
*/
|
||||
public class MyMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
// cf. MPLUGIN-152
|
||||
private static final Map<String, String> map1 = Collections.<String, String> emptyMap();
|
||||
|
||||
public void execute()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue