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
.*
9 * Tests for auto-reloading of tag libraries
11 * @author Graeme Rocher
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()
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('''
31 def myTag = { attrs, body ->
32 out << "bar:${attrs.bar}"
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()
51 def tagLibClass
= gcl
.parseClass(
54 def myTag = { attrs, body ->
55 println "attributes $attrs"
56 out << "foo:${attrs.foo}"
62 ga
.addArtefact(tagLibClass
)