EXTSCRIPT-166
git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk@1360717 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/common/util/ClassLoaderUtils.java b/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/common/util/ClassLoaderUtils.java
index 4111cf9..221a736 100644
--- a/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/common/util/ClassLoaderUtils.java
+++ b/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/common/util/ClassLoaderUtils.java
@@ -22,9 +22,11 @@
import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
import java.io.File;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -89,12 +91,18 @@
URL[] urls = resolveClasspath(classLoader);
for (URL url : urls) {
- classpath.append(url.getPath());
-
- // Note that the classpath separator character is platform
- // dependent. On Windows systems it's ";" whereas on other
- // UNIX systems it's ":".
- classpath.append(File.pathSeparatorChar);
+ try
+ {
+ classpath.append(URLDecoder.decode(url.getPath(), "UTF-8"));
+ // Note that the classpath separator character is platform
+ // dependent. On Windows systems it's ";" whereas on other
+ // UNIX systems it's ":".
+ classpath.append(File.pathSeparatorChar);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
}
String retVal = classpath.toString();
diff --git a/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/engine/BaseEngine.java b/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/engine/BaseEngine.java
index 60c9427..f245f52 100644
--- a/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/engine/BaseEngine.java
+++ b/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/engine/BaseEngine.java
@@ -28,7 +28,9 @@
import javax.servlet.ServletContext;
import java.io.File;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
+import java.net.URLDecoder;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -234,7 +236,15 @@
if (pathSeparatedList.equals(defaultValue))
{
URL resource = ClassUtils.getContextClassLoader().getResource("./");
- pathSeparatedList = FilenameUtils.normalize(resource.getPath() + "../.." + defaultValue);
+ try
+ {
+ pathSeparatedList = FilenameUtils.normalize(URLDecoder.decode(resource.getPath(),"UTF-8")
+ + "../.." + defaultValue);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ e.printStackTrace();
+ }
}
String[] paths = pathSeparatedList.split(",");
for (String path : paths)
diff --git a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/GroovyCompilerTest.java b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/GroovyCompilerTest.java
index 3237677..3eaf821 100644
--- a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/GroovyCompilerTest.java
+++ b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/GroovyCompilerTest.java
@@ -29,6 +29,7 @@
import java.io.File;
import java.io.IOException;
+import java.net.URLDecoder;
import static org.junit.Assert.assertTrue;
@@ -69,7 +70,7 @@
//and the ide cannot cope with resource paths for now
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String currentPath = loader.getResource("./").getPath();
+ String currentPath = URLDecoder.decode(loader.getResource("./").getPath());
String sourcePath1 = currentPath + PROBE1;
String sourcePath2 = currentPath + PROBE2;
String rootPath = currentPath + RESOURCES;
diff --git a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/JavaCompilerTest.java b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/JavaCompilerTest.java
index 287532f..fc716d1 100644
--- a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/JavaCompilerTest.java
+++ b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/JavaCompilerTest.java
@@ -38,6 +38,7 @@
import javax.tools.ToolProvider;
import java.io.File;
import java.io.IOException;
+import java.net.URLDecoder;
import java.util.Arrays;
import java.util.Locale;
@@ -78,7 +79,7 @@
//and the ide cannot cope with resource paths for now
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String currentPath = loader.getResource("./").getPath();
+ String currentPath = URLDecoder.decode(loader.getResource("./").getPath());
String sourcePath1 = currentPath + PROBE1;
String sourcePath2 = currentPath + PROBE2;
String rootPath = currentPath + RESOURCES;
diff --git a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/ScalaCompilerTest.java b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/ScalaCompilerTest.java
index a2f73fe..8bb866f 100644
--- a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/ScalaCompilerTest.java
+++ b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/engine/compiler/ScalaCompilerTest.java
@@ -32,6 +32,7 @@
import java.io.File;
import java.io.IOException;
+import java.net.URLDecoder;
import static org.junit.Assert.assertTrue;
@@ -70,7 +71,7 @@
//and the ide cannot cope with resource paths for now
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String currentPath = loader.getResource("./").getPath();
+ String currentPath = URLDecoder.decode(loader.getResource("./").getPath());
String sourcePath1 = currentPath + PROBE1;
String sourcePath2 = currentPath + PROBE2;
String rootPath = currentPath + RESOURCES;
diff --git a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/AbstractGeneratorTestCase.java b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/AbstractGeneratorTestCase.java
index cfc20a3..38ae7ff 100644
--- a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/AbstractGeneratorTestCase.java
+++ b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/AbstractGeneratorTestCase.java
@@ -24,6 +24,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.net.URLDecoder;
/**
* <p>Base class for test cases that generate Java source files.</p>
@@ -45,7 +46,7 @@
public void setUp() throws Exception {
// Create the test directory within the directory that the class file of this test case is located in
testDirectory =
- new File(getClass().getResource(".").toURI().getPath(), "test");
+ new File(URLDecoder.decode(getClass().getResource(".").toURI().getPath()), "test");
if (!testDirectory.mkdirs() && !testDirectory.exists()) {
throw new IllegalStateException(
"Couldn't setup the test case for the test case '" + getClass().getName()
diff --git a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/MockServletContext.java b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/MockServletContext.java
index 67d6824..80fb367 100644
--- a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/MockServletContext.java
+++ b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/MockServletContext.java
@@ -25,6 +25,7 @@
import java.io.File;
import java.lang.reflect.Field;
+import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
@@ -98,8 +99,10 @@
public void setResourceRoot(String newRoot)
{
_resourceRoot = newRoot;
- super.setDocumentRoot(new File(FilenameUtils.normalize(Thread.currentThread().getContextClassLoader().getResource("./")
- .getPath() +
+ super.setDocumentRoot(new File(FilenameUtils.normalize(URLDecoder.decode(Thread.currentThread()
+ .getContextClassLoader()
+ .getResource("./")
+ .getPath()) +
_resourceRoot)));
}
diff --git a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/PathUtils.java b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/PathUtils.java
index d2b2e1d..0e6b269 100644
--- a/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/PathUtils.java
+++ b/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/PathUtils.java
@@ -20,6 +20,7 @@
package org.apache.myfaces.extensions.scripting.core.support;
import java.io.File;
+import java.net.URLDecoder;
/**
* Supportive utils to access the source
@@ -39,7 +40,7 @@
//we use a location relative to our current root one to reach the sources
//because the test also has to be performed outside of maven
//and the ide cannot cope with resource paths for now
- _currentPath = loader.getResource("./").getPath();
+ _currentPath = URLDecoder.decode(loader.getResource("./").getPath());
_resourceRoot = _currentPath + "../../src/test/resources";
}