o Updated to make the test work when checking out into a directory like "/tmp/Spaces & Special Char/plugin-tools".
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1784345 13f79535-47bb-0310-9956-ffa450edef68master
parent
04684f0fc3
commit
d484f85160
|
|
@ -19,6 +19,16 @@ package org.apache.maven.tools.plugin.extractor.ant;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
|
|
@ -29,18 +39,6 @@ import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
|||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class AntMojoDescriptorExtractorTest
|
||||
extends TestCase
|
||||
|
|
@ -103,34 +101,42 @@ public class AntMojoDescriptorExtractorTest
|
|||
|
||||
private Map buildTestMap( String resourceDirName )
|
||||
{
|
||||
Map result = new HashMap();
|
||||
|
||||
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
|
||||
URL mojosXmlUrl = cloader.getResource( resourceDirName + "/test.mojos.xml" );
|
||||
|
||||
if ( mojosXmlUrl == null )
|
||||
try
|
||||
{
|
||||
fail( "No classpath resource named: '" + resourceDirName + "/test.mojos.xml' could be found." );
|
||||
}
|
||||
Map result = new HashMap();
|
||||
|
||||
File mojosXml = new File( StringUtils.replace( mojosXmlUrl.getPath(), "%20", " " ) );
|
||||
File dir = mojosXml.getParentFile();
|
||||
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
|
||||
URL mojosXmlUrl = cloader.getResource( resourceDirName + "/test.mojos.xml" );
|
||||
|
||||
Set scripts = new HashSet();
|
||||
String[] listing = dir.list();
|
||||
for ( int i = 0; listing != null && i < listing.length; i++ )
|
||||
{
|
||||
if ( listing[i].endsWith( ".mojos.xml" ) )
|
||||
if ( mojosXmlUrl == null )
|
||||
{
|
||||
File f = new File( dir, listing[i] ).getAbsoluteFile();
|
||||
|
||||
scripts.add( f );
|
||||
fail( "No classpath resource named: '" + resourceDirName + "/test.mojos.xml' could be found." );
|
||||
}
|
||||
|
||||
// TODO As of JDK 7, replace with Paths.get( resource.toURI() ).toFile()
|
||||
File mojosXml = new File( mojosXmlUrl.toURI() );
|
||||
File dir = mojosXml.getParentFile();
|
||||
|
||||
Set scripts = new HashSet();
|
||||
String[] listing = dir.list();
|
||||
for ( int i = 0; listing != null && i < listing.length; i++ )
|
||||
{
|
||||
if ( listing[i].endsWith( ".mojos.xml" ) )
|
||||
{
|
||||
File f = new File( dir, listing[i] ).getAbsoluteFile();
|
||||
|
||||
scripts.add( f );
|
||||
}
|
||||
}
|
||||
|
||||
result.put( dir.getAbsolutePath(), scripts );
|
||||
|
||||
return result;
|
||||
}
|
||||
catch ( final URISyntaxException e )
|
||||
{
|
||||
throw new AssertionError( e );
|
||||
}
|
||||
|
||||
result.put( dir.getAbsolutePath(), scripts );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
|
|
|||
|
|
@ -19,16 +19,12 @@ package org.apache.maven.tools.plugin.extractor.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.tools.plugin.extractor.model.PluginMetadataParseException;
|
||||
import org.apache.maven.tools.plugin.extractor.model.PluginMetadataParser;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
|
||||
public class PluginMetadataParserTest
|
||||
extends TestCase
|
||||
|
|
@ -62,13 +58,21 @@ public class PluginMetadataParserTest
|
|||
|
||||
private File getMetadataFile( String name )
|
||||
{
|
||||
URL resource = Thread.currentThread().getContextClassLoader().getResource( name );
|
||||
if ( resource == null )
|
||||
try
|
||||
{
|
||||
fail( "Cannot find classpath resource: '" + name + "'." );
|
||||
}
|
||||
URL resource = Thread.currentThread().getContextClassLoader().getResource( name );
|
||||
if ( resource == null )
|
||||
{
|
||||
fail( "Cannot find classpath resource: '" + name + "'." );
|
||||
}
|
||||
|
||||
return new File( StringUtils.replace( resource.getPath(), "%20", " " ) );
|
||||
// TODO As of JDK 7, replace with Paths.get( resource.toURI() ).toFile()
|
||||
return new File( resource.toURI() );
|
||||
}
|
||||
catch ( final URISyntaxException e )
|
||||
{
|
||||
throw new AssertionError( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@ package org.apache.maven.script.ant;
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
|
@ -29,13 +25,14 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Reader;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Build;
|
||||
|
|
@ -59,9 +56,10 @@ import org.codehaus.plexus.configuration.PlexusConfigurationException;
|
|||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
public class AntMojoWrapperTest
|
||||
extends TestCase
|
||||
|
|
@ -69,7 +67,7 @@ public class AntMojoWrapperTest
|
|||
|
||||
public void test2xStylePlugin()
|
||||
throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException,
|
||||
ComponentConfigurationException, ArchiverException
|
||||
ComponentConfigurationException, ArchiverException, URISyntaxException
|
||||
{
|
||||
String pluginXml = "META-INF/maven/plugin-2.1.xml";
|
||||
|
||||
|
|
@ -89,7 +87,7 @@ public class AntMojoWrapperTest
|
|||
|
||||
public void test20StylePlugin()
|
||||
throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException,
|
||||
ComponentConfigurationException, ArchiverException
|
||||
ComponentConfigurationException, ArchiverException, URISyntaxException
|
||||
{
|
||||
String pluginXml = "META-INF/maven/plugin-2.0.xml";
|
||||
|
||||
|
|
@ -128,7 +126,7 @@ public class AntMojoWrapperTest
|
|||
|
||||
private List<String> run( String pluginXml, boolean includeImplied )
|
||||
throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException,
|
||||
ComponentConfigurationException, ArchiverException
|
||||
ComponentConfigurationException, ArchiverException, URISyntaxException
|
||||
{
|
||||
StackTraceElement stack = new Throwable().getStackTrace()[1];
|
||||
System.out.println( "\n\nRunning: " + stack.getMethodName() + "\n\n" );
|
||||
|
|
@ -146,6 +144,8 @@ public class AntMojoWrapperTest
|
|||
{
|
||||
reader = new InputStreamReader( resource.openStream() );
|
||||
pd = new PluginDescriptorBuilder().build( reader, pluginXml );
|
||||
reader.close();
|
||||
reader = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -168,7 +168,8 @@ public class AntMojoWrapperTest
|
|||
|
||||
if ( includeImplied )
|
||||
{
|
||||
File pluginXmlFile = new File( StringUtils.replace( resource.getPath(), "%20", " " ) );
|
||||
// TODO As of JDK 7, replace with Paths.get( resource.toURI() ).toFile()
|
||||
File pluginXmlFile = new File( resource.toURI() );
|
||||
|
||||
File jarFile = File.createTempFile( "AntMojoWrapperTest.", ".test.jar" );
|
||||
jarFile.deleteOnExit();
|
||||
|
|
|
|||
Loading…
Reference in New Issue