如何使用ConfigSlurper读取“xxxResources.groovy”文件

时间:2015-01-13 06:34:32

标签: grails

我正在尝试使用配置slurper阅读以下“Resources”文件“ApplicationResources.groovy”但没有成功:

package resources

// resource bundles
modules = {

    google {
        resource  url: 'http://maps.google.com/maps/api/js?sensor=false', attrs: [type: "js"], disposition: 'head'
    }

}

这是我的测试代码:

package modules.manager.grails.plugin

import org.springframework.core.io.ClassPathResource
import org.springframework.core.io.Resource
import spock.lang.Specification

class RefreshModulesSpec extends Specification {

    void "test modifying existing resources file"() {
        given:
        Resource resource = new ClassPathResource("resources/ApplicationResources.groovy")
        Script script = new GroovyShell().parse(resource.file)
        ConfigObject configObject = new ConfigSlurper().parse(script)

        expect:
        configObject.modules.google.resources.url == "http://maps.google.com/maps/api/js?sensor=false"
    }
}

谢谢!

0 个答案:

没有答案