|
18 | 18 | package org.apache.commons.io.file; |
19 | 19 |
|
20 | 20 | import static org.apache.commons.io.file.CounterAssertions.assertCounts; |
21 | | -import static org.junit.jupiter.api.Assertions.assertTrue; |
22 | 21 |
|
23 | 22 | import java.io.IOException; |
24 | 23 | import java.nio.file.Files; |
25 | 24 | import java.nio.file.Path; |
26 | 25 | import java.nio.file.Paths; |
27 | 26 |
|
28 | 27 | import org.apache.commons.io.file.Counters.PathCounters; |
29 | | -import org.junit.jupiter.api.AfterEach; |
30 | 28 | import org.junit.jupiter.api.Assertions; |
31 | | -import org.junit.jupiter.api.BeforeEach; |
| 29 | +import org.junit.jupiter.api.io.TempDir; |
32 | 30 | import org.junit.jupiter.params.ParameterizedTest; |
33 | 31 | import org.junit.jupiter.params.provider.MethodSource; |
34 | 32 |
|
|
37 | 35 | */ |
38 | 36 | public class CleaningPathVisitorTest extends TestArguments { |
39 | 37 |
|
| 38 | + @TempDir |
40 | 39 | private Path tempDir; |
41 | 40 |
|
42 | | - @AfterEach |
43 | | - public void afterEach() throws IOException { |
44 | | - // temp dir should still exist since we are cleaning and not deleting. |
45 | | - assertTrue(Files.exists(tempDir)); |
46 | | - // backstop |
47 | | - if (Files.exists(tempDir) && PathUtils.isEmptyDirectory(tempDir)) { |
48 | | - Files.deleteIfExists(tempDir); |
49 | | - } |
50 | | - } |
51 | | - |
52 | 41 | private void applyCleanEmptyDirectory(final CleaningPathVisitor visitor) throws IOException { |
53 | 42 | Files.walkFileTree(tempDir, visitor); |
54 | 43 | assertCounts(1, 0, 0, visitor); |
55 | 44 | } |
56 | 45 |
|
57 | | - @BeforeEach |
58 | | - public void beforeEach() throws IOException { |
59 | | - tempDir = Files.createTempDirectory(getClass().getCanonicalName()); |
60 | | - } |
61 | | - |
62 | 46 | /** |
63 | 47 | * Tests an empty folder. |
64 | 48 | */ |
|
0 commit comments