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

camel-spring-boot - EndpointInject happens before CamelContextConfiguration#beforeApplicationStart

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • None
    • 3.x
    • camel-spring-boot, tests
    • None
    • Unknown

    Description

      Currently something like this fails in camel-spring-boot tests:

      @EndpointInject("mock:result")
      MockEndpoint mock;
      
      @Test
      public void testComponentConfigured() {
          // this fails
          assertTrue(mock.isLog());
      }
      
      @Bean
      CamelContextConfiguration contextConfiguration() {
          return new CamelContextConfiguration() {
              @Override
              public void beforeApplicationStart(CamelContext context) {
                  MockComponent mock = new MockComponent(context);
                  mock.setLog(true);
                  context.addComponent("mock", mock);
              }
      
              @Override
              public void afterApplicationStart(CamelContext camelContext) {
                  //do nothing here
              }
          };
      }
      

      This is because the wiring for @EndpointInject happens before CamelContextConfiguration#beforeApplicationStart. Workaround is to configure the component via @Bean

      Attachments

        Activity

          People

            Unassigned Unassigned
            jpoth John Poth
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: