You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by eb...@apache.org on 2005/01/03 17:35:05 UTC
cvs commit: jakarta-commons/configuration/src/test-cactus/org/apache/commons/configuration TestConfigurationFactoryWithJNDI.java TestJNDIAndCompositeConfiguration.java
ebourg 2005/01/03 08:35:05
Modified: configuration/xdocs changes.xml
configuration/src/test/org/apache/commons/configuration
MockStaticMemoryInitialContextFactory.java
TestBaseNullConfiguration.java
TestCompositeConfigurationNonStringProperties.java
TestConfigurationFactory.java
TestDatabaseConfiguration.java
TestNonStringProperties.java
TestXMLConfiguration.java
configuration/src/test-cactus/org/apache/commons/configuration
TestConfigurationFactoryWithJNDI.java
TestJNDIAndCompositeConfiguration.java
Log:
Tabulations removal
Revision Changes Path
1.79 +27 -27 jakarta-commons/configuration/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- changes.xml 3 Jan 2005 12:42:31 -0000 1.78
+++ changes.xml 3 Jan 2005 16:35:04 -0000 1.79
@@ -13,26 +13,26 @@
FileConfiguration interface to control the encoding of the
configuration file.
</action>
- <action dev="oheger" type="add" issue="31136">
- Access to the top leven element of the XML document is now provided. For
- newly created configurations this element can be changed before the
- document is written.
- </action>
- <action dev="oheger" type="update" issue="31429">
- Merged the two XML related configuration classes into one new class
- XMLConfiguration. This new class should provide the best of its
- ancestors.
- </action>
+ <action dev="oheger" type="add" issue="31136">
+ Access to the top leven element of the XML document is now provided. For
+ newly created configurations this element can be changed before the
+ document is written.
+ </action>
+ <action dev="oheger" type="update" issue="31429">
+ Merged the two XML related configuration classes into one new class
+ XMLConfiguration. This new class should provide the best of its
+ ancestors.
+ </action>
<action dev="ebourg" type="update">
Replaced the PropertyTokenizer inner class in AbstractConfiguration
with the split method in PropertyConverter. Also moved the method
building an iterator on the elements of a composite value in
PropertyConverter as toIterator().
</action>
- <action dev="oheger" type="fix" issue="30858">
- Some cleanup of the handling of the base path in file based configurations.
- The base path is now always taken into account.
- </action>
+ <action dev="oheger" type="fix" issue="30858">
+ Some cleanup of the handling of the base path in file based configurations.
+ The base path is now always taken into account.
+ </action>
<action dev="ebourg" type="fix">
Calling getProperties on a JNDIConfiguration no longer throws an
UnsupportedOperationException.
@@ -42,9 +42,9 @@
concrete configurations now implement directly the getProperty method
from the Configuration interface.
</action>
- <action dev="oheger" type="add" issue="31130">
- Added implementation of a save() method for HierarchicalXMLConfiguration.
- </action>
+ <action dev="oheger" type="add" issue="31130">
+ Added implementation of a save() method for HierarchicalXMLConfiguration.
+ </action>
<action dev="ebourg" type="update">
Constructing a file based configuration with a File no longer throws
an exception when the file doesn't exist.
@@ -61,15 +61,15 @@
This fixes a bug preventing configuration files from being found if
the configuration descriptor is in a JAR file (reported by Grant Ingersoll).
</action>
- <action dev="oheger" type="fix" issue="32236">
- Fixed NPE that were caused in the constructors of file based
- configurations if an invalid file name was specified.
- </action>
- <action dev="oheger" type="add" issue="31797">
- Added support for optional configuration sources in definition files for
- ConfigurationFactory. A new optional attribute allows to specify whether a
- configuration source is mandatory or optional.
- </action>
+ <action dev="oheger" type="fix" issue="32236">
+ Fixed NPE that were caused in the constructors of file based
+ configurations if an invalid file name was specified.
+ </action>
+ <action dev="oheger" type="add" issue="31797">
+ Added support for optional configuration sources in definition files for
+ ConfigurationFactory. A new optional attribute allows to specify whether a
+ configuration source is mandatory or optional.
+ </action>
<action dev="ebourg" type="fix">
JNDIConfiguration.getKeys() now returns an empty iterator instead of
throwing a ConfigurationRuntimeException when a NamingException occurs.
@@ -244,7 +244,7 @@
<action dev="epugh" type="remove">
ConfigurationXMLDocument removed until post 1.0.
</action>
- <action dev="epugh" type="fix" issue="29734">
+ <action dev="epugh" type="fix" issue="29734">
DatabaseConfiguration doesn't support List properties.
</action>
<action dev="ebourg" type="fix">
1.2 +2 -2 jakarta-commons/configuration/src/test/org/apache/commons/configuration/MockStaticMemoryInitialContextFactory.java
Index: MockStaticMemoryInitialContextFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/MockStaticMemoryInitialContextFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MockStaticMemoryInitialContextFactory.java 4 May 2004 22:14:29 -0000 1.1
+++ MockStaticMemoryInitialContextFactory.java 3 Jan 2005 16:35:04 -0000 1.2
@@ -5,6 +5,7 @@
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
+
package org.apache.commons.configuration;
import java.util.Hashtable;
@@ -17,7 +18,6 @@
import org.codehaus.spice.jndikit.DefaultNamespace;
import org.codehaus.spice.jndikit.memory.MemoryContext;
-
/**
* Initial context factory for memorycontext. This factory will
* retrieve the {@link MemoryContext} from a static variable.
@@ -51,7 +51,7 @@
try
{
- Context testContext = me.createSubcontext("test");
+ Context testContext = me.createSubcontext("test");
testContext.bind("key", "jndivalue");
testContext.bind("key2","jndivalue2");
testContext.bind("short","1");
1.4 +436 -436 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBaseNullConfiguration.java
Index: TestBaseNullConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBaseNullConfiguration.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestBaseNullConfiguration.java 14 Dec 2004 17:03:51 -0000 1.3
+++ TestBaseNullConfiguration.java 3 Jan 2005 16:35:04 -0000 1.4
@@ -36,8 +36,8 @@
{
protected BaseConfiguration config = null;
- protected static Class missingElementException = NoSuchElementException.class;
- protected static Class incompatibleElementException = ConversionException.class;
+ protected static Class missingElementException = NoSuchElementException.class;
+ protected static Class incompatibleElementException = ConversionException.class;
protected void setUp() throws Exception
{
@@ -50,450 +50,450 @@
assertFalse("Throw Exception Property is set!", config.isThrowExceptionOnMissing());
}
- public void testGetProperty()
- {
- /* should be empty and return null */
- assertEquals("This returns null", config.getProperty("foo"), null);
-
- /* add a real value, and get it two different ways */
- config.setProperty("number", "1");
- assertEquals("This returns '1'", config.getProperty("number"), "1");
- assertEquals("This returns '1'", config.getString("number"), "1");
- }
-
- public void testGetByte()
- {
- config.setProperty("number", "1");
- byte oneB = 1;
- byte twoB = 2;
- assertEquals("This returns 1(byte)", oneB, config.getByte("number"));
- assertEquals("This returns 1(byte)", oneB, config.getByte("number", twoB));
- assertEquals("This returns 2(default byte)", twoB, config.getByte("numberNotInConfig", twoB));
- assertEquals("This returns 1(Byte)", new Byte(oneB), config.getByte("number", new Byte("2")));
-
- // missing key without default value
- Throwable t = null;
- try {
- config.getByte("numberNotInConfig");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for missing keys", t);
- ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
-
- // existing key with an incompatible value
- config.setProperty("test.empty", "");
- t = null;
- try {
- config.getByte("test.empty");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for incompatible values", t);
- ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
- }
-
- public void testGetShort()
- {
- config.setProperty("numberS", "1");
- short oneS = 1;
- short twoS = 2;
- assertEquals("This returns 1(short)", oneS, config.getShort("numberS"));
- assertEquals("This returns 1(short)", oneS, config.getShort("numberS", twoS));
- assertEquals("This returns 2(default short)", twoS, config.getShort("numberNotInConfig", twoS));
- assertEquals("This returns 1(Short)", new Short(oneS), config.getShort("numberS", new Short("2")));
-
- // missing key without default value
- Throwable t = null;
- try {
- config.getShort("numberNotInConfig");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for missing keys", t);
- ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
-
- // existing key with an incompatible value
- config.setProperty("test.empty", "");
- t = null;
- try {
- config.getShort("test.empty");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for incompatible values", t);
- ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
- }
-
- public void testGetLong()
- {
- config.setProperty("numberL", "1");
- long oneL = 1;
- long twoL = 2;
- assertEquals("This returns 1(long)", oneL, config.getLong("numberL"));
- assertEquals("This returns 1(long)", oneL, config.getLong("numberL", twoL));
- assertEquals("This returns 2(default long)", twoL, config.getLong("numberNotInConfig", twoL));
- assertEquals("This returns 1(Long)", new Long(oneL), config.getLong("numberL", new Long("2")));
-
- // missing key without default value
- Throwable t = null;
- try {
- config.getLong("numberNotInConfig");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for missing keys", t);
- ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
-
- // existing key with an incompatible value
- config.setProperty("test.empty", "");
- t = null;
- try {
- config.getLong("test.empty");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for incompatible values", t);
- ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
- }
-
- public void testGetFloat()
- {
- config.setProperty("numberF", "1.0");
- float oneF = 1;
- float twoF = 2;
- assertEquals("This returns 1(float)", oneF, config.getFloat("numberF"), 0);
- assertEquals("This returns 1(float)", oneF, config.getFloat("numberF", twoF), 0);
- assertEquals("This returns 2(default float)", twoF, config.getFloat("numberNotInConfig", twoF), 0);
- assertEquals("This returns 1(Float)", new Float(oneF), config.getFloat("numberF", new Float("2")));
-
- // missing key without default value
- Throwable t = null;
- try {
- config.getFloat("numberNotInConfig");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for missing keys", t);
- ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
-
- // existing key with an incompatible value
- config.setProperty("test.empty", "");
- t = null;
- try {
- config.getFloat("test.empty");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for incompatible values", t);
- ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
- }
-
- public void testGetDouble()
- {
- config.setProperty("numberD", "1.0");
- double oneD = 1;
- double twoD = 2;
- assertEquals("This returns 1(double)", oneD, config.getDouble("numberD"), 0);
- assertEquals("This returns 1(double)", oneD, config.getDouble("numberD", twoD), 0);
- assertEquals("This returns 2(default double)", twoD, config.getDouble("numberNotInConfig", twoD), 0);
- assertEquals("This returns 1(Double)", new Double(oneD), config.getDouble("numberD", new Double("2")));
-
- // missing key without default value
- Throwable t = null;
- try {
- config.getDouble("numberNotInConfig");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for missing keys", t);
- ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
-
- // existing key with an incompatible value
- config.setProperty("test.empty", "");
- t = null;
- try {
- config.getDouble("test.empty");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for incompatible values", t);
- ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
- }
-
- public void testGetBigDecimal()
- {
- config.setProperty("numberBigD", "123.456");
- BigDecimal number = new BigDecimal("123.456");
- BigDecimal defaultValue = new BigDecimal("654.321");
-
- assertEquals("Existing key", number, config.getBigDecimal("numberBigD"));
- assertEquals("Existing key with default value", number, config.getBigDecimal("numberBigD", defaultValue));
- assertEquals("Missing key with default value", defaultValue, config.getBigDecimal("numberNotInConfig", defaultValue));
+ public void testGetProperty()
+ {
+ /* should be empty and return null */
+ assertEquals("This returns null", config.getProperty("foo"), null);
+
+ /* add a real value, and get it two different ways */
+ config.setProperty("number", "1");
+ assertEquals("This returns '1'", config.getProperty("number"), "1");
+ assertEquals("This returns '1'", config.getString("number"), "1");
+ }
+
+ public void testGetByte()
+ {
+ config.setProperty("number", "1");
+ byte oneB = 1;
+ byte twoB = 2;
+ assertEquals("This returns 1(byte)", oneB, config.getByte("number"));
+ assertEquals("This returns 1(byte)", oneB, config.getByte("number", twoB));
+ assertEquals("This returns 2(default byte)", twoB, config.getByte("numberNotInConfig", twoB));
+ assertEquals("This returns 1(Byte)", new Byte(oneB), config.getByte("number", new Byte("2")));
+
+ // missing key without default value
+ Throwable t = null;
+ try {
+ config.getByte("numberNotInConfig");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for missing keys", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
+
+ // existing key with an incompatible value
+ config.setProperty("test.empty", "");
+ t = null;
+ try {
+ config.getByte("test.empty");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for incompatible values", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
+ }
+
+ public void testGetShort()
+ {
+ config.setProperty("numberS", "1");
+ short oneS = 1;
+ short twoS = 2;
+ assertEquals("This returns 1(short)", oneS, config.getShort("numberS"));
+ assertEquals("This returns 1(short)", oneS, config.getShort("numberS", twoS));
+ assertEquals("This returns 2(default short)", twoS, config.getShort("numberNotInConfig", twoS));
+ assertEquals("This returns 1(Short)", new Short(oneS), config.getShort("numberS", new Short("2")));
+
+ // missing key without default value
+ Throwable t = null;
+ try {
+ config.getShort("numberNotInConfig");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for missing keys", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
+
+ // existing key with an incompatible value
+ config.setProperty("test.empty", "");
+ t = null;
+ try {
+ config.getShort("test.empty");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for incompatible values", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
+ }
+
+ public void testGetLong()
+ {
+ config.setProperty("numberL", "1");
+ long oneL = 1;
+ long twoL = 2;
+ assertEquals("This returns 1(long)", oneL, config.getLong("numberL"));
+ assertEquals("This returns 1(long)", oneL, config.getLong("numberL", twoL));
+ assertEquals("This returns 2(default long)", twoL, config.getLong("numberNotInConfig", twoL));
+ assertEquals("This returns 1(Long)", new Long(oneL), config.getLong("numberL", new Long("2")));
+
+ // missing key without default value
+ Throwable t = null;
+ try {
+ config.getLong("numberNotInConfig");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for missing keys", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
+
+ // existing key with an incompatible value
+ config.setProperty("test.empty", "");
+ t = null;
+ try {
+ config.getLong("test.empty");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for incompatible values", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
+ }
+
+ public void testGetFloat()
+ {
+ config.setProperty("numberF", "1.0");
+ float oneF = 1;
+ float twoF = 2;
+ assertEquals("This returns 1(float)", oneF, config.getFloat("numberF"), 0);
+ assertEquals("This returns 1(float)", oneF, config.getFloat("numberF", twoF), 0);
+ assertEquals("This returns 2(default float)", twoF, config.getFloat("numberNotInConfig", twoF), 0);
+ assertEquals("This returns 1(Float)", new Float(oneF), config.getFloat("numberF", new Float("2")));
+
+ // missing key without default value
+ Throwable t = null;
+ try {
+ config.getFloat("numberNotInConfig");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for missing keys", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
+
+ // existing key with an incompatible value
+ config.setProperty("test.empty", "");
+ t = null;
+ try {
+ config.getFloat("test.empty");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for incompatible values", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
+ }
+
+ public void testGetDouble()
+ {
+ config.setProperty("numberD", "1.0");
+ double oneD = 1;
+ double twoD = 2;
+ assertEquals("This returns 1(double)", oneD, config.getDouble("numberD"), 0);
+ assertEquals("This returns 1(double)", oneD, config.getDouble("numberD", twoD), 0);
+ assertEquals("This returns 2(default double)", twoD, config.getDouble("numberNotInConfig", twoD), 0);
+ assertEquals("This returns 1(Double)", new Double(oneD), config.getDouble("numberD", new Double("2")));
+
+ // missing key without default value
+ Throwable t = null;
+ try {
+ config.getDouble("numberNotInConfig");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for missing keys", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
+
+ // existing key with an incompatible value
+ config.setProperty("test.empty", "");
+ t = null;
+ try {
+ config.getDouble("test.empty");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for incompatible values", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
+ }
- // missing key without default value
+ public void testGetBigDecimal()
+ {
+ config.setProperty("numberBigD", "123.456");
+ BigDecimal number = new BigDecimal("123.456");
+ BigDecimal defaultValue = new BigDecimal("654.321");
+
+ assertEquals("Existing key", number, config.getBigDecimal("numberBigD"));
+ assertEquals("Existing key with default value", number, config.getBigDecimal("numberBigD", defaultValue));
+ assertEquals("Missing key with default value", defaultValue, config.getBigDecimal("numberNotInConfig", defaultValue));
+
+ // missing key without default value
assertEquals("Missing Key is not null!", null, config.getBigDecimal("numberNotInConfig"));
- // existing key with an incompatible value
- config.setProperty("test.empty", "");
- Throwable t = null;
- try {
- config.getBigDecimal("test.empty");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for incompatible values", t);
- ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
- }
-
- public void testGetBigInteger()
- {
- config.setProperty("numberBigI", "1234567890");
- BigInteger number = new BigInteger("1234567890");
- BigInteger defaultValue = new BigInteger("654321");
-
- assertEquals("Existing key", number, config.getBigInteger("numberBigI"));
- assertEquals("Existing key with default value", number, config.getBigInteger("numberBigI", defaultValue));
- assertEquals("Missing key with default value", defaultValue, config.getBigInteger("numberNotInConfig", defaultValue));
+ // existing key with an incompatible value
+ config.setProperty("test.empty", "");
+ Throwable t = null;
+ try {
+ config.getBigDecimal("test.empty");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for incompatible values", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
+ }
+
+ public void testGetBigInteger()
+ {
+ config.setProperty("numberBigI", "1234567890");
+ BigInteger number = new BigInteger("1234567890");
+ BigInteger defaultValue = new BigInteger("654321");
+
+ assertEquals("Existing key", number, config.getBigInteger("numberBigI"));
+ assertEquals("Existing key with default value", number, config.getBigInteger("numberBigI", defaultValue));
+ assertEquals("Missing key with default value", defaultValue, config.getBigInteger("numberNotInConfig", defaultValue));
- // missing key without default value
+ // missing key without default value
assertEquals("Missing Key is not null!", null, config.getBigInteger("numberNotInConfig"));
- // existing key with an incompatible value
- config.setProperty("test.empty", "");
- Throwable t = null;
- try {
- config.getBigInteger("test.empty");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for incompatible values", t);
- ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
- }
-
-
- public void testGetString()
- {
- config.setProperty("testString", "The quick brown fox");
- String string = new String("The quick brown fox");
- String defaultValue = new String("jumps over the lazy dog");
-
- assertEquals("Existing key", string, config.getString("testString"));
- assertEquals("Existing key with default value", string, config.getString("testString", defaultValue));
- assertEquals("Missing key with default value", defaultValue, config.getString("stringNotInConfig", defaultValue));
+ // existing key with an incompatible value
+ config.setProperty("test.empty", "");
+ Throwable t = null;
+ try {
+ config.getBigInteger("test.empty");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for incompatible values", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
+ }
+
- // missing key without default value
+ public void testGetString()
+ {
+ config.setProperty("testString", "The quick brown fox");
+ String string = new String("The quick brown fox");
+ String defaultValue = new String("jumps over the lazy dog");
+
+ assertEquals("Existing key", string, config.getString("testString"));
+ assertEquals("Existing key with default value", string, config.getString("testString", defaultValue));
+ assertEquals("Missing key with default value", defaultValue, config.getString("stringNotInConfig", defaultValue));
+
+ // missing key without default value
assertEquals("Missing Key is not null!", null, config.getString("stringNotInConfig"));
- }
+ }
- public void testGetBoolean()
- {
- config.setProperty("boolA", Boolean.TRUE);
- boolean boolT = true, boolF = false;
- assertEquals("This returns true", boolT, config.getBoolean("boolA"));
- assertEquals("This returns true, not the default", boolT, config.getBoolean("boolA", boolF));
- assertEquals("This returns false(default)", boolF, config.getBoolean("boolNotInConfig", boolF));
- assertEquals("This returns true(Boolean)", new Boolean(boolT), config.getBoolean("boolA", new Boolean(boolF)));
-
- // missing key without default value
- Throwable t = null;
- try {
- config.getBoolean("numberNotInConfig");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for missing keys", t);
- ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
-
- // existing key with an incompatible value
- config.setProperty("test.empty", "");
- t = null;
- try {
- config.getBoolean("test.empty");
- } catch (Throwable T) {
- t = T;
- }
- assertNotNull("No exception thrown for incompatible values", t);
- ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
- }
-
- public void testGetList()
- {
- config.addProperty("number", "1");
- config.addProperty("number", "2");
- List list = config.getList("number");
- assertNotNull("The list is null", list);
- assertEquals("List size", 2, list.size());
- assertTrue("The number 1 is missing from the list", list.contains("1"));
- assertTrue("The number 2 is missing from the list", list.contains("2"));
-
- /*
- * now test dan's new fix where we get the first scalar
- * when we access a list valued property
- */
- try
- {
- config.getString("number");
- }
- catch (NoSuchElementException nsse)
- {
- fail("Should return a string");
- }
- }
-
- public void testCommaSeparatedString()
- {
- String prop = "hey, that's a test";
- config.setProperty("prop.string", prop);
- try
- {
- config.getList("prop.string");
- }
- catch (NoSuchElementException nsse)
- {
- fail("Should return a list");
- }
-
- String prop2 = "hey\\, that's a test";
- config.clearProperty("prop.string");
- config.setProperty("prop.string", prop2);
- try
- {
- config.getString("prop.string");
- }
- catch (NoSuchElementException nsse)
- {
- fail("Should return a list");
- }
-
- }
-
- public void testPropertyAccess()
- {
- config.clearProperty("prop.properties");
- config.setProperty("prop.properties", "");
- assertEquals(
- "This returns an empty Properties object",
- config.getProperties("prop.properties"),
- new Properties());
- config.clearProperty("prop.properties");
- config.setProperty("prop.properties", "foo=bar, baz=moo, seal=clubber");
-
- Properties p = new Properties();
- p.setProperty("foo", "bar");
- p.setProperty("baz", "moo");
- p.setProperty("seal", "clubber");
- assertEquals(
- "This returns a filled in Properties object",
- config.getProperties("prop.properties"),
- p);
- }
-
- public void testSubset()
- {
- /*
- * test subset : assure we don't reprocess the data elements
- * when generating the subset
- */
-
- String prop = "hey, that's a test";
- String prop2 = "hey\\, that's a test";
- config.setProperty("prop.string", prop2);
- config.setProperty("property.string", "hello");
-
- Configuration subEprop = config.subset("prop");
-
- assertEquals(
- "Returns the full string",
- prop,
- subEprop.getString("string"));
- try
- {
- subEprop.getString("string");
- }
- catch (NoSuchElementException nsse)
- {
- fail("Should return a string");
- }
- try
- {
- subEprop.getList("string");
- }
- catch (NoSuchElementException nsse)
- {
- fail("Should return a list");
- }
-
- Iterator it = subEprop.getKeys();
- it.next();
- assertFalse(it.hasNext());
-
- subEprop = config.subset("prop.");
- it = subEprop.getKeys();
- assertFalse(it.hasNext());
- }
-
- public void testInterpolation() throws Exception
- {
- config.setProperty("applicationRoot", "/home/applicationRoot");
- config.setProperty("db", "${applicationRoot}/db/hypersonic");
- String unInterpolatedValue = "${applicationRoot2}/db/hypersonic";
- config.setProperty("dbFailedInterpolate", unInterpolatedValue);
- String dbProp = "/home/applicationRoot/db/hypersonic";
-
- //construct a new config, using config as the defaults config for it.
- BaseConfiguration superProp = config;
-
- assertEquals(
- "Checking interpolated variable",dbProp,
- superProp.getString("db"));
- assertEquals(
- "lookup fails, leave variable as is",
- superProp.getString("dbFailedInterpolate"),
- unInterpolatedValue);
-
- superProp.setProperty("arrayInt", "${applicationRoot}/1");
- String[] arrayInt = superProp.getStringArray("arrayInt");
- assertEquals(
- "check first entry was interpolated",
- "/home/applicationRoot/1",
- arrayInt[0]);
- }
-
- public void testMultipleInterpolation() throws Exception
- {
- config.setProperty("test.base-level", "/base-level");
- config.setProperty("test.first-level", "${test.base-level}/first-level");
- config.setProperty(
- "test.second-level",
- "${test.first-level}/second-level");
- config.setProperty(
- "test.third-level",
- "${test.second-level}/third-level");
-
- String expectedValue =
- "/base-level/first-level/second-level/third-level";
-
- assertEquals(config.getString("test.third-level"), expectedValue);
- }
-
- public void testInterpolationLoop() throws Exception
- {
- config.setProperty("test.a", "${test.b}");
- config.setProperty("test.b", "${test.a}");
-
- try
- {
- config.getString("test.a");
- }
- catch (IllegalStateException e)
- {
- return;
- }
+ public void testGetBoolean()
+ {
+ config.setProperty("boolA", Boolean.TRUE);
+ boolean boolT = true, boolF = false;
+ assertEquals("This returns true", boolT, config.getBoolean("boolA"));
+ assertEquals("This returns true, not the default", boolT, config.getBoolean("boolA", boolF));
+ assertEquals("This returns false(default)", boolF, config.getBoolean("boolNotInConfig", boolF));
+ assertEquals("This returns true(Boolean)", new Boolean(boolT), config.getBoolean("boolA", new Boolean(boolF)));
+
+ // missing key without default value
+ Throwable t = null;
+ try {
+ config.getBoolean("numberNotInConfig");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for missing keys", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for missing keys", missingElementException, t);
+
+ // existing key with an incompatible value
+ config.setProperty("test.empty", "");
+ t = null;
+ try {
+ config.getBoolean("test.empty");
+ } catch (Throwable T) {
+ t = T;
+ }
+ assertNotNull("No exception thrown for incompatible values", t);
+ ObjectAssert.assertInstanceOf("Exception thrown for incompatible values", incompatibleElementException, t);
+ }
+
+ public void testGetList()
+ {
+ config.addProperty("number", "1");
+ config.addProperty("number", "2");
+ List list = config.getList("number");
+ assertNotNull("The list is null", list);
+ assertEquals("List size", 2, list.size());
+ assertTrue("The number 1 is missing from the list", list.contains("1"));
+ assertTrue("The number 2 is missing from the list", list.contains("2"));
+
+ /*
+ * now test dan's new fix where we get the first scalar
+ * when we access a list valued property
+ */
+ try
+ {
+ config.getString("number");
+ }
+ catch (NoSuchElementException nsse)
+ {
+ fail("Should return a string");
+ }
+ }
+
+ public void testCommaSeparatedString()
+ {
+ String prop = "hey, that's a test";
+ config.setProperty("prop.string", prop);
+ try
+ {
+ config.getList("prop.string");
+ }
+ catch (NoSuchElementException nsse)
+ {
+ fail("Should return a list");
+ }
+
+ String prop2 = "hey\\, that's a test";
+ config.clearProperty("prop.string");
+ config.setProperty("prop.string", prop2);
+ try
+ {
+ config.getString("prop.string");
+ }
+ catch (NoSuchElementException nsse)
+ {
+ fail("Should return a list");
+ }
- fail("IllegalStateException should have been thrown for looped property references");
- }
+ }
+
+ public void testPropertyAccess()
+ {
+ config.clearProperty("prop.properties");
+ config.setProperty("prop.properties", "");
+ assertEquals(
+ "This returns an empty Properties object",
+ config.getProperties("prop.properties"),
+ new Properties());
+ config.clearProperty("prop.properties");
+ config.setProperty("prop.properties", "foo=bar, baz=moo, seal=clubber");
+
+ Properties p = new Properties();
+ p.setProperty("foo", "bar");
+ p.setProperty("baz", "moo");
+ p.setProperty("seal", "clubber");
+ assertEquals(
+ "This returns a filled in Properties object",
+ config.getProperties("prop.properties"),
+ p);
+ }
+
+ public void testSubset()
+ {
+ /*
+ * test subset : assure we don't reprocess the data elements
+ * when generating the subset
+ */
+
+ String prop = "hey, that's a test";
+ String prop2 = "hey\\, that's a test";
+ config.setProperty("prop.string", prop2);
+ config.setProperty("property.string", "hello");
+
+ Configuration subEprop = config.subset("prop");
+
+ assertEquals(
+ "Returns the full string",
+ prop,
+ subEprop.getString("string"));
+ try
+ {
+ subEprop.getString("string");
+ }
+ catch (NoSuchElementException nsse)
+ {
+ fail("Should return a string");
+ }
+ try
+ {
+ subEprop.getList("string");
+ }
+ catch (NoSuchElementException nsse)
+ {
+ fail("Should return a list");
+ }
+
+ Iterator it = subEprop.getKeys();
+ it.next();
+ assertFalse(it.hasNext());
+
+ subEprop = config.subset("prop.");
+ it = subEprop.getKeys();
+ assertFalse(it.hasNext());
+ }
+
+ public void testInterpolation() throws Exception
+ {
+ config.setProperty("applicationRoot", "/home/applicationRoot");
+ config.setProperty("db", "${applicationRoot}/db/hypersonic");
+ String unInterpolatedValue = "${applicationRoot2}/db/hypersonic";
+ config.setProperty("dbFailedInterpolate", unInterpolatedValue);
+ String dbProp = "/home/applicationRoot/db/hypersonic";
+
+ //construct a new config, using config as the defaults config for it.
+ BaseConfiguration superProp = config;
+
+ assertEquals(
+ "Checking interpolated variable",dbProp,
+ superProp.getString("db"));
+ assertEquals(
+ "lookup fails, leave variable as is",
+ superProp.getString("dbFailedInterpolate"),
+ unInterpolatedValue);
+
+ superProp.setProperty("arrayInt", "${applicationRoot}/1");
+ String[] arrayInt = superProp.getStringArray("arrayInt");
+ assertEquals(
+ "check first entry was interpolated",
+ "/home/applicationRoot/1",
+ arrayInt[0]);
+ }
+
+ public void testMultipleInterpolation() throws Exception
+ {
+ config.setProperty("test.base-level", "/base-level");
+ config.setProperty("test.first-level", "${test.base-level}/first-level");
+ config.setProperty(
+ "test.second-level",
+ "${test.first-level}/second-level");
+ config.setProperty(
+ "test.third-level",
+ "${test.second-level}/third-level");
+
+ String expectedValue =
+ "/base-level/first-level/second-level/third-level";
+
+ assertEquals(config.getString("test.third-level"), expectedValue);
+ }
+
+ public void testInterpolationLoop() throws Exception
+ {
+ config.setProperty("test.a", "${test.b}");
+ config.setProperty("test.b", "${test.a}");
+
+ try
+ {
+ config.getString("test.a");
+ }
+ catch (IllegalStateException e)
+ {
+ return;
+ }
+
+ fail("IllegalStateException should have been thrown for looped property references");
+ }
}
1.5 +12 -14 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestCompositeConfigurationNonStringProperties.java
Index: TestCompositeConfigurationNonStringProperties.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestCompositeConfigurationNonStringProperties.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestCompositeConfigurationNonStringProperties.java 2 Jun 2004 16:42:24 -0000 1.4
+++ TestCompositeConfigurationNonStringProperties.java 3 Jan 2005 16:35:04 -0000 1.5
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.io.File;
/**
@@ -25,17 +25,15 @@
*/
public class TestCompositeConfigurationNonStringProperties extends BaseNonStringProperties
{
- /** The File that we test with */
- private String testProperties = new File("conf/test.properties").getAbsolutePath();
+ /** The File that we test with */
+ private String testProperties = new File("conf/test.properties").getAbsolutePath();
- public void setUp() throws Exception
- {
- PropertiesConfiguration pc =
- new PropertiesConfiguration(testProperties);
- CompositeConfiguration cc = new CompositeConfiguration();
- cc.addConfiguration(pc);
- conf = cc;
- nonStringTestHolder.setConfiguration(conf);
- }
+ public void setUp() throws Exception
+ {
+ CompositeConfiguration cc = new CompositeConfiguration();
+ cc.addConfiguration(new PropertiesConfiguration(testProperties));
+ conf = cc;
+ nonStringTestHolder.setConfiguration(conf);
+ }
}
1.20 +2 -2 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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- TestConfigurationFactory.java 19 Nov 2004 19:25:47 -0000 1.19
+++ TestConfigurationFactory.java 3 Jan 2005 16:35:04 -0000 1.20
@@ -48,7 +48,7 @@
private File testDigesterFileOptional =
new File("conf/testDigesterOptionalConfiguration.xml");
private File testDigesterFileOptionalEx =
- new File("conf/testDigesterOptionalConfigurationEx.xml");
+ new File("conf/testDigesterOptionalConfigurationEx.xml");
private File testDigesterBadXML = new File("conf/testDigesterBadXML.xml");
1.13 +8 -8 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java
Index: TestDatabaseConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TestDatabaseConfiguration.java 2 Dec 2004 22:05:52 -0000 1.12
+++ TestDatabaseConfiguration.java 3 Jan 2005 16:35:04 -0000 1.13
@@ -35,7 +35,7 @@
/**
* Test for database stored configurations. Note, when running this Unit
- * Test in Eclipse it sometimes takes a couple tries. Otherwise you ma get
+ * Test in Eclipse it sometimes takes a couple tries. Otherwise you may get
* database is already in use by another process errors.
*
* @version $Revision$, $Date$
@@ -51,12 +51,12 @@
protected void setUp() throws Exception
{
- /*
- * Thread.sleep may or may not help with the database is already in
- * use exception.
- */
- //Thread.sleep(1000);
-
+ /*
+ * Thread.sleep may or may not help with the database is already in
+ * use exception.
+ */
+ //Thread.sleep(1000);
+
// set up the datasource
if (hsqlDB == null)
1.4 +8 -8 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestNonStringProperties.java
Index: TestNonStringProperties.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestNonStringProperties.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestNonStringProperties.java 27 Feb 2004 17:41:34 -0000 1.3
+++ TestNonStringProperties.java 3 Jan 2005 16:35:04 -0000 1.4
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.io.File;
/**
@@ -27,11 +27,11 @@
{
/** The File that we test with */
private String testProperties = new File("conf/test.properties").getAbsolutePath();
-
- public void setUp() throws Exception{
- conf = new PropertiesConfiguration(testProperties);
- nonStringTestHolder.setConfiguration(conf);
+
+ public void setUp() throws Exception
+ {
+ conf = new PropertiesConfiguration(testProperties);
+ nonStringTestHolder.setConfiguration(conf);
}
-
}
1.18 +8 -8 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
Index: TestXMLConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestXMLConfiguration.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- TestXMLConfiguration.java 31 Dec 2004 16:00:00 -0000 1.17
+++ TestXMLConfiguration.java 3 Jan 2005 16:35:04 -0000 1.18
@@ -339,13 +339,13 @@
public void testSave() throws Exception
{
- // remove the file previously saved if necessary
+ // remove the file previously saved if necessary
if(testSaveConf.exists()){
- assertTrue(testSaveConf.delete());
- }
+ assertTrue(testSaveConf.delete());
+ }
// add an array of strings to the configuration
- conf.addProperty("string", "value1");
+ conf.addProperty("string", "value1");
for (int i = 1; i < 5; i++)
{
conf.addProperty("test.array", "value" + i);
@@ -367,9 +367,9 @@
for (Iterator i = conf.getKeys(); i.hasNext();)
{
- String key = (String) i.next();
- assertTrue("The saved configuration doesn't contain the key '" + key + "'", checkConfig.containsKey(key));
- assertEquals("Value of the '" + key + "' property", conf.getProperty(key), checkConfig.getProperty(key));
+ String key = (String) i.next();
+ assertTrue("The saved configuration doesn't contain the key '" + key + "'", checkConfig.containsKey(key));
+ assertEquals("Value of the '" + key + "' property", conf.getProperty(key), checkConfig.getProperty(key));
}
}
1.4 +50 -50 jakarta-commons/configuration/src/test-cactus/org/apache/commons/configuration/TestConfigurationFactoryWithJNDI.java
Index: TestConfigurationFactoryWithJNDI.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test-cactus/org/apache/commons/configuration/TestConfigurationFactoryWithJNDI.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestConfigurationFactoryWithJNDI.java 16 Sep 2004 13:54:15 -0000 1.3
+++ TestConfigurationFactoryWithJNDI.java 3 Jan 2005 16:35:05 -0000 1.4
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.io.File;
import java.util.Iterator;
import java.util.List;
@@ -27,39 +27,35 @@
public class TestConfigurationFactoryWithJNDI extends ServletTestCase
{
- private File testDigesterFile = new File("conf/testDigesterConfigurationWJNDI.xml");
- private static Log log = LogFactory.getLog(TestConfigurationFactoryWithJNDI.class);
-
- public TestConfigurationFactoryWithJNDI(String testName) {
- super(testName);
- }
-
-
- public void testLoadingWithDigester() throws Exception {
-
- ConfigurationFactory cf = new ConfigurationFactory();
- cf.setConfigurationFileName(testDigesterFile.toString());
- CompositeConfiguration compositeConfiguration = (CompositeConfiguration)cf.getConfiguration();
-
- assertEquals("Verify how many configs", 4, compositeConfiguration.getNumberOfConfigurations());
-
- assertEquals(JNDIConfiguration.class, compositeConfiguration.getConfiguration(1).getClass());
- assertEquals(PropertiesConfiguration.class, compositeConfiguration.getConfiguration(2).getClass());
- //assertEquals(DOM4JConfiguration.class, compositeConfiguration.getConfiguration(3).getClass());
- PropertiesConfiguration pc = (PropertiesConfiguration) compositeConfiguration.getConfiguration(2);
-
- assertNotNull("Make sure we have a fileName:" + pc.getFileName(), pc.getFileName());
-
- assertTrue("Make sure we have loaded our key", compositeConfiguration.getBoolean("test.boolean"));
- assertEquals("I'm complex!", compositeConfiguration.getProperty("element2.subelement.subsubelement"));
-
- assertEquals("Make sure the JNDI config overwrites everything else!","80", compositeConfiguration.getString("test.overwrite"));
- }
-
- /**
- * Verify the getKeys() method works.
- * @throws Exception
- */
+ private File testDigesterFile = new File("conf/testDigesterConfigurationWJNDI.xml");
+ private static Log log = LogFactory.getLog(TestConfigurationFactoryWithJNDI.class);
+
+ public void testLoadingWithDigester() throws Exception
+ {
+ ConfigurationFactory cf = new ConfigurationFactory();
+ cf.setConfigurationFileName(testDigesterFile.toString());
+ CompositeConfiguration compositeConfiguration = (CompositeConfiguration) cf.getConfiguration();
+
+ assertEquals("Verify how many configs", 4, compositeConfiguration.getNumberOfConfigurations());
+
+ assertEquals(JNDIConfiguration.class, compositeConfiguration.getConfiguration(1).getClass());
+ assertEquals(PropertiesConfiguration.class, compositeConfiguration.getConfiguration(2).getClass());
+ //assertEquals(DOM4JConfiguration.class, compositeConfiguration.getConfiguration(3).getClass());
+ PropertiesConfiguration pc = (PropertiesConfiguration) compositeConfiguration.getConfiguration(2);
+
+ assertNotNull("Make sure we have a fileName:" + pc.getFileName(), pc.getFileName());
+
+ assertTrue("Make sure we have loaded our key", compositeConfiguration.getBoolean("test.boolean"));
+ assertEquals("I'm complex!", compositeConfiguration.getProperty("element2.subelement.subsubelement"));
+
+ assertEquals("Make sure the JNDI config overwrites everything else!", "80", compositeConfiguration.getString("test.overwrite"));
+ }
+
+ /**
+ * Verify the getKeys() method works.
+ *
+ * @throws Exception
+ */
public void testGetKeys() throws Exception
{
ConfigurationFactory cf = new ConfigurationFactory();
@@ -71,10 +67,11 @@
assertTrue(iteratedList.contains("test.jndi"));
}
- /**
- * Test that a simple key works with JNDI
- * @throws Exception
- */
+ /**
+ * Test that a simple key works with JNDI
+ *
+ * @throws Exception
+ */
public void testGetKeysWithString() throws Exception
{
String KEY = "test";
@@ -84,18 +81,20 @@
Configuration c = cf.getConfiguration();
List iteratedList = IteratorUtils.toList(c.getKeys(KEY));
-
- assertTrue("Size:" + iteratedList.size(),iteratedList.size()>0);
+
+ assertTrue("Size:" + iteratedList.size(), iteratedList.size() > 0);
assertTrue(iteratedList.contains("test.jndi"));
- for (Iterator i = iteratedList.iterator();i.hasNext();){
- String foundKey = (String)i.next();
- assertTrue(foundKey.startsWith(KEY));
+ for (Iterator i = iteratedList.iterator(); i.hasNext();)
+ {
+ String foundKey = (String) i.next();
+ assertTrue(foundKey.startsWith(KEY));
}
}
-
+
/**
* Verify that if a key is made of multiple parts, we still find
* the correct JNDI Context.
+ *
* @throws Exception
*/
public void testGetKeysWithString2() throws Exception
@@ -107,12 +106,13 @@
Configuration c = cf.getConfiguration();
List iteratedList = IteratorUtils.toList(c.getKeys(KEY));
-
- assertTrue("Size:" + iteratedList.size(),iteratedList.size()==2);
+
+ assertTrue("Size:" + iteratedList.size(), iteratedList.size() == 2);
assertTrue(iteratedList.contains("test.deep.somekey"));
- for (Iterator i = iteratedList.iterator();i.hasNext();){
- String foundKey = (String)i.next();
- assertTrue(foundKey.startsWith(KEY));
+ for (Iterator i = iteratedList.iterator(); i.hasNext();)
+ {
+ String foundKey = (String) i.next();
+ assertTrue(foundKey.startsWith(KEY));
}
}
1.3 +5 -18 jakarta-commons/configuration/src/test-cactus/org/apache/commons/configuration/TestJNDIAndCompositeConfiguration.java
Index: TestJNDIAndCompositeConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/test-cactus/org/apache/commons/configuration/TestJNDIAndCompositeConfiguration.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestJNDIAndCompositeConfiguration.java 27 Feb 2004 17:41:36 -0000 1.2
+++ TestJNDIAndCompositeConfiguration.java 3 Jan 2005 16:35:05 -0000 1.3
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@@ -16,21 +14,18 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import org.apache.cactus.ServletTestCase;
import java.io.File;
public class TestJNDIAndCompositeConfiguration extends ServletTestCase
{
- private String testProperties =
- new File("conf/test.properties").getAbsolutePath();
+ private String testProperties = new File("conf/test.properties").getAbsolutePath();
private CompositeConfiguration cc;
private PropertiesConfiguration conf1;
private JNDIConfiguration jndiConf;
- public TestJNDIAndCompositeConfiguration(String testName)
- {
- super(testName);
- }
public void setUp() throws Exception
{
@@ -42,7 +37,6 @@
cc.addConfiguration(jndiConf);
cc.addConfiguration(conf1);
-
}
public void testSimpleGet() throws Exception
@@ -54,7 +48,6 @@
cc.addConfiguration(conf1);
cc.addConfiguration(jndiConf);
assertEquals("1", cc.getString("test.overwrite"));
-
}
/**
@@ -64,9 +57,7 @@
{
cc.clearProperty("test.short");
- assertTrue(
- "Make sure test.short is gone!",
- !cc.containsKey("test.short"));
+ assertTrue("Make sure test.short is gone!", !cc.containsKey("test.short"));
}
/**
@@ -74,12 +65,8 @@
*/
public void testAddingProperty() throws Exception
{
-
cc.addProperty("test.short", "88");
- assertEquals(
- "Make sure test.short is overridden!",
- "88",
- cc.getString("test.short"));
+ assertEquals("Make sure test.short is overridden!", "88", cc.getString("test.short"));
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org