commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <>
Subject [jira] [Commented] (COMPRESS-387) Allow spaces in path for unit tests in Windows
Date Wed, 19 Apr 2017 17:16:41 GMT


Uwe Schindler commented on COMPRESS-387:

bq. Thanks, we probably don't need the getPath() at all but could rather stop right after

Yes, that's the correct way to do it. Using getPath() on the URI may break, too. The correct
way (see also the Maven project's code guidelines about URL/URI/File and Classpath) is to
convert the URL to an URI and pass the URI to the File ctor:
(although this is outdated, as newer Java versions have URL.toURI() that works correct.

This is "the correct way" to do this:

URL u = foobar.getResource("...");
File f = new File(u.toURI());

Nevertheless, I'd prefer to get an InputStream directly, as the test suite would fail, if
the resources are in a JAR file for some reason (IDE,...).

> Allow spaces in path for unit tests in Windows
> ----------------------------------------------
>                 Key: COMPRESS-387
>                 URL:
>             Project: Commons Compress
>          Issue Type: Improvement
>            Reporter: Tim Allison
>            Priority: Trivial
>             Fix For: 1.14
> I'm getting build failures on Windows, probably because I'm working in a directory that
has a space in the name (on purpose!).
> If we modify the much better:
> {noformat}
>     private static final File ARCDIR = new File(CLASSLOADER.getResource("archives").getFile());
> {noformat}
> with this hideousness in LongPathTest, LongSymLinkTest and ArchiveReadTest
> {noformat}
>     static {
>         try {
>             ARCDIR = new File(CLASSLOADER.getResource("archives").toURI().getPath());
>         } catch (URISyntaxException e) {
>             throw new RuntimeException(e);
>         }
>     }
> {noformat}
> tests all pass.

This message was sent by Atlassian JIRA

View raw message