1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.io.file;
19
20 import static org.apache.commons.io.file.CounterAssertions.assertCounts;
21
22 import java.io.IOException;
23
24 import org.junit.jupiter.api.Assertions;
25 import org.junit.jupiter.params.ParameterizedTest;
26 import org.junit.jupiter.params.provider.MethodSource;
27
28
29
30
31 public class CountingPathVisitorTest extends TestArguments {
32
33 private void checkZeroCounts(final CountingPathVisitor visitor) {
34 Assertions.assertEquals(CountingPathVisitor.withLongCounters(), visitor);
35 Assertions.assertEquals(CountingPathVisitor.withBigIntegerCounters(), visitor);
36 }
37
38
39
40
41 @ParameterizedTest
42 @MethodSource("countingPathVisitors")
43 public void testCountEmptyFolder(final CountingPathVisitor visitor) throws IOException {
44 checkZeroCounts(visitor);
45 try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
46 assertCounts(1, 0, 0, PathUtils.visitFileTree(visitor, tempDir.get()));
47 }
48 }
49
50
51
52
53 @ParameterizedTest
54 @MethodSource("countingPathVisitors")
55 public void testCountFolders1FileSize0(final CountingPathVisitor visitor) throws IOException {
56 checkZeroCounts(visitor);
57 assertCounts(1, 1, 0, PathUtils.visitFileTree(visitor,
58 "src/test/resources/org/apache/commons/io/dirs-1-file-size-0"));
59 }
60
61
62
63
64 @ParameterizedTest
65 @MethodSource("countingPathVisitors")
66 public void testCountFolders1FileSize1(final CountingPathVisitor visitor) throws IOException {
67 checkZeroCounts(visitor);
68 assertCounts(1, 1, 1, PathUtils.visitFileTree(visitor,
69 "src/test/resources/org/apache/commons/io/dirs-1-file-size-1"));
70 }
71
72
73
74
75 @ParameterizedTest
76 @MethodSource("countingPathVisitors")
77 public void testCountFolders2FileSize2(final CountingPathVisitor visitor) throws IOException {
78 checkZeroCounts(visitor);
79 assertCounts(3, 2, 2, PathUtils.visitFileTree(visitor,
80 "src/test/resources/org/apache/commons/io/dirs-2-file-size-2"));
81 }
82
83 @ParameterizedTest
84 @MethodSource("countingPathVisitors")
85 void testToString(final CountingPathVisitor visitor) {
86
87 visitor.toString();
88 }
89 }