From b7ef019ea8a6059a66b9948ae314cf64f47d67be Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Sat, 5 Apr 2008 11:16:31 +0000 Subject: [PATCH] fixed tests when there are spaces in directory name git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@645078 13f79535-47bb-0310-9956-ffa450edef68 --- .../extractor/java/JavaMojoDescriptorExtractorTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java index 39ea17c..8eb49d3 100644 --- a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java +++ b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java @@ -27,7 +27,9 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import java.io.File; +import java.io.UnsupportedEncodingException; import java.net.URL; +import java.net.URLDecoder; import java.util.List; /** @@ -104,7 +106,7 @@ public class JavaMojoDescriptorExtractorTest assertEquals( "Implementation parameter", "source2.sub.MyBla", parameter.getImplementation() ); } - private File fileOf( String classpathResource ) + private File fileOf( String classpathResource ) throws UnsupportedEncodingException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL resource = cl.getResource( classpathResource ); @@ -112,7 +114,8 @@ public class JavaMojoDescriptorExtractorTest File result = null; if ( resource != null ) { - result = new File( resource.getPath() ); + // URLDecoder.decode necessary for JDK 1.5+, where spaces are escaped to %20 + result = new File( URLDecoder.decode( resource.getPath(), "UTF-8" ) ); } return result;