|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -201,6 +201,27 @@ public void twoLevelsWithNoBeanMethods() {
|
201 | 201 | assertNotEquals(l2i1.toString(), l2i2.toString());
|
202 | 202 | }
|
203 | 203 |
|
| 204 | + @Test |
| 205 | + public void twoLevelsOnNonAnnotatedBaseClass() { |
| 206 | + AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
| 207 | + ctx.register(L0ConfigConcrete.class); |
| 208 | + ctx.refresh(); |
| 209 | + |
| 210 | + assertFalse(ctx.getBeanFactory().containsSingleton("l0ConfigConcrete")); |
| 211 | + Object l0i1 = ctx.getBean(L0ConfigConcrete.class); |
| 212 | + Object l0i2 = ctx.getBean(L0ConfigConcrete.class); |
| 213 | + assertTrue(l0i1 == l0i2); |
| 214 | + |
| 215 | + Object l1i1 = ctx.getBean(L0ConfigConcrete.L1ConfigEmpty.class); |
| 216 | + Object l1i2 = ctx.getBean(L0ConfigConcrete.L1ConfigEmpty.class); |
| 217 | + assertTrue(l1i1 != l1i2); |
| 218 | + |
| 219 | + Object l2i1 = ctx.getBean(L0ConfigConcrete.L1ConfigEmpty.L2ConfigEmpty.class); |
| 220 | + Object l2i2 = ctx.getBean(L0ConfigConcrete.L1ConfigEmpty.L2ConfigEmpty.class); |
| 221 | + assertTrue(l2i1 == l2i2); |
| 222 | + assertNotEquals(l2i1.toString(), l2i2.toString()); |
| 223 | + } |
| 224 | + |
204 | 225 |
|
205 | 226 | @Configuration
|
206 | 227 | @Lazy
|
@@ -365,4 +386,24 @@ protected static class L2ConfigEmpty {
|
365 | 386 | }
|
366 | 387 | }
|
367 | 388 |
|
| 389 | + |
| 390 | + static class L0ConfigBase { |
| 391 | + |
| 392 | + @Component |
| 393 | + @Scope("prototype") |
| 394 | + static class L1ConfigEmpty { |
| 395 | + |
| 396 | + @Component |
| 397 | + @Scope(value = "prototype", proxyMode = ScopedProxyMode.TARGET_CLASS) |
| 398 | + protected static class L2ConfigEmpty { |
| 399 | + } |
| 400 | + } |
| 401 | + } |
| 402 | + |
| 403 | + |
| 404 | + @Component |
| 405 | + @Lazy |
| 406 | + static class L0ConfigConcrete extends L0ConfigBase { |
| 407 | + } |
| 408 | + |
368 | 409 | }
|
0 commit comments