|
57 | 57 |
|
58 | 58 | import lombok.extern.slf4j.Slf4j;
|
59 | 59 |
|
60 |
| -import java.io.File; |
61 | 60 | import java.io.IOException;
|
62 | 61 | import java.math.BigDecimal;
|
63 | 62 | import java.nio.ByteBuffer;
|
| 63 | +import java.nio.file.FileVisitResult; |
| 64 | +import java.nio.file.Path; |
| 65 | +import java.nio.file.Paths; |
| 66 | +import java.nio.file.SimpleFileVisitor; |
| 67 | +import java.nio.file.attribute.BasicFileAttributes; |
64 | 68 | import java.time.LocalDate;
|
65 | 69 | import java.time.LocalDateTime;
|
66 | 70 | import java.time.LocalTime;
|
@@ -135,9 +139,29 @@ public void tearDown() throws Exception {}
|
135 | 139 | @AfterEach
|
136 | 140 | public void clean() {
|
137 | 141 | // clean the catalog dir
|
138 |
| - File catalogDir = new File(CATALOG_DIR); |
139 |
| - if (catalogDir.exists()) { |
140 |
| - catalogDir.delete(); |
| 142 | + Path catalogPath = Paths.get(CATALOG_DIR); |
| 143 | + if (java.nio.file.Files.exists(catalogPath)) { |
| 144 | + try { |
| 145 | + java.nio.file.Files.walkFileTree( |
| 146 | + catalogPath, |
| 147 | + new SimpleFileVisitor<Path>() { |
| 148 | + @Override |
| 149 | + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) |
| 150 | + throws IOException { |
| 151 | + java.nio.file.Files.delete(file); |
| 152 | + return FileVisitResult.CONTINUE; |
| 153 | + } |
| 154 | + |
| 155 | + @Override |
| 156 | + public FileVisitResult postVisitDirectory(Path dir, IOException exc) |
| 157 | + throws IOException { |
| 158 | + java.nio.file.Files.delete(dir); |
| 159 | + return FileVisitResult.CONTINUE; |
| 160 | + } |
| 161 | + }); |
| 162 | + } catch (IOException e) { |
| 163 | + throw new RuntimeException(e); |
| 164 | + } |
141 | 165 | }
|
142 | 166 | }
|
143 | 167 |
|
|
0 commit comments