@@ -133,69 +133,61 @@ class GroovyBeanDefinitionReaderTests extends GroovyTestCase {
133
133
void testUseTwoSpringNamespaces () {
134
134
def beanReader = new GroovyBeanDefinitionReader ()
135
135
136
- SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder ()
137
- try {
138
-
139
- builder. bind(" bar" , " success" )
140
- builder. activate()
141
- TestScope scope = new TestScope ()
142
-
143
- GenericApplicationContext appCtx = beanReader. getSpringConfig(). getUnrefreshedApplicationContext()
144
- appCtx. getBeanFactory(). registerScope(" test" , scope)
145
- beanReader. beans {
146
- xmlns aop :" http://www.springframework.org/schema/aop"
147
- xmlns jee :" http://www.springframework.org/schema/jee"
148
- scopedList(ArrayList ) { bean ->
149
- bean. scope = " test"
150
- aop. ' scoped-proxy' ()
151
- }
152
-
153
- jee. ' jndi-lookup' (id :" foo" , ' jndi-name' :" bar" )
136
+ TestScope scope = new TestScope ()
154
137
138
+ GenericApplicationContext appCtx = beanReader. getSpringConfig(). getUnrefreshedApplicationContext()
139
+ appCtx. getBeanFactory(). registerScope(" test" , scope)
140
+ beanReader. beans {
141
+ xmlns aop :" http://www.springframework.org/schema/aop"
142
+ xmlns util :" http://www.springframework.org/schema/util"
143
+ scopedList(ArrayList ) { bean ->
144
+ bean. scope = " test"
145
+ aop. ' scoped-proxy' ()
155
146
}
147
+ util. list(id : ' foo' ) {
148
+ value ' one'
149
+ value ' two'
150
+ }
151
+ }
156
152
157
- appCtx = beanReader. createApplicationContext()
158
-
159
- assertEquals " success" , appCtx. getBean(" foo" )
160
-
161
- assertNotNull appCtx. getBean(" scopedList" )
162
- assertNotNull appCtx. getBean(" scopedList" ). size()
163
- assertNotNull appCtx. getBean(" scopedList" ). size()
153
+ appCtx = beanReader. createApplicationContext()
164
154
165
- // should only be true because bean not initialized until proxy called
166
- assertEquals 2 , scope. instanceCount
155
+ assert [' one' , ' two' ] == appCtx. getBean(" foo" )
167
156
168
- beanReader = new GroovyBeanDefinitionReader ()
157
+ assertNotNull appCtx. getBean(" scopedList" )
158
+ assertNotNull appCtx. getBean(" scopedList" ). size()
159
+ assertNotNull appCtx. getBean(" scopedList" ). size()
169
160
170
- appCtx = beanReader. getSpringConfig(). getUnrefreshedApplicationContext()
171
- appCtx. getBeanFactory(). registerScope(" test" , scope)
172
- beanReader. beans {
173
- xmlns aop :" http://www.springframework.org/schema/aop" ,
174
- jee :" http://www.springframework.org/schema/jee"
175
- scopedList(ArrayList ) { bean ->
176
- bean. scope = " test"
177
- aop. ' scoped-proxy' ()
178
- }
161
+ // should only be true because bean not initialized until proxy called
162
+ assertEquals 2 , scope. instanceCount
179
163
180
- jee . ' jndi-lookup ' ( id : " foo " , ' jndi-name ' : " bar " )
164
+ beanReader = new GroovyBeanDefinitionReader ( )
181
165
166
+ appCtx = beanReader. getSpringConfig(). getUnrefreshedApplicationContext()
167
+ appCtx. getBeanFactory(). registerScope(" test" , scope)
168
+ beanReader. beans {
169
+ xmlns aop :" http://www.springframework.org/schema/aop" ,
170
+ util :" http://www.springframework.org/schema/util"
171
+ scopedList(ArrayList ) { bean ->
172
+ bean. scope = " test"
173
+ aop. ' scoped-proxy' ()
182
174
}
183
- appCtx = beanReader. createApplicationContext()
184
-
185
- assertEquals " success" , appCtx. getBean(" foo" )
186
-
187
- assertNotNull appCtx. getBean(" scopedList" )
188
- assertNotNull appCtx. getBean(" scopedList" ). size()
189
- assertNotNull appCtx. getBean(" scopedList" ). size()
190
175
191
- // should only be true because bean not initialized until proxy called
192
- assertEquals 4 , scope. instanceCount
176
+ util. list(id : ' foo' ) {
177
+ value ' one'
178
+ value ' two'
179
+ }
180
+ }
181
+ appCtx = beanReader. createApplicationContext()
182
+
183
+ assert [' one' , ' two' ] == appCtx. getBean(" foo" )
193
184
185
+ assertNotNull appCtx. getBean(" scopedList" )
186
+ assertNotNull appCtx. getBean(" scopedList" ). size()
187
+ assertNotNull appCtx. getBean(" scopedList" ). size()
194
188
195
- }
196
- finally {
197
- builder. deactivate()
198
- }
189
+ // should only be true because bean not initialized until proxy called
190
+ assertEquals 4 , scope. instanceCount
199
191
}
200
192
201
193
void testSpringAOPSupport () {
@@ -262,24 +254,17 @@ class GroovyBeanDefinitionReaderTests extends GroovyTestCase {
262
254
void testSpringNamespaceBean () {
263
255
def beanReader = new GroovyBeanDefinitionReader ()
264
256
265
- SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder ()
266
- try {
267
-
268
- builder. bind(" bar" , " success" )
269
- builder. activate()
270
-
271
- beanReader. beans {
272
- xmlns jee :" http://www.springframework.org/schema/jee"
273
- jee. ' jndi-lookup' (id :" foo" , ' jndi-name' :" bar" )
257
+ beanReader. beans {
258
+ xmlns util : ' http://www.springframework.org/schema/util'
259
+ util. list(id : ' foo' ) {
260
+ value ' one'
261
+ value ' two'
274
262
}
275
-
276
- ApplicationContext appCtx = beanReader. createApplicationContext()
277
-
278
- assertEquals " success" , appCtx. getBean(" foo" )
279
- }
280
- finally {
281
- builder. deactivate()
282
263
}
264
+
265
+ def ctx = beanReader. createApplicationContext()
266
+
267
+ assert [' one' , ' two' ] == ctx. getBean(' foo' )
283
268
}
284
269
285
270
void testNamedArgumentConstructor () {
0 commit comments