You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Young Gun <sc...@hotmail.com> on 2012/02/14 17:42:16 UTC

test.value=foo

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
 		 	   		  

RE: test.value=foo

Posted by Young Gun <sc...@hotmail.com>.
Figured it out, I originally took an example from the user.guide, where the examples.xml had the following lines:  But thanks to your code I started to think it must be my environment and once I removed the following lines it worked as expected. I will have to read up some more to figure out why this was causing a problem.
<result delimiterParsingDisabled="true" forceReloadCheck="true">
  <expressionEngine config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
</result>
Thanks!

From: scott_cornwell@hotmail.com
To: user@commons.apache.org
Subject: RE: test.value=foo
Date: Tue, 14 Feb 2012 13:41:14 -0500







Jime,
Thanks for the quick response but no workie....
I took code as is, an add values to the user.prooperties file but it still does not work but with double periods:


user.name=jime
user.code=1234

Output was---
user/name=jime
user/code=1234
-----------------

If I added double periods (..) then it works..
user..name=jime

user..code=1234

Output was ---
user.name=jime
user.code=1234
----------------- 

I am using Java 7 u1 . I tried commons version 1.7 and 1.8 but I have NOT tried with Java 6 yet..

IS THIS A BUG W/ JAVA 7 ???


Scott

> Date: Tue, 14 Feb 2012 14:37:20 -0300
> Subject: Re: test.value=foo
> From: jimesanchez@gmail.com
> To: user@commons.apache.org
> 
> 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 <sc...@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
> >
 		 	   		   		 	   		  

Re: test.value=foo

Posted by Maria Jimena Sanchez <ji...@gmail.com>.
that could be.
I'm running linux with java 1.6.
I didn't download java 7 yet, let me try that.

On Tue, Feb 14, 2012 at 3:41 PM, Young Gun <sc...@hotmail.com>wrote:

>
> Jime,
> Thanks for the quick response but no workie....
> I took code as is, an add values to the user.prooperties file but it still
> does not work but with double periods:
>
>
> user.name=jime
> user.code=1234
>
> Output was---
> user/name=jime
> user/code=1234
> -----------------
>
> If I added double periods (..) then it works..
> user..name=jime
>
> user..code=1234
>
> Output was ---
> user.name=jime
> user.code=1234
> -----------------
>
> I am using Java 7 u1 . I tried commons version 1.7 and 1.8 but I have NOT
> tried with Java 6 yet..
>
> IS THIS A BUG W/ JAVA 7 ???
>
>
> Scott
>
> > Date: Tue, 14 Feb 2012 14:37:20 -0300
> > Subject: Re: test.value=foo
> > From: jimesanchez@gmail.com
> > To: user@commons.apache.org
> >
> > 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
> > >
>
>

RE: test.value=foo

Posted by Young Gun <sc...@hotmail.com>.
Jime,
Thanks for the quick response but no workie....
I took code as is, an add values to the user.prooperties file but it still does not work but with double periods:


user.name=jime
user.code=1234

Output was---
user/name=jime
user/code=1234
-----------------

If I added double periods (..) then it works..
user..name=jime

user..code=1234

Output was ---
user.name=jime
user.code=1234
----------------- 

I am using Java 7 u1 . I tried commons version 1.7 and 1.8 but I have NOT tried with Java 6 yet..

IS THIS A BUG W/ JAVA 7 ???


Scott

> Date: Tue, 14 Feb 2012 14:37:20 -0300
> Subject: Re: test.value=foo
> From: jimesanchez@gmail.com
> To: user@commons.apache.org
> 
> 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 <sc...@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
> >
 		 	   		  

Re: test.value=foo

Posted by Maria Jimena Sanchez <ji...@gmail.com>.
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 <sc...@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
>