Details
-
Type:
Improvement
-
Status: Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.18.1
-
Fix Version/s: 2.20.0
-
Component/s: camel-test
-
Labels:
-
Environment:
Spring 4.1 onwards
-
Estimated Complexity:Novice
Description
Vanilla Spring test passes:
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes= PropTest.class) @Configuration @TestPropertySource(properties = "key=value") public class PropTest { @Value("${key}") private String key; @Test public void test() { assertThat(key, is("value")); } }
Camel test fails (first two lines only changed):
@RunWith(CamelSpringRunner.class) @BootstrapWith(CamelTestContextBootstrapper.class) @ContextConfiguration(classes= PropTest.class) @Configuration @TestPropertySource(properties = "key=value") public class PropTest { @Value("${key}") private String key; @Test public void test() { assertThat(key, is("value")); } }
This would appear to be related to the comment in @TestPropertySource
@TestPropertySource is enabled if the configured context loader honors it. Every SmartContextLoader that is a subclass of either AbstractGenericContextLoader or AbstractGenericWebContextLoader provides automatic support for @TestPropertySource
CamelSpringTestContextLoader does not extend AbstractGenericContextLoader but its parent AbstractContextLoader so ignores the annotation.
Attachments
Issue Links
- links to