1 16 17 package org.apache.commons.configuration; 18 19 import junit.framework.TestCase; 20 21 26 public class TestStrictConfigurationComparator extends TestCase 27 { 28 31 protected ConfigurationComparator comparator = new StrictConfigurationComparator(); 32 33 36 protected Configuration configuration = new BaseConfiguration(); 37 38 41 public void testCompare() 42 { 43 assertTrue( 45 "Compare an empty configuration with itself", 46 comparator.compare(configuration, configuration)); 47 48 configuration.setProperty("one", "1"); 49 configuration.setProperty("two", "2"); 50 configuration.setProperty("three", "3"); 51 52 assertTrue( 54 "Compare a configuration with itself", 55 comparator.compare(configuration, configuration)); 56 57 Configuration other = new BaseConfiguration(); 59 assertFalse( 60 "Compare a configuration with an empty one", 61 comparator.compare(configuration, other)); 62 63 other.setProperty("one", "1"); 64 other.setProperty("two", "2"); 65 other.setProperty("three", "3"); 66 67 assertTrue( 69 "Compare a configuration with an identical one", 70 comparator.compare(configuration, other)); 71 72 other.setProperty("four", "4"); 73 assertFalse( 74 "Compare our configuration with another that has an additional key mapping", 75 comparator.compare(configuration, other)); 76 77 configuration.setProperty("four", "4"); 78 assertTrue( 79 "Compare our configuration with another that is identical", 80 comparator.compare(configuration, other)); 81 } 82 83 public void testCompareNull() 84 { 85 assertTrue(comparator.compare(null, null)); 86 assertFalse(comparator.compare(configuration, null)); 87 assertFalse(comparator.compare(null, configuration)); 88 } 89 } 90 | Popular Tags |