You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metamodel.apache.org by "Kasper Sørensen (JIRA)" <ji...@apache.org> on 2016/07/16 05:23:20 UTC
[jira] [Commented] (METAMODEL-1104) ResourceFactoryRegsitryImplTest
broken on Windows
[ https://issues.apache.org/jira/browse/METAMODEL-1104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15380504#comment-15380504 ]
Kasper Sørensen commented on METAMODEL-1104:
--------------------------------------------
I guess other workarounds could be:
1) To do a {code}file.getAbsolutePath().replace("\", "/");{code} in the unittest, or even
2) Change it so that the string-based method/constructor does a similar backslash-to-slash replacement before calling {code}URI.create(...){code}
And yes, I know those would not be 'correct'. But they would cover a test case which resembles very common developer behaviour (as seen by yours truly in the failing test): It's easy to expect this to work: {code}String uri = "file://" + file.getAbsolutePath{code}
> ResourceFactoryRegsitryImplTest broken on Windows
> -------------------------------------------------
>
> Key: METAMODEL-1104
> URL: https://issues.apache.org/jira/browse/METAMODEL-1104
> Project: Apache MetaModel
> Issue Type: Bug
> Affects Versions: 4.5.4
> Reporter: Dennis Du Krøger
>
> {{ResourceFactoryRegistryImplTest.testGetQualifiedFileResource()}} assumes Unix paths, which breaks the build on Windows machines:
> {code}
> java.lang.IllegalArgumentException: Illegal character in path at index 10: file:///C:\[path to MM folder]\core\src\test\resources\unicode-text-utf8.txt
> {code}
> Quick fix:
> {code:java}
> final String uri = this.getClass().getClassLoader().getResource("unicode-text-utf8.txt").toString();
> final Resource res = registry.createResource(new SimpleResourceProperties(uri));
> {code}
> (uri becomes file:/C:/[mm path]/core/target/test-classes/unicode-text-utf8.txt)
> When referring to test resources, it is usually more compatible and flexible to use {{getResource()}} instead of {{new File()}} calls (a bit of a nono since it assumes build system and working dir)...
> Not entirely sure what to do about the {{testGetUnqualifiedRelativeFileResource()}}, though. It again makes assumptions about file system layout, but at least it doesn't break anything
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)