matrei commented on code in PR #15409:
URL: https://github.com/apache/grails-core/pull/15409#discussion_r2925363574
##########
grails-core/src/test/groovy/org/grails/plugins/BinaryPluginSpec.groovy:
##########
@@ -72,67 +71,57 @@ class BinaryPluginSpec extends Specification {
cssResource == null
}
- def "Test plugin with both plugin.yml and plugin.groovy throws
exception"() {
+ def "Test getPropertySource returns null when no mainContext is set on
GrailsApplication"() {
when:
- def descriptor = new BinaryGrailsPluginDescriptor(new
ByteArrayResource(testBinary.getBytes('UTF-8')),
['org.grails.plugins.TestBinaryResource'])
- MockConfigBinaryGrailsPlugin.YAML_EXISTS = true
- MockConfigBinaryGrailsPlugin.GROOVY_EXISTS = true
- new MockConfigBinaryGrailsPlugin(descriptor)
+ def descriptor = new GrailsPluginDescriptor(new
ByteArrayResource(testBinary.getBytes('UTF-8')),
['org.grails.plugins.TestBinaryResource'], [])
+ def binaryPlugin = new BinaryGrailsPlugin(TestBinaryGrailsPlugin,
descriptor, new DefaultGrailsApplication())
then:
- thrown(RuntimeException)
+ binaryPlugin.getPropertySource() == null
}
- def "Test plugin with only plugin.yml"() {
- when:
- def descriptor = new BinaryGrailsPluginDescriptor(new
ByteArrayResource(testBinary.getBytes('UTF-8')),
['org.grails.plugins.TestBinaryResource'])
- MockConfigBinaryGrailsPlugin.YAML_EXISTS = true
- MockConfigBinaryGrailsPlugin.GROOVY_EXISTS = false
- def binaryPlugin = new MockConfigBinaryGrailsPlugin(descriptor)
+ def "Test getPropertySource looks up plugin.yml from environment"() {
+ given:
+ def descriptor = new GrailsPluginDescriptor(new
ByteArrayResource(testBinary.getBytes('UTF-8')),
['org.grails.plugins.TestBinaryResource'], [])
+ def grailsApp = new DefaultGrailsApplication()
+ def binaryPlugin = new BinaryGrailsPlugin(TestBinaryGrailsPlugin,
descriptor, grailsApp)
- then:
- binaryPlugin.propertySource.getProperty('foo') == "bar"
- }
+ def appCtx = new GenericApplicationContext()
+ def ymlPropertySource = new MapPropertySource('testBinary-plugin.yml',
[foo: 'bar'])
+ appCtx.environment.propertySources.addLast(ymlPropertySource)
- def "Test plugin with only plugin.groovy"() {
when:
- def descriptor = new BinaryGrailsPluginDescriptor(new
ByteArrayResource(testBinary.getBytes('UTF-8')),
['org.grails.plugins.TestBinaryResource'])
- MockConfigBinaryGrailsPlugin.YAML_EXISTS = false
- MockConfigBinaryGrailsPlugin.GROOVY_EXISTS = true
- def binaryPlugin = new MockConfigBinaryGrailsPlugin(descriptor)
+ grailsApp.setMainContext(appCtx)
then:
- binaryPlugin.propertySource.getProperty('bar') == "foo"
+ binaryPlugin.getPropertySource() != null
+ binaryPlugin.getPropertySource().getProperty('foo') == 'bar'
Review Comment:
Groovy property getters?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]