|
19 | 19 |
|
20 | 20 | import junitparams.JUnitParamsRunner; |
21 | 21 | import junitparams.Parameters; |
| 22 | +import org.apache.commons.io.FileUtils; |
22 | 23 | import org.eclipse.jgit.api.Git; |
23 | 24 | import org.eclipse.jgit.api.ResetCommand; |
24 | 25 | import org.junit.*; |
|
33 | 34 | import java.nio.charset.StandardCharsets; |
34 | 35 | import java.nio.file.Files; |
35 | 36 | import java.nio.file.Path; |
36 | | -import java.nio.file.StandardCopyOption; |
37 | 37 | import java.text.SimpleDateFormat; |
38 | 38 | import java.util.*; |
39 | | -import java.util.stream.Stream; |
40 | 39 |
|
41 | 40 | import static java.util.Arrays.asList; |
42 | 41 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -1511,31 +1510,14 @@ private File createTmpDotGitDirectory(@Nonnull AvailableGitTestRepo availableGit |
1511 | 1510 | Path dotGitDirectory = sandbox.resolve(".git"); |
1512 | 1511 | deleteDir(dotGitDirectory); |
1513 | 1512 |
|
1514 | | - Path src = availableGitTestRepo.getDir().toPath(); |
1515 | | - Path dest = dotGitDirectory; |
1516 | | - |
1517 | | - Stream<Path> files = Files.walk(src); |
1518 | | - // copy all files and folders from `src` to `dest` |
1519 | | - files.forEach(file -> { |
1520 | | - try { |
1521 | | - Files.copy(file, dest.resolve(src.relativize(file)), StandardCopyOption.REPLACE_EXISTING); |
1522 | | - } catch (IOException e) { |
1523 | | - e.printStackTrace(); |
1524 | | - } |
1525 | | - }); |
1526 | | - |
1527 | | - // close the stream |
1528 | | - files.close(); |
| 1513 | + FileUtils.copyDirectory(availableGitTestRepo.getDir(), dotGitDirectory.toFile()); |
1529 | 1514 |
|
1530 | 1515 | return dotGitDirectory.toFile(); |
1531 | 1516 | } |
1532 | 1517 |
|
1533 | 1518 | private void deleteDir(@Nonnull Path toBeDeleted) throws IOException { |
1534 | 1519 | if (toBeDeleted.toFile().exists()) { |
1535 | | - Files.walk(toBeDeleted) |
1536 | | - .sorted(Comparator.reverseOrder()) |
1537 | | - .map(Path::toFile) |
1538 | | - .forEach(File::delete); |
| 1520 | + FileUtils.deleteDirectory(toBeDeleted.toFile()); |
1539 | 1521 | } |
1540 | 1522 | } |
1541 | 1523 |
|
|
0 commit comments