GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / reload / SpringProxiedBeanReloadTests.groovy
blobf0ac06022bc3fe04e262f4e1df5df19206b398b7
1 /**
2 * @author Graeme Rocher
3 * @since 1.0
4 *
5 * Created: Nov 22, 2007
6 */
7 package org.codehaus.groovy.grails.reload
9 import grails.spring.BeanBuilder
10 import org.springframework.aop.framework.ProxyFactoryBean
11 import org.aopalliance.intercept.MethodInterceptor
12 import org.aopalliance.intercept.MethodInvocation
14 class SpringProxiedBeanReloadTests extends GroovyTestCase {
16 void testReloadCGLibProxiedBean() {
17 def gcl = new GroovyClassLoader()
18 def cls = gcl.parseClass("class Book { String title = 'The Stand'; String author }")
20 def bb = new BeanBuilder(gcl)
21 bb.beans {
22 interceptor(DummyInterceptor)
23 target(cls) {
24 author = "Stephen King"
26 myBean(ProxyFactoryBean) {
27 targetName = 'target'
28 autodetectInterfaces = false
29 interceptorNames = 'interceptor'
33 def appCtx = bb.createApplicationContext()
35 println "Bean = " + appCtx.getBean("myBean")
36 println "Class = " + appCtx.getBean('myBean').getClass()
37 assertEquals "The Stand", appCtx.getBean('myBean').title
38 assertEquals "Stephen King", appCtx.getBean('myBean').author
41 gcl = new GroovyClassLoader()
42 cls = gcl.parseClass("class Book { String title = 'The Shining'; String author }")
44 bb = new BeanBuilder(gcl)
45 def beanDefinitions = bb.beans {
46 interceptor(DummyInterceptor)
47 target(cls) {
48 author = "Stephen King"
50 myBean(ProxyFactoryBean) {
51 targetName = 'target'
52 autodetectInterfaces = false
53 interceptorNames = 'interceptor'
57 bb.registerBeans(appCtx)
59 assertEquals "The Shining", appCtx.getBean('myBean').title
60 assertEquals "Stephen King", appCtx.getBean('myBean').author
64 class DummyInterceptor implements MethodInterceptor {
65 public Object invoke(MethodInvocation methodInvocation) {
66 return methodInvocation.proceed();