|
16 | 16 |
|
17 | 17 | package org.springframework.context.annotation.configuration;
|
18 | 18 |
|
| 19 | +import java.util.Collections; |
| 20 | + |
19 | 21 | import org.aspectj.lang.annotation.Aspect;
|
20 | 22 | import org.aspectj.lang.annotation.Before;
|
| 23 | + |
21 | 24 | import static org.hamcrest.CoreMatchers.*;
|
22 | 25 | import static org.junit.Assert.*;
|
| 26 | + |
23 | 27 | import org.junit.Ignore;
|
24 | 28 | import org.junit.Test;
|
25 | 29 | import org.springframework.tests.sample.beans.TestBean;
|
26 |
| - |
27 | 30 | import org.springframework.aop.support.AopUtils;
|
28 | 31 | import org.springframework.beans.factory.annotation.Autowired;
|
29 | 32 | import org.springframework.beans.factory.annotation.Value;
|
|
34 | 37 | import org.springframework.context.annotation.Bean;
|
35 | 38 | import org.springframework.context.annotation.Configuration;
|
36 | 39 | import org.springframework.context.annotation.ImportResource;
|
| 40 | +import org.springframework.core.env.MapPropertySource; |
| 41 | +import org.springframework.core.env.PropertySource; |
37 | 42 |
|
38 | 43 | /**
|
39 | 44 | * Integration tests for {@link ImportResource} support.
|
@@ -178,4 +183,22 @@ public void testImportDifferentResourceTypes() {
|
178 | 183 | reader=XmlBeanDefinitionReader.class)
|
179 | 184 | static class SubResourceConfig extends ImportNonXmlResourceConfig {
|
180 | 185 | }
|
| 186 | + |
| 187 | + @Test |
| 188 | + public void importWithPlaceHolder() throws Exception { |
| 189 | + AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
| 190 | + PropertySource<?> propertySource = new MapPropertySource("test", |
| 191 | + Collections.<String, Object> singletonMap("test", "springframework")); |
| 192 | + ctx.getEnvironment().getPropertySources().addFirst(propertySource); |
| 193 | + ctx.register(ImportXmlConfig.class); |
| 194 | + ctx.refresh(); |
| 195 | + assertTrue("did not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean")); |
| 196 | + } |
| 197 | + |
| 198 | + @Configuration |
| 199 | + @ImportResource("classpath:org/${test}/context/annotation/configuration/ImportXmlConfig-context.xml") |
| 200 | + static class ImportWithPlaceHolder { |
| 201 | + } |
| 202 | + |
| 203 | + |
181 | 204 | }
|
0 commit comments