|
1 | 1 | package org.utplsql.api.reporter; |
2 | 2 |
|
3 | | -import org.junit.jupiter.api.AfterAll; |
| 3 | +import org.junit.jupiter.api.Tag; |
4 | 4 | import org.junit.jupiter.api.Test; |
| 5 | +import org.junit.jupiter.api.io.TempDir; |
5 | 6 |
|
6 | 7 | import java.io.File; |
7 | | -import java.io.IOException; |
8 | | -import java.nio.file.*; |
9 | | -import java.nio.file.attribute.BasicFileAttributes; |
| 8 | +import java.nio.file.Path; |
| 9 | +import java.nio.file.Paths; |
10 | 10 |
|
11 | 11 | import static org.junit.jupiter.api.Assertions.assertTrue; |
12 | 12 |
|
| 13 | +@Tag("binary") |
13 | 14 | class CoverageHTMLReporterAssetTest { |
14 | 15 |
|
15 | 16 | private static final String TEST_FOLDER = "__testAssets"; |
16 | 17 |
|
17 | | - @AfterAll |
18 | | - static void clearTestAssetsFolder() { |
19 | | - try { |
20 | | - Files.walkFileTree(Paths.get(TEST_FOLDER), new SimpleFileVisitor<Path>() { |
21 | | - @Override |
22 | | - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { |
23 | | - Files.delete(file); |
24 | | - return FileVisitResult.CONTINUE; |
25 | | - } |
26 | | - |
27 | | - @Override |
28 | | - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { |
29 | | - Files.delete(dir); |
30 | | - return FileVisitResult.CONTINUE; |
31 | | - } |
32 | | - }); |
33 | | - } catch (IOException e) { |
34 | | - e.printStackTrace(); |
35 | | - } |
36 | | - } |
| 18 | + @TempDir |
| 19 | + Path tempDir; |
37 | 20 |
|
38 | 21 | private void testFileExists(Path filePath) { |
39 | | - File f = new File(filePath.toUri()); |
| 22 | + File f = new File(tempDir.resolve(TEST_FOLDER).resolve(filePath).toUri()); |
40 | 23 |
|
41 | 24 | assertTrue(f.exists(), () -> "File " + f.toString() + " does not exist"); |
42 | 25 | } |
43 | 26 |
|
44 | 27 | @Test |
45 | 28 | void writeReporterAssetsTo() throws RuntimeException { |
46 | 29 |
|
47 | | - Path targetPath = Paths.get(TEST_FOLDER); |
| 30 | + Path targetPath = tempDir.resolve(TEST_FOLDER); |
48 | 31 |
|
49 | 32 | // Act |
50 | 33 | CoverageHTMLReporter.writeReportAssetsTo(targetPath); |
51 | 34 |
|
52 | | - testFileExists(targetPath.resolve(Paths.get("colorbox", "border.png"))); |
53 | | - testFileExists(targetPath.resolve(Paths.get("colorbox", "controls.png"))); |
54 | | - testFileExists(targetPath.resolve(Paths.get("colorbox", "loading.gif"))); |
55 | | - testFileExists(targetPath.resolve(Paths.get("colorbox", "loading_background.png"))); |
56 | | - |
57 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_flat_0_aaaaaa_40x100.png"))); |
58 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_flat_75_ffffff_40x100.png"))); |
59 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_55_fbf9ee_1x400.png"))); |
60 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_65_ffffff_1x400.png"))); |
61 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_75_dadada_1x400.png"))); |
62 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_75_e6e6e6_1x400.png"))); |
63 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_95_fef1ec_1x400.png"))); |
64 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_highlight-soft_75_cccccc_1x100.png"))); |
65 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_2e83ff_256x240.png"))); |
66 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_222222_256x240.png"))); |
67 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_454545_256x240.png"))); |
68 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_888888_256x240.png"))); |
69 | | - testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_cd0a0a_256x240.png"))); |
70 | | - |
71 | | - testFileExists(targetPath.resolve(Paths.get("application.css"))); |
72 | | - testFileExists(targetPath.resolve(Paths.get("application.js"))); |
73 | | - testFileExists(targetPath.resolve(Paths.get("favicon_green.png"))); |
74 | | - testFileExists(targetPath.resolve(Paths.get("favicon_red.png"))); |
75 | | - testFileExists(targetPath.resolve(Paths.get("favicon_yellow.png"))); |
76 | | - testFileExists(targetPath.resolve(Paths.get("loading.gif"))); |
77 | | - testFileExists(targetPath.resolve(Paths.get("magnify.png"))); |
| 35 | + testFileExists(Paths.get("colorbox", "border.png")); |
| 36 | + testFileExists(Paths.get("colorbox", "controls.png")); |
| 37 | + testFileExists(Paths.get("colorbox", "loading.gif")); |
| 38 | + testFileExists(Paths.get("colorbox", "loading_background.png")); |
| 39 | + |
| 40 | + testFileExists(Paths.get("images", "ui-bg_flat_0_aaaaaa_40x100.png")); |
| 41 | + testFileExists(Paths.get("images", "ui-bg_flat_75_ffffff_40x100.png")); |
| 42 | + testFileExists(Paths.get("images", "ui-bg_glass_55_fbf9ee_1x400.png")); |
| 43 | + testFileExists(Paths.get("images", "ui-bg_glass_65_ffffff_1x400.png")); |
| 44 | + testFileExists(Paths.get("images", "ui-bg_glass_75_dadada_1x400.png")); |
| 45 | + testFileExists(Paths.get("images", "ui-bg_glass_75_e6e6e6_1x400.png")); |
| 46 | + testFileExists(Paths.get("images", "ui-bg_glass_95_fef1ec_1x400.png")); |
| 47 | + testFileExists(Paths.get("images", "ui-bg_highlight-soft_75_cccccc_1x100.png")); |
| 48 | + testFileExists(Paths.get("images", "ui-icons_2e83ff_256x240.png")); |
| 49 | + testFileExists(Paths.get("images", "ui-icons_222222_256x240.png")); |
| 50 | + testFileExists(Paths.get("images", "ui-icons_454545_256x240.png")); |
| 51 | + testFileExists(Paths.get("images", "ui-icons_888888_256x240.png")); |
| 52 | + testFileExists(Paths.get("images", "ui-icons_cd0a0a_256x240.png")); |
| 53 | + |
| 54 | + testFileExists(Paths.get("application.css")); |
| 55 | + testFileExists(Paths.get("application.js")); |
| 56 | + testFileExists(Paths.get("favicon_green.png")); |
| 57 | + testFileExists(Paths.get("favicon_red.png")); |
| 58 | + testFileExists(Paths.get("favicon_yellow.png")); |
| 59 | + testFileExists(Paths.get("loading.gif")); |
| 60 | + testFileExists(Paths.get("magnify.png")); |
78 | 61 |
|
79 | 62 | } |
80 | 63 | } |
0 commit comments