You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Marc Carter (JIRA)" <ji...@apache.org> on 2017/07/14 12:21:00 UTC

[jira] [Commented] (CAMEL-11543) Camel doesn't support @TestPropertySource

    [ https://issues.apache.org/jira/browse/CAMEL-11543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16087246#comment-16087246 ] 

Marc Carter commented on CAMEL-11543:
-------------------------------------

FYI for anyone else. If the properties you need to override are *only* used within Camel then {{@UseOverridePropertiesWithPropertiesComponent}} should let you do the same as the above.
{noformat}from("{{input.uri}}").to("{{output.uri}}";{noformat}

> Camel doesn't support @TestPropertySource
> -----------------------------------------
>
>                 Key: CAMEL-11543
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11543
>             Project: Camel
>          Issue Type: Bug
>          Components: tests
>    Affects Versions: 2.18.1
>         Environment: Spring 4.1 onwards
>            Reporter: Marc Carter
>              Labels: spring
>
> Vanilla Spring test passes:
> {code:java}
> @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"));
>     }
> }
> {code}
> Camel test fails (first two lines only changed):
> {code:java}
> @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"));
>     }
> }
> {code}
> This would appear to be related to the comment in [@TestPropertySource|https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/test/context/TestPropertySource.html]
> bq. @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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)