|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2013 the original author or authors. |
| 2 | + * Copyright 2002-2014 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.
|
|
27 | 27 | import java.util.Map;
|
28 | 28 |
|
29 | 29 | import org.apache.commons.logging.LogFactory;
|
| 30 | + |
30 | 31 | import org.junit.Test;
|
31 |
| -import org.xml.sax.InputSource; |
32 | 32 |
|
33 | 33 | import org.springframework.aop.framework.ProxyFactory;
|
34 | 34 | import org.springframework.aop.support.AopUtils;
|
|
61 | 61 | import org.springframework.tests.sample.beans.ResourceTestBean;
|
62 | 62 | import org.springframework.tests.sample.beans.TestBean;
|
63 | 63 | import org.springframework.tests.sample.beans.factory.DummyFactory;
|
| 64 | +import org.springframework.util.ClassUtils; |
64 | 65 | import org.springframework.util.FileCopyUtils;
|
65 | 66 | import org.springframework.util.SerializationTestUtils;
|
66 | 67 | import org.springframework.util.StopWatch;
|
67 | 68 |
|
| 69 | +import org.xml.sax.InputSource; |
| 70 | + |
68 | 71 | import static org.hamcrest.CoreMatchers.*;
|
69 | 72 | import static org.junit.Assert.*;
|
70 | 73 |
|
71 | 74 | /**
|
72 | 75 | * Miscellaneous tests for XML bean definitions.
|
73 |
| - * |
| 76 | + * |
74 | 77 | * @author Juergen Hoeller
|
75 | 78 | * @author Rod Johnson
|
76 | 79 | * @author Rick Evans
|
77 | 80 | * @author Chris Beams
|
| 81 | + * @author Sam Brannen |
78 | 82 | */
|
79 | 83 | public final class XmlBeanFactoryTests {
|
80 | 84 |
|
@@ -1283,6 +1287,31 @@ public void testRecursiveImport() {
|
1283 | 1287 | }
|
1284 | 1288 | }
|
1285 | 1289 |
|
| 1290 | + /** |
| 1291 | + * @since 3.2.8 and 4.0.2 |
| 1292 | + * @see <a href="https://jira.springsource.org/browse/SPR-10785">SPR-10785</a> and <a |
| 1293 | + * href="https://jira.springsource.org/browse/SPR-11420">SPR-11420</a> |
| 1294 | + */ |
| 1295 | + @Test |
| 1296 | + public void methodInjectedBeanMustBeOfSameEnhancedCglibSubclassTypeAcrossBeanFactories() { |
| 1297 | + Class<?> firstClass = null; |
| 1298 | + |
| 1299 | + for (int i = 1; i <= 10; i++) { |
| 1300 | + DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); |
| 1301 | + new XmlBeanDefinitionReader(bf).loadBeanDefinitions(OVERRIDES_CONTEXT); |
| 1302 | + |
| 1303 | + final Class<?> currentClass = bf.getBean("overrideOneMethod").getClass(); |
| 1304 | + assertTrue("Method injected bean class [" + currentClass + "] must be a CGLIB enhanced subclass.", |
| 1305 | + ClassUtils.isCglibProxyClass(currentClass)); |
| 1306 | + |
| 1307 | + if (firstClass == null) { |
| 1308 | + firstClass = currentClass; |
| 1309 | + } |
| 1310 | + else { |
| 1311 | + assertEquals(firstClass, currentClass); |
| 1312 | + } |
| 1313 | + } |
| 1314 | + } |
1286 | 1315 |
|
1287 | 1316 | @Test
|
1288 | 1317 | public void testLookupOverrideMethodsWithSetterInjection() {
|
@@ -1915,6 +1944,7 @@ public LenientDependencyTestBean(DerivedTestBean tb) {
|
1915 | 1944 | this.tb = tb;
|
1916 | 1945 | }
|
1917 | 1946 |
|
| 1947 | + @SuppressWarnings("rawtypes") |
1918 | 1948 | public LenientDependencyTestBean(Map[] m) {
|
1919 | 1949 | throw new IllegalStateException("Don't pick this constructor");
|
1920 | 1950 | }
|
|
0 commit comments