commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maria Jimena Sanchez <jimesanc...@gmail.com>
Subject Re: test.value=foo
Date Tue, 14 Feb 2012 17:37:20 GMT
I tested its and it works.

Here is my test:
the test class
public class Testasfd {
    @Test
    public void test() throws ConfigurationException {
        Map<String, String> expectedValues = new HashMap<String, String>();
        expectedValues.put("user.name", "jime");
        expectedValues.put("user.code", "1234");
        DefaultConfigurationBuilder defaultConfigurationBuilder = new
DefaultConfigurationBuilder("/home/jsanchez/wc/tendril.git/paper-reports/workflows/src/test/java/com/tendril/pr/workflows/example.xml");
        CombinedConfiguration cc = (CombinedConfiguration)
defaultConfigurationBuilder.getConfiguration(true);
        Iterator keys = cc.getKeys();
        for (Iterator iterator = cc.getKeys(); iterator.hasNext();) {
            Object key = iterator.next();
            System.out.println(key + "=" + cc.getString((String) key));
            assertTrue(expectedValues.containsKey(key));
            assertEquals(expectedValues.get(key), cc.getString((String)
key));
        }
    }
}

with this xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<configuration>
  <properties fileName="props.properties"/>
</configuration>

and this properties
user.name=jime
user.code=1234

here is the output
user.name=jime
user.code=1234

Jime

On Tue, Feb 14, 2012 at 1:42 PM, Young Gun <scott_cornwell@hotmail.com>wrote:

>
> Ok this is bugging the heck out of me, I have the following (if there is a
> typo it is because I have to type this by hand from one screen to next,
> don't ask) What am I doing wrong??:
>
> example.xml loads user.properties
>
> user.proerties has an entry:
> dog.type = lab
> ....
>
> dcb=new DefaultConfigurationBuilder("example.xml);
> cc = (CombinedConfiguration) dcb.getConfiguration(true);
>
> .....
>
> if I get the keys .. cc.getKeys() the key prints out as: dog/type
>
> if I get the value cc.getString() it returns: null
>
> IF I PUT the value as dog..type = lab (two periods) in user.properties
> then then it prints dog.type as the key and lab as the value.
>
> I refactor code where some of the property files have xxx.xxx = value and
> I see example of this in the documentation. I can change all of them to
> double periods.
>
> Any help is greatly appreciated!!
>
>
> Scott
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message