Applying a unit test and a fix for COLLECTIONS-238 - allowing ExtendedProperties to support empty property values
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@641153 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb41a3c01c
commit
0d948ddefd
|
@ -593,10 +593,12 @@ public class ExtendedProperties extends Hashtable {
|
|||
String key = line.substring(0, equalSign).trim();
|
||||
String value = line.substring(equalSign + 1).trim();
|
||||
|
||||
/* COLLECTIONS-238 allows empty properties to exist by commenting this out
|
||||
// Configure produces lines like this ... just ignore them
|
||||
if ("".equals(value)) {
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
if (includeProperty != null && key.equalsIgnoreCase(includeProperty)) {
|
||||
// Recursively load properties files.
|
||||
|
|
|
@ -407,4 +407,16 @@ public class TestExtendedProperties extends TestCase {
|
|||
assertEquals( "\\\\192.168.1.91\\test", props2.getProperty("test") );
|
||||
}
|
||||
|
||||
public void testCollections238() throws IOException {
|
||||
ExtendedProperties props = new ExtendedProperties();
|
||||
String txt = "x=1\ny=\nz=3";
|
||||
byte[] bytes = txt.getBytes();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
|
||||
props.load(in);
|
||||
assertEquals("1", props.getProperty("x"));
|
||||
assertEquals("3", props.getProperty("z"));
|
||||
assertEquals("", props.getProperty("y"));
|
||||
assertEquals(3, props.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue