| 26 | import static org.assertj.core.api.Assertions.assertThat; |
| 27 | |
| 28 | class TestUtils { |
| 29 | |
| 30 | /** |
| 31 | * Get a File forn item in the resource path. |
| 32 | * |
| 33 | * @param filename |
| 34 | * @return |
| 35 | * @throws IOException |
| 36 | */ |
| 37 | static File getFile(String filename) throws IOException { |
| 38 | URL file = Thread.currentThread().getContextClassLoader().getResource(filename); |
| 39 | assertThat(file).isNotNull(); |
| 40 | File dataFile = new File(file.getFile()); |
| 41 | assertThat(dataFile).isNotNull(); |
| 42 | return dataFile; |
| 43 | } |
| 44 | |
| 45 | static Reader getReader(String filename) throws IOException { |
| 46 | File dataFile = getFile(filename); |
| 47 | return new FileReader(dataFile); |
| 48 | } |
| 49 | |
| 50 | static byte[] getData(File dataFile) throws IOException { |
| 51 | return Files.readAllBytes(dataFile.toPath()); |
| 52 | } |
| 53 | |
| 54 | static byte[] getData(String filename) throws IOException { |
| 55 | File f = getFile(filename); |
| 56 | return getData(f); |
| 57 | } |
| 58 | } |
nothing calls this directly
no outgoing calls
no test coverage detected