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 protected ConfigurationComparator comparator = new StrictConfigurationComparator();
33
34
35
36
37 protected Configuration configuration = new BaseConfiguration();
38
39
40
41
42 @Test
43 public void testCompare() {
44
45 assertTrue(comparator.compare(configuration, configuration));
46
47 configuration.setProperty("one", "1");
48 configuration.setProperty("two", "2");
49 configuration.setProperty("three", "3");
50
51
52 assertTrue(comparator.compare(configuration, configuration));
53
54
55 final Configuration other = new BaseConfiguration();
56 assertFalse(comparator.compare(configuration, other));
57
58 other.setProperty("one", "1");
59 other.setProperty("two", "2");
60 other.setProperty("three", "3");
61
62
63 assertTrue(comparator.compare(configuration, other));
64
65 other.setProperty("four", "4");
66 assertFalse(comparator.compare(configuration, other));
67
68 configuration.setProperty("four", "4");
69 assertTrue(comparator.compare(configuration, other));
70 }
71
72 @Test
73 public void testCompareNull() {
74 assertTrue(comparator.compare(null, null));
75 assertFalse(comparator.compare(configuration, null));
76 assertFalse(comparator.compare(null, configuration));
77 }
78 }