1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.sourceforge.acelogger.filter.test;
16
17 import org.testng.annotations.BeforeMethod;
18 import org.testng.annotations.DataProvider;
19 import org.testng.annotations.Test;
20
21 import net.sourceforge.acelogger.level.LogLevel;
22 import net.sourceforge.acelogger.level.filter.LessOrEqualLevelFilter;
23 import net.sourceforge.acelogger.test.DataProviderHelper;
24
25 import static org.testng.Assert.assertEquals;
26
27
28
29
30
31
32
33
34 @Test
35 public class LessOrEqualLevelFilterTest {
36
37 private LessOrEqualLevelFilter lessFilter;
38
39 @BeforeMethod
40 public void setupTest() {
41 lessFilter = null;
42 }
43
44 @DataProvider
45 public Object[][] identifierConstructorDataProvider() {
46 return DataProviderHelper.loadData();
47 }
48
49 @Test(dataProvider = "identifierConstructorDataProvider")
50 public void testIdentifierConstructor(LogLevel level, boolean shouldPass) {
51 lessFilter = new LessOrEqualLevelFilter(
52 "LessOrEqualLevelFilterTest.testIdentifierConstructor");
53 assertEquals(lessFilter.isSuitable(level), shouldPass);
54 }
55
56 @DataProvider
57 public Object[][] levelConstructorDataProvider() {
58 return DataProviderHelper.loadData();
59 }
60
61 @Test(dataProvider = "levelConstructorDataProvider")
62 public void testLevelConstructor(LogLevel maximumLevel, LogLevel level, boolean shouldPass) {
63 lessFilter = new LessOrEqualLevelFilter("LessOrEqualLevelFilterTest.testLevelConstructor",
64 maximumLevel);
65 assertEquals(lessFilter.isSuitable(level), shouldPass);
66 }
67
68 @DataProvider
69 public Object[][] setDesiredLevelDataProvider() {
70 return new Object[][] {
71 {LogLevel.TRACE, LogLevel.TRACE},
72 {LogLevel.DEBUG, LogLevel.DEBUG},
73 {LogLevel.INFO, LogLevel.INFO},
74 {LogLevel.WARN, LogLevel.WARN},
75 {LogLevel.ERROR, LogLevel.ERROR},
76 {LogLevel.FATAL, LogLevel.FATAL}
77 };
78 }
79
80 @Test(dataProvider = "setDesiredLevelDataProvider")
81 public void testSetDesiredLevel(LogLevel maximumLevel, LogLevel expectedResult) {
82 lessFilter = new LessOrEqualLevelFilter("LessOrEqualLevelFilterTest.testSetDesiredLevel");
83 lessFilter.setMaximumLevel(maximumLevel);
84 assertEquals(lessFilter.getMaximumLevel(), expectedResult);
85 }
86
87
88
89
90 @Test
91 public void testGetIdentifier() {
92 lessFilter = new LessOrEqualLevelFilter("LessOrEqualLevelFilterTest.testGetIdentifier");
93 assertEquals(lessFilter.getIdentifier(), "LessOrEqualLevelFilterTest.testGetIdentifier");
94 }
95
96 }