[
https://issues.apache.org/jira/browse/RAT-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18028255#comment-18028255
]
Tilman Hausherr commented on RAT-496:
-------------------------------------
Thank you these work. There are two more in GitIgnoreBuilderTest.java, there
replace the code until {{File file = new File(url.getFile());}}:
{code:java}
public void test_RAT_335() throws URISyntaxException {
GitIgnoreBuilder underTest = new GitIgnoreBuilder() {
@Override
protected Optional<File> globalGitIgnore() {
return Optional.empty();
}
};
URL url =
GitIgnoreBuilderTest.class.getClassLoader().getResource("GitIgnoreBuilderTest/src/");
File file = Paths.get(url.toURI()).toFile();
{code}
{code:java}
public void test_global_gitignore() throws URISyntaxException {
GitIgnoreBuilder underTest = new GitIgnoreBuilder() {
@Override
protected Optional<File> globalGitIgnore() {
URL globalGitIgnoreUrl =
GitIgnoreBuilderTest.class.getClassLoader().getResource("GitIgnoreBuilderTest/global-gitignore");
String globalGitIgnore;
try
{
globalGitIgnore =
Paths.get(globalGitIgnoreUrl.toURI()).toString();
return Optional.of(new File(globalGitIgnore));
}
catch (URISyntaxException ex)
{
return Optional.empty();
}
}
};
URL url =
GitIgnoreBuilderTest.class.getClassLoader().getResource("GitIgnoreBuilderTest/src/");
File file = Paths.get(url.toURI()).toFile();
{code}
Alternatively we could create a file from the "GitIgnoreBuilderTest" resource
during test setup and add the appropriate subdirectory in the individual tests.
> FileNotFoundException in Resources.getExampleResource() if project path has a
> space
> -----------------------------------------------------------------------------------
>
> Key: RAT-496
> URL: https://issues.apache.org/jira/browse/RAT-496
> Project: Apache Rat
> Issue Type: Bug
> Components: core engine
> Affects Versions: 0.17
> Reporter: Tilman Hausherr
> Assignee: Philipp Ottlinger
> Priority: Minor
> Fix For: 0.17
>
>
> I tried to build on my machine and got this:
> java.io.FileNotFoundException: Source
> 'XXXXX\Eigene%20Dateien\XXXX\Java\creadur-rat\apache-rat-core\target\test-classes\examples\exampleData\Source.java'
> does not exist
> at org.apache.commons.io.FileUtils.checkFileExists(FileUtils.java:317)
> at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:855)
> at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:888)
> at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:790)
> at
> org.apache.rat.document.FileDocumentTest.setUp(FileDocumentTest.java:50)
> This can be fixed by changing the code in {{Resources.java}} like this:
> {code:java}
> public static File getExampleResource(String pResource) {
> URL url = Resources.class.getResource("/examples/" + pResource);
> Objects.requireNonNull(url, "/examples/" + pResource + " not found");
> try
> {
> return Paths.get(url.toURI()).toFile();
> }
> catch (URISyntaxException ex)
> {
> throw new IllegalArgumentException(ex);
> }
> }
> {code}
> Using IllegalArgumentException because this is an unchecked exception.
> Alternatively we could throw URISyntaxException but then we'd have to change
> more files.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)