WICKET-4915 org.apache.wicket.util.resource.Patht#find fails on Windows

Fix a failing test on Windows.
Path#find() expects a relative url against the folder it was initialized with.
The test is passing on Unix because new File("/", "/tmp/something") leads to 
"//tmp/something" and this is OK.
In Windows: new File("C:\", "C:\tmp\something") leads to "C:\C:\tmp\something".

patch-by: cleiter


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/f4c5a3ad
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/f4c5a3ad
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/f4c5a3ad

Branch: refs/heads/master
Commit: f4c5a3add532da0783a7cbe8e2bf371c1eec55a5
Parents: 5ae1222
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Fri Dec 7 09:33:31 2012 +0100
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Fri Dec 7 09:33:31 2012 +0100

----------------------------------------------------------------------
 .../org/apache/wicket/util/resource/PathTest.java  |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/f4c5a3ad/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java 
b/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java
index 52efe32..e3939f6 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java
@@ -24,7 +24,6 @@ import java.nio.charset.Charset;
 import java.util.Arrays;
 
 import org.apache.wicket.WicketTestCase;
-import org.apache.wicket.util.file.Folder;
 import org.apache.wicket.util.file.Path;
 import org.junit.Test;
 
@@ -38,7 +37,8 @@ public class PathTest extends WicketTestCase
                final File file = createTempFile(contents);
                final File root = findRoot(file);
                final Path path = new Path(root.getCanonicalPath());
-               IResourceStream rs = path.find(PathTest.class, 
file.getCanonicalPath());
+               String relative = 
root.toURI().relativize(file.toURI()).getPath();
+               IResourceStream rs = path.find(PathTest.class, relative);
                assertNotNull(rs);
                assertContents(contents, rs);
        }

Reply via email to