You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ep...@apache.org on 2004/01/16 18:31:39 UTC
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestConfigurationFactory.java
epugh 2004/01/16 09:31:39
Modified: configuration/src/test/org/apache/commons/configuration
TestConfigurationFactory.java
Log:
Fix simian duplicate code error!
Revision Changes Path
1.3 +27 -41 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationFactory.java
Index: TestConfigurationFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestConfigurationFactory.java 16 Jan 2004 14:23:39 -0000 1.2
+++ TestConfigurationFactory.java 16 Jan 2004 17:31:39 -0000 1.3
@@ -147,26 +147,7 @@
//configurationFactory.setDigesterRules(digesterRules.toURL());
configurationFactory.setDigesterRuleNamespaceURI("namespace-one");
- compositeConfiguration = (CompositeConfiguration) configurationFactory.getConfiguration();
-
- assertEquals("Verify how many configs", 2, compositeConfiguration.getNumberOfConfigurations());
-
- assertEquals(PropertiesConfiguration.class, compositeConfiguration.getConfiguration(0).getClass());
-
- PropertiesConfiguration pc = (PropertiesConfiguration) compositeConfiguration.getConfiguration(0);
- assertNotNull("Make sure we have a fileName:" + pc.getFileName(), pc.getFileName());
- assertTrue("Make sure we have loaded our key", pc.getBoolean("test.boolean"));
-
- assertTrue("Make sure we have loaded our key", compositeConfiguration.getBoolean("test.boolean"));
-
- try
- {
- compositeConfiguration.getProperty("element2.subelement.subsubelement");
- fail("Should have thrown an exception");
- }
- catch (java.util.NoSuchElementException nsee)
- {
- }
+ checkCompositeConfiguration();
}
public void testLoadingConfigurationBasePath() throws Exception
@@ -178,26 +159,7 @@
//configurationFactory.setDigesterRules(digesterRules.toURL());
//configurationFactory.setDigesterRuleNamespaceURI("namespace-one");
- compositeConfiguration = (CompositeConfiguration) configurationFactory.getConfiguration();
-
- assertEquals("Verify how many configs", 2, compositeConfiguration.getNumberOfConfigurations());
-
- assertEquals(PropertiesConfiguration.class, compositeConfiguration.getConfiguration(0).getClass());
-
- PropertiesConfiguration pc = (PropertiesConfiguration) compositeConfiguration.getConfiguration(0);
- assertNotNull("Make sure we have a fileName:" + pc.getFileName(), pc.getFileName());
- assertTrue("Make sure we have loaded our key", pc.getBoolean("test.boolean"));
-
- assertTrue("Make sure we have loaded our key", compositeConfiguration.getBoolean("test.boolean"));
-
- try
- {
- compositeConfiguration.getProperty("element2.subelement.subsubelement");
- fail("Should have thrown an exception");
- }
- catch (java.util.NoSuchElementException nsee)
- {
- }
+ checkCompositeConfiguration();
}
public void testLoadingAdditional() throws Exception
@@ -240,4 +202,28 @@
// This was overriden, too, but not in additional section
assertEquals("enhanced factory", compositeConfiguration.getString("test.configuration"));
}
+
+ private void checkCompositeConfiguration() throws Exception
+ {
+ compositeConfiguration = (CompositeConfiguration) configurationFactory.getConfiguration();
+
+ assertEquals("Verify how many configs", 2, compositeConfiguration.getNumberOfConfigurations());
+
+ assertEquals(PropertiesConfiguration.class, compositeConfiguration.getConfiguration(0).getClass());
+
+ PropertiesConfiguration pc = (PropertiesConfiguration) compositeConfiguration.getConfiguration(0);
+ assertNotNull("Make sure we have a fileName:" + pc.getFileName(), pc.getFileName());
+ assertTrue("Make sure we have loaded our key", pc.getBoolean("test.boolean"));
+
+ assertTrue("Make sure we have loaded our key", compositeConfiguration.getBoolean("test.boolean"));
+
+ try
+ {
+ compositeConfiguration.getProperty("element2.subelement.subsubelement");
+ fail("Should have thrown an exception");
+ }
+ catch (java.util.NoSuchElementException nsee)
+ {
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org