1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.configuration2;
19
20 import static org.junit.jupiter.api.Assertions.assertFalse;
21 import static org.junit.jupiter.api.Assertions.assertTrue;
22
23 import org.junit.jupiter.api.Test;
24
25
26
27
28 public class TestStrictConfigurationComparator {
29
30
31
32
33 protected ConfigurationComparator comparator = new StrictConfigurationComparator();
34
35
36
37
38 protected Configuration configuration = new BaseConfiguration();
39
40
41
42
43 @Test
44 void testCompare() {
45
46 assertTrue(comparator.compare(configuration, configuration));
47
48 configuration.setProperty("one", "1");
49 configuration.setProperty("two", "2");
50 configuration.setProperty("three", "3");
51
52
53 assertTrue(comparator.compare(configuration, configuration));
54
55
56 final Configuration other = new BaseConfiguration();
57 assertFalse(comparator.compare(configuration, other));
58
59 other.setProperty("one", "1");
60 other.setProperty("two", "2");
61 other.setProperty("three", "3");
62
63
64 assertTrue(comparator.compare(configuration, other));
65
66 other.setProperty("four", "4");
67 assertFalse(comparator.compare(configuration, other));
68
69 configuration.setProperty("four", "4");
70 assertTrue(comparator.compare(configuration, other));
71 }
72
73 @Test
74 void testCompareNull() {
75 assertTrue(comparator.compare(null, null));
76 assertFalse(comparator.compare(configuration, null));
77 assertFalse(comparator.compare(null, configuration));
78 }
79 }