|
41 | 41 | import org.junit.Rule;
|
42 | 42 | import org.junit.Test;
|
43 | 43 | import org.junit.rules.ExpectedException;
|
| 44 | +import org.mockito.Matchers; |
44 | 45 |
|
45 | 46 | import org.springframework.beans.BeansException;
|
46 | 47 | import org.springframework.beans.MutablePropertyValues;
|
|
52 | 53 | import org.springframework.beans.TypeMismatchException;
|
53 | 54 | import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
54 | 55 | import org.springframework.beans.factory.config.BeanDefinition;
|
| 56 | +import org.springframework.beans.factory.config.BeanExpressionContext; |
| 57 | +import org.springframework.beans.factory.config.BeanExpressionResolver; |
55 | 58 | import org.springframework.beans.factory.config.BeanPostProcessor;
|
56 | 59 | import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
57 | 60 | import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
58 | 61 | import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
|
| 62 | +import org.springframework.beans.factory.config.PropertiesFactoryBean; |
59 | 63 | import org.springframework.beans.factory.config.RuntimeBeanReference;
|
60 | 64 | import org.springframework.beans.factory.config.TypedStringValue;
|
61 | 65 | import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
@@ -1165,6 +1169,23 @@ public void testDoubleArrayConstructorWithOptionalAutowiring() throws MalformedU
|
1165 | 1169 | assertNull(ab.getResourceArray());
|
1166 | 1170 | }
|
1167 | 1171 |
|
| 1172 | + @Test |
| 1173 | + public void testExpressionInStringArray() { |
| 1174 | + DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); |
| 1175 | + BeanExpressionResolver beanExpressionResolver = mock(BeanExpressionResolver.class); |
| 1176 | + when(beanExpressionResolver.evaluate(eq("#{foo}"), Matchers.any(BeanExpressionContext.class))) |
| 1177 | + .thenReturn("classpath:/org/springframework/beans/factory/xml/util.properties"); |
| 1178 | + bf.setBeanExpressionResolver(beanExpressionResolver); |
| 1179 | + |
| 1180 | + RootBeanDefinition rbd = new RootBeanDefinition(PropertiesFactoryBean.class); |
| 1181 | + MutablePropertyValues pvs = new MutablePropertyValues(); |
| 1182 | + pvs.add("locations", new String[]{"#{foo}"}); |
| 1183 | + rbd.setPropertyValues(pvs); |
| 1184 | + bf.registerBeanDefinition("myProperties", rbd); |
| 1185 | + Properties properties = (Properties) bf.getBean("myProperties"); |
| 1186 | + assertEquals("bar", properties.getProperty("foo")); |
| 1187 | + } |
| 1188 | + |
1168 | 1189 | @Test
|
1169 | 1190 | public void testAutowireWithNoDependencies() {
|
1170 | 1191 | DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
|
|
0 commit comments