Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-11543

Camel doesn't support @TestPropertySource

    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

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                drekbour Marc Carter
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: