|
|
Re: resource descriptions in unit tests [message #880006 is a reply to message #879614] |
Fri, 01 June 2012 09:15 |
Vlad Dumitrescu Messages: 431 Registered: July 2009 Location: Gothenburg |
Senior Member |
|
|
I found the problem: I am declaring several file extensions for the language files and the ParserHelper uses their concatenation when creating a synthetic name for a resource.
@Inject
@Named(Constants.FILE_EXTENSIONS)
public String fileExtension;
I suppose that parsing the value and taking the first extension will fix this. Something like
protected URI computeUnusedUri(ResourceSet resourceSet) {
String name = "__synthetic";
String ext = firstItem(fileExtension)
for (int i = 0; i < Integer.MAX_VALUE; i++) {
URI syntheticUri = URI.createURI(name + i + "." + ext);
if (resourceSet.getResource(syntheticUri, false) == null)
return syntheticUri;
}
throw new IllegalStateException();
}
private String firstItem(String list) {
list = list.trim();
int ix = list.indexOf(',');
if(ix<0)
return list;
return list.substring(0, ix);
}
best regards,
Vlad
[Updated on: Fri, 01 June 2012 09:15] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03189 seconds