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:14:01 UTC

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

Marc Carter created CAMEL-11543:
-----------------------------------

             Summary: 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


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)