diff --git a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java index 047f0ea..93396e7 100644 --- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java +++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java @@ -27,6 +27,7 @@ import org.codehaus.plexus.util.xml.CompactXMLWriter; import org.codehaus.plexus.util.xml.XMLWriter; import java.io.StringWriter; +import java.io.UnsupportedEncodingException; import java.util.Collections; /** @@ -71,7 +72,7 @@ public class PluginUtilsTest assertEquals( pattern, output ); } - public void testShouldFindTwoScriptsWhenNoExcludesAreGiven() + public void testShouldFindTwoScriptsWhenNoExcludesAreGiven() throws UnsupportedEncodingException { String testScript = "test.txt"; @@ -83,7 +84,7 @@ public class PluginUtilsTest assertEquals( 2, files.length ); } - public void testShouldFindOneScriptsWhenAnExcludeIsGiven() + public void testShouldFindOneScriptsWhenAnExcludeIsGiven() throws UnsupportedEncodingException { String testScript = "test.txt"; diff --git a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/TestUtils.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/TestUtils.java index fb3fde4..8476dc9 100644 --- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/TestUtils.java +++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/TestUtils.java @@ -21,7 +21,9 @@ package org.apache.maven.tools.plugin.util; import junit.framework.TestCase; +import java.io.UnsupportedEncodingException; import java.net.URL; +import java.net.URLDecoder; /** * @author jdcasey @@ -30,7 +32,7 @@ public class TestUtils extends TestCase { - public void testDirnameFunction_METATEST() + public void testDirnameFunction_METATEST() throws UnsupportedEncodingException { String classname = getClass().getName().replace( '.', '/' ) + ".class"; String basedir = TestUtils.dirname( classname ); @@ -41,14 +43,16 @@ public class TestUtils assertEquals( resource.getPath(), basedir + classname ); } - public static String dirname( String file ) + public static String dirname( String file ) throws UnsupportedEncodingException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL fileResource = cl.getResource( file ); String fullPath = fileResource.getPath(); - return fullPath.substring( 0, fullPath.length() - file.length() ); + String path = fullPath.substring( 0, fullPath.length() - file.length() ); + + return URLDecoder.decode( path, "UTF-8" ); // necessary for JDK 1.5+, where spaces are escaped to %20 } } \ No newline at end of file