GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / reload / TagLibReloadTests.groovy
blobd12576ac2dd0fc5557ad2da03de979415966129e
1 package org.codehaus.groovy.grails.reload;
3 import org.codehaus.groovy.grails.web.servlet.mvc.*
4 import org.codehaus.groovy.grails.commons.*
5 import org.apache.commons.logging.*
6 import org.codehaus.groovy.grails.web.taglib.*
8 /**
9 * Tests for auto-reloading of tag libraries
11 * @author Graeme Rocher
12 **/
14 class TagLibReloadTests extends AbstractGrailsTagTests {
17 void testReloadTagLibrary() {
18 def sw = new StringWriter()
19 def pw = new PrintWriter(sw)
20 Class oldClass = ga.getTagLibClass("TestTagLib").getClazz()
21 def result
22 println "trying myTag"
23 withTag("myTag",pw) { tag ->
24 tag.call([foo:"bar"],null)
26 assertEquals "foo:bar", sw.toString()
29 def event = [source:new GroovyClassLoader().parseClass('''
30 class TestTagLib {
31 def myTag = { attrs, body ->
32 out << "bar:${attrs.bar}"
35 '''),
36 ctx:appCtx, manager:mockManager]
38 def plugin = mockManager.getGrailsPlugin("controllers")
40 def eventHandler = plugin.instance.onChange
41 eventHandler.delegate = plugin
42 eventHandler.call(event)
44 withTag("myTag",pw) { tag ->
45 tag.call([bar:"foo"], null)
47 assertEquals "foo:barbar:foo", sw.toString()
50 void onInit() {
51 def tagLibClass = gcl.parseClass(
52 '''
53 class TestTagLib {
54 def myTag = { attrs, body ->
55 println "attributes $attrs"
56 out << "foo:${attrs.foo}"
59 '''
62 ga.addArtefact(tagLibClass)