Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2573

ConfigSlurper does not process property files with nested properties correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.4
    • 1.5.6, 1.6-beta-1
    • None
    • None
    • windows xp

    Description

      1. I created the following Groovy test:
        import java.io.IOException;
        
        public class PropertyParsingTest extends GroovyTestCase {
            public void test() throws IOException{
                ConfigSlurper configSlurper = new ConfigSlurper()
                Properties props = new Properties()
                props.load(PropertyParsingTest.class.getResourceAsStream("system.properties"))
                ConfigObject newConfig = configSlurper.parse(props)
                props = newConfig.toProperties()
        
                assertEquals("false", props.get("catalog.prov"))
                assertEquals("sa", props.get("catalog.prov.db.user"))
            }
        }
        
      2. I created system.properties file and put it to into classpath:
        catalog.prov = false
        catalog.prov.db.user = sa
        

      I got the following exception:

      There was 1 failure:
      1) test(PropertyParsingTest)junit.framework.ComparisonFailure: expected:<sa> but was:<null>
              at groovy.util.GroovyTestCase.assertEquals(GroovyTestCase.java:393)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
              at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)
              at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)
              at PropertyParsingTest.test(PropertyParsingTest.groovy:13)
      

      Attachments

        Activity

          People

            graemerocher Graeme Rocher
            andrew.osipenko Andrew Osipenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: