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.RangedLevelFilter;
23 import net.sourceforge.acelogger.test.DataProviderHelper;
24
25 import static org.testng.Assert.assertEquals;
26 import static org.testng.Assert.assertTrue;
27
28
29
30
31
32
33
34
35 @Test
36 public class RangedLevelFilterTest {
37
38 private RangedLevelFilter rangedFilter;
39
40 @BeforeMethod
41 public void setupTest() {
42 rangedFilter = null;
43 }
44
45 @DataProvider
46 public Object[][] identifierConstructorDataProvider() {
47 return DataProviderHelper.loadData();
48 }
49
50 @Test(dataProvider = "identifierConstructorDataProvider")
51 public void testIdentifierConstructor(LogLevel level, boolean shouldPass) {
52 rangedFilter = new RangedLevelFilter("RangedLevelFilterTest.testIdentifierConstructor");
53 assertEquals(rangedFilter.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 minimumLevel, LogLevel maximumLevel, LogLevel level,
63 boolean shouldPass) {
64 rangedFilter = new RangedLevelFilter("RangedLevelFilterTest.testLevelConstructor",
65 minimumLevel, maximumLevel);
66 assertEquals(rangedFilter.isSuitable(level), shouldPass);
67 }
68
69 @DataProvider
70 public Object[][] validRangeDataProvider() {
71 return DataProviderHelper.loadData();
72 }
73
74 @Test(dataProvider = "validRangeDataProvider")
75 public void testConstructorValidRange(LogLevel minimumLevel, LogLevel maximumLevel) {
76 rangedFilter = new RangedLevelFilter("RangedLevelFilterTest.testConstructorValidRange",
77 minimumLevel, maximumLevel);
78 final boolean succeded = rangedFilter.getMinimumLevel().equals(minimumLevel)
79 && rangedFilter.getMaximumLevel().equals(maximumLevel);
80 assertTrue(succeded);
81 }
82
83 @Test(dataProvider = "validRangeDataProvider")
84 public void testSetValidRange(LogLevel minimumLevel, LogLevel maximumLevel) {
85 rangedFilter = new RangedLevelFilter("RangedLevelFilterTest.testSetValidRange");
86 rangedFilter.setLevelRange(minimumLevel, maximumLevel);
87 final boolean succeded = rangedFilter.getMinimumLevel().equals(minimumLevel)
88 && rangedFilter.getMaximumLevel().equals(maximumLevel);
89 assertTrue(succeded);
90 }
91
92
93
94
95 @Test
96 public void testGetIdentifier() {
97 rangedFilter = new RangedLevelFilter("RangedLevelFilterTest.testGetIdentifier");
98 assertEquals(rangedFilter.getIdentifier(), "RangedLevelFilterTest.testGetIdentifier");
99 }
100
101 }