commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r750313 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
Date Fri, 06 Mar 2009 13:23:53 GMT
On 06/03/2009, Stefan Bodewig <bodewig@apache.org> wrote:
> On 2009-03-06, sebb <sebbaz@gmail.com> wrote:
>
>  > On 05/03/2009, bodewig@apache.org <bodewig@apache.org> wrote:
>
>
> >>  URL: http://svn.apache.org/viewvc?rev=750313&view=rev
>  >>  Log:
>  >>  make tests pass on Linux
>
>  > However, they now fail on Windows (and compilation fails on Java
>  > 1.4/1.5, but I fixed that).
>
>
> Sorry about the Java6ism.
>
>
>  > Adding back the .getClassLoader() stage improves matters,
>
>
> That really isn't supposed to make any difference, strange.
>

Class.getResource() makes these changes to the resource name:

"if the resource name starts with "/", it is unchanged; otherwise, the
package name is prepended to the resource name after converting "." to
"/". "

ClassLoader.getResource() does not do this.

I've no idea why, but that's what the Javadoc for 1.4 says.

>
>  > but then the ChangeSetTestCase tests fail with
>
>  >      java.io.IOException: Illegal character in path
>
>  > which is caused by the space character.
>
>
> The File -> URI and URI -> File conversions have always been
>  problematic.  I had hoped new File(URI) would work - didn't test on
>  Windows, obviously).
>
>  The IOException probably is wrapping an URISyntaxException, which
>  means URL.toString() has returned an illegal URI on your JDK, great.
>

Looks like it.

This was on Win/XP using

java version "1.4.2_17"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_17-b06)
Java HotSpot(TM) Client VM (build 1.4.2_17-b06, mixed mode)

Works fine using:

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_17-b04)

So it does appear to be a Java bug.

>
>  > I'm not sure that getResource() is the correct method to use here.
>
>
> Well, it works great for files that don't contain spaces in their name
>  8-)

Only if you use the ClassLoader version.

I checked the Continuum build and it reports file not found for test1.xml.

>  A hack could be to check whether the file name contains spaces and
>  locate the parent directory instead of the file itself - or use
>  getResourceAsStream in all tests that want to use files with spaces in
>  their names - neither approach looks nice, but I'm not sure how to
>  locate the files from the resources without hardcoding paths.
>
>  Stefan
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message