1 51 package org.apache.excalibur.configuration.test; 52 53 import junit.framework.TestCase; 54 55 import org.apache.avalon.framework.configuration.DefaultConfiguration; 56 import org.apache.excalibur.configuration.ConfigurationUtil; 57 58 63 public final class ConfigurationUtilTestCase extends TestCase 64 { 65 private DefaultConfiguration m_configuration; 66 67 public ConfigurationUtilTestCase() 68 { 69 this( "ConfigurationUtil Test Case" ); 70 } 71 72 public ConfigurationUtilTestCase( String name ) 73 { 74 super( name ); 75 } 76 77 public void setUp() 78 { 79 m_configuration = new DefaultConfiguration( "a", "b" ); 80 } 81 82 public void tearDowm() 83 { 84 m_configuration = null; 85 } 86 87 102 103 public void testIdentityEquals() 104 { 105 assertTrue( ConfigurationUtil.equals( m_configuration, m_configuration ) ); 106 } 107 108 public void testAttributeEquals() 109 { 110 DefaultConfiguration c1 = new DefaultConfiguration("a", "here"); 111 DefaultConfiguration c2 = new DefaultConfiguration("a", "there"); 112 113 c1.setAttribute("test", "test"); 114 c2.setAttribute("test", "test"); 115 116 assertTrue( ConfigurationUtil.equals( c1, c2 ) ); 117 } 118 119 public void testValueEquals() 120 { 121 DefaultConfiguration c1 = new DefaultConfiguration("a", "here"); 122 DefaultConfiguration c2 = new DefaultConfiguration("a", "there"); 123 124 c1.setValue("test"); 125 c2.setValue("test"); 126 127 assertTrue( ConfigurationUtil.equals( c1, c2 ) ); 128 } 129 130 public void testChildrenEquals() 131 { 132 DefaultConfiguration c1 = new DefaultConfiguration("a", "here"); 133 DefaultConfiguration k1 = new DefaultConfiguration("b", "wow"); 134 DefaultConfiguration c2 = new DefaultConfiguration("a", "there"); 135 DefaultConfiguration k2 = new DefaultConfiguration("c", "wow"); 136 DefaultConfiguration k3 = new DefaultConfiguration("c", "wow"); 137 138 k3.setValue( "bigger stronger faster" ); 139 140 k1.setAttribute("test", "test"); 141 k2.setAttribute("test", "test"); 142 143 c1.addChild( k1 ); 144 c2.addChild( k2 ); 145 146 assertTrue( !ConfigurationUtil.equals( c1, c2 ) ); 147 148 c1.addChild( k2 ); 149 c2.addChild( k1 ); 150 151 assertTrue( ConfigurationUtil.equals( c1, c2 ) ); 152 153 c1.addChild( k2 ); 154 c1.addChild( k1 ); 155 c2.addChild( k1 ); 156 c2.addChild( k2 ); 157 c1.addChild( k3 ); 158 c2.addChild( k3 ); 159 160 assertTrue( ConfigurationUtil.equals( c1, c2 ) ); 161 } 162 } 163 164 165 166 167 168 | Popular Tags |