Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6304 Configslurper Issues
  3. GROOVY-4493

ConfigSlurper().parse() - property not located correctly in returned tree.

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.5, 1.8-beta-2
    • None
    • groovy-jdk
    • None
    • windows 7; java version "1.6.0_21; gdk I.7.5 but also occurs for gdk 1.8.0 beta 2.

    Description

      package tasktrack;
      
      import groovy.util.GroovyTestCase;
      class ConfigSurlperTest extends GroovyTestCase {
      
      	public void testParseScript() {
      		def configFile = '''
      		log4j {
      			rootLogger="debug,stdout"
      			appender {		
      				stdout("org.apache.log4j.ConsoleAppender") { // See Note 2
      					layout("org.apache.log4j.PatternLayout") {		  
      						ConversionPattern="%5p [%t] (%F:%L) - %m%n"
      					}
      				}
      			}		
      		}
      		'''
      		
      		def cfg = new ConfigSlurper().parse(configFile)
      		assertEquals "debug,stdout", cfg.log4j.rootLogger  //Pass
      		assertEquals "org.apache.log4j.ConsoleAppender", cfg.log4j.appender.stdout //Pass
      		assertEquals "org.apache.log4j.PatternLayout", cfg.log4j.appender.stdout.layout // Fails - See Note 1
      	}
      }
      

      Note 1
      ======

      Result in the following exception

      groovy.lang.MissingPropertyException: No such property: layout for class: java.lang.String
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
      at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63)
      ...

      Note 2
      ======

      The third assert works when the value, org.apache.log4j.ConsoleAppender, is not declared.
      That is:

      ...
      appender {
      stdout {
      layout("org.apache.log4j.PatternLayout")

      { ConversionPattern="%5p [%t] (%F:%L) - %m%n" }

      }
      }
      ...

      Attachments

        1. ConfigSlurper Issue.txt
          1 kB
          Tom Weekes

        Activity

          People

            Unassigned Unassigned
            tweekes Tom Weekes
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: