forked from spotbugs/spotbugs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use java.nio to load filter files (spotbugs#2684)
* test: load a filter with non-ascii characters in file name * Use java.nio to load filter files java.io.FileInputStream seems to be running into issues when trying to load files with non-ascii charatecter in the file name. Other similar issues point to this happening on a Mac, so it might be dependent on the combination of OS/JDK version/user settings Originally reported here: JetBrains/spotbugs-intellij-plugin#1492
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/Utf8FilterFileNameTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Contributions to SpotBugs | ||
* Copyright (C) 2023, the SpotBugs authors | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
package edu.umd.cs.findbugs.filter; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
|
||
/** | ||
* @author gtoison | ||
*/ | ||
class Utf8FilterFileNameTest { | ||
@TempDir | ||
private Path folderPath; | ||
|
||
@Test | ||
void loadFilter() { | ||
Path filterPath = folderPath.resolve("äéàùçæð.xml"); | ||
|
||
try { | ||
Files.createFile(filterPath); | ||
Files.writeString(filterPath, "<FindBugsFilter/>"); | ||
|
||
Filter filter = new Filter(filterPath.toAbsolutePath().toString()); | ||
} catch (IOException e) { | ||
fail("Error loading filter file " + filterPath, e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters