1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.rolling;
15
16 import ch.qos.logback.core.testUtil.CoreTestConstants;
17 import ch.qos.logback.core.util.Compare;
18
19 import java.io.IOException;
20 import java.util.List;
21
22 import static org.junit.jupiter.api.Assertions.assertTrue;
23
24 public class DefaultRolloverChecker implements RolloverChecker {
25
26 final String testId;
27 final boolean withCompression;
28 final String compressionSuffix;
29
30 public DefaultRolloverChecker(String testId, boolean withCompression, String compressionSuffix) {
31 this.testId = testId;
32 this.withCompression = withCompression;
33 this.compressionSuffix = compressionSuffix;
34 }
35
36 public void check(List<String> expectedFilenameList) throws IOException {
37
38 int i = 0;
39 for (String fn : expectedFilenameList) {
40 String suffix = withCompression ? addGZIfNotLast(expectedFilenameList, i, compressionSuffix) : "";
41
42 String witnessFileName = CoreTestConstants.TEST_SRC_PREFIX + "witness/rolling/tbr-" + testId + "." + i
43 + suffix;
44 assertTrue(Compare.compare(fn, witnessFileName));
45 i++;
46 }
47 }
48
49 String addGZIfNotLast(List<String> expectedFilenameList, int i, String suff) {
50 int lastIndex = expectedFilenameList.size() - 1;
51 return (i != lastIndex) ? suff : "";
52 }
53 }