Skip to content

Commit 0299c09

Browse files
committed
Add a regression test for urlToFile(directory)
Java on Windows really has problems in that department: the default AppClassLoader is a URLClassLoader whose getURLs() method returns URLs of the form: file:C:/path/to/file.jar i.e. omitting a slash: it should read file:/C:/path/to/file.jar instead, otherwise, when converted into a URI via the toURI() method, then passed onto a File constructor, one will see the lovely message: IllegalArgumentException: URI is not hierarchical Signed-off-by: Johannes Schindelin <[email protected]>
1 parent bf03041 commit 0299c09

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/test/java/org/scijava/util/FileUtilsTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ public void testURLToFile() throws MalformedURLException {
9696
} else {
9797
jqpublic = "/Users/jqpublic/";
9898
}
99+
100+
final File jqpublicFile = FileUtils.urlToFile("file:" + jqpublic);
101+
assertEqualsPath(jqpublic, jqpublicFile.getPath() + "/");
102+
99103
final String filePath = jqpublic + "imagej/ImageJ.class";
100104
final String fileURL = new File(filePath).toURI().toURL().toString();
101105
final File fileFile = FileUtils.urlToFile(fileURL);

0 commit comments

Comments
 (0)