Fix ExtendedProperties.convertProperties to pickup any default parent configuration
bug 32204, from Shinobu Kawai git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@171380 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
29d3d6ec87
commit
4a6212148d
|
@ -73,6 +73,7 @@ If this causes major headaches to anyone please contact commons-dev at jakarta.a
|
|||
<li>BoundedFifoBuffer/CircularFifoBuffer - Fix serialization to work in case where buffer serialized when full [31433]</li>
|
||||
<li>BoundedFifoBuffer - Fix iterator remove bug causing ArrayIndexOutOfBounds error [33071]</li>
|
||||
<li>IteratorChain.remove() - Fix to avoid IllegalStateException when one of the underlying iterators is a FilterIterator [34267]</li>
|
||||
<li>ExtendedProperties.convertProperties() - Fix to handle default properties maps correctly [32204]</li>
|
||||
</ul>
|
||||
|
||||
<center><h3>JAVADOC</h3></center>
|
||||
|
|
|
@ -206,6 +206,9 @@
|
|||
<contributor>
|
||||
<name>Nissim Karpenstein</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Shinobu Kawai</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Mohan Kishore</name>
|
||||
</contributor>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation
|
||||
* Copyright 2001-2005 The Apache Software Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -137,6 +137,7 @@ import java.util.Vector;
|
|||
* @author Janek Bogucki
|
||||
* @author Mohan Kishore
|
||||
* @author Stephen Colebourne
|
||||
* @author Shinobu Kawai
|
||||
*/
|
||||
public class ExtendedProperties extends Hashtable {
|
||||
|
||||
|
@ -1610,6 +1611,9 @@ public class ExtendedProperties extends Hashtable {
|
|||
|
||||
/**
|
||||
* Convert a standard properties class into a configuration class.
|
||||
* <p>
|
||||
* NOTE: From Commons Collections 3.2 this method will pick up
|
||||
* any default parent Properties of the specified input object.
|
||||
*
|
||||
* @param props the properties object to convert
|
||||
* @return new ExtendedProperties created from props
|
||||
|
@ -1617,12 +1621,12 @@ public class ExtendedProperties extends Hashtable {
|
|||
public static ExtendedProperties convertProperties(Properties props) {
|
||||
ExtendedProperties c = new ExtendedProperties();
|
||||
|
||||
for (Enumeration e = props.keys(); e.hasMoreElements();) {
|
||||
for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
|
||||
String s = (String) e.nextElement();
|
||||
c.setProperty(s, props.getProperty(s));
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation
|
||||
* Copyright 2001-2005 The Apache Software Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,6 +18,7 @@ package org.apache.commons.collections;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
@ -31,6 +32,7 @@ import junit.framework.TestSuite;
|
|||
* @author Geir Magnusson Jr.
|
||||
* @author Mohan Kishore
|
||||
* @author Stephen Colebourne
|
||||
* @author Shinobu Kawai
|
||||
*/
|
||||
public class TestExtendedProperties extends TestCase {
|
||||
|
||||
|
@ -251,5 +253,18 @@ public class TestExtendedProperties extends TestCase {
|
|||
assertEquals("c", ep1.getVector("one").get(2));
|
||||
assertEquals("d", ep1.getVector("one").get(3));
|
||||
}
|
||||
|
||||
|
||||
public void testInheritDefaultProperties() {
|
||||
Properties defaults = new Properties();
|
||||
defaults.setProperty("resource.loader", "class");
|
||||
|
||||
Properties properties = new Properties(defaults);
|
||||
properties.setProperty("test", "foo");
|
||||
|
||||
ExtendedProperties extended = ExtendedProperties.convertProperties(properties);
|
||||
|
||||
assertEquals("foo", extended.getString("test"));
|
||||
assertEquals("class", extended.getString("resource.loader"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue