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 93396e7..047f0ea 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,7 +27,6 @@ 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; /** @@ -72,7 +71,7 @@ public class PluginUtilsTest assertEquals( pattern, output ); } - public void testShouldFindTwoScriptsWhenNoExcludesAreGiven() throws UnsupportedEncodingException + public void testShouldFindTwoScriptsWhenNoExcludesAreGiven() { String testScript = "test.txt"; @@ -84,7 +83,7 @@ public class PluginUtilsTest assertEquals( 2, files.length ); } - public void testShouldFindOneScriptsWhenAnExcludeIsGiven() throws UnsupportedEncodingException + public void testShouldFindOneScriptsWhenAnExcludeIsGiven() { 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 cc5a254..925caa8 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 @@ -43,7 +43,7 @@ public class TestUtils assertEquals( URLDecoder.decode( resource.getPath(), "UTF-8" ), basedir + classname ); } - public static String dirname( String file ) throws UnsupportedEncodingException + public static String dirname( String file ) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL fileResource = cl.getResource( file ); @@ -52,7 +52,19 @@ public class TestUtils 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 + try + { + /* + * FIXME: URL encoding and HTML form encoding are not the same. Use FileUtils.toFile(URL) from plexus-utils + * once PLXUTILS-56 is released. + */ + // necessary for JDK 1.5+, where spaces are escaped to %20 + return URLDecoder.decode( path, "UTF-8" ); + } + catch ( UnsupportedEncodingException e ) + { + throw new Error( "Broken JVM, UTF-8 must be supported", e ); + } } -} \ No newline at end of file +} 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 8eb49d3..32ae8b8 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 @@ -106,7 +106,7 @@ public class JavaMojoDescriptorExtractorTest assertEquals( "Implementation parameter", "source2.sub.MyBla", parameter.getImplementation() ); } - private File fileOf( String classpathResource ) throws UnsupportedEncodingException + private File fileOf( String classpathResource ) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL resource = cl.getResource( classpathResource ); @@ -114,8 +114,19 @@ public class JavaMojoDescriptorExtractorTest File result = null; if ( resource != null ) { - // URLDecoder.decode necessary for JDK 1.5+, where spaces are escaped to %20 - result = new File( URLDecoder.decode( resource.getPath(), "UTF-8" ) ); + 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;