0

I have a yet very simple Spring Boot (2.5.1)/ Apache Camel (3.10.0) Application and i am struggling creating a simple test. In my case it even fails to inject endpoints:

So my first simple try is to get this green:

@CamelSpringBootTest
class UnmarshalXmlTest {

    @EndpointInject("mock:out")
    MockEndpoint outEndpoint;
    
    @Produce("direct:in")
    ProducerTemplate template;
    
    @Test
    void test() {
        assertNotNull(outEndpoint);
        assertNotNull(template);
    }

}

But it is red. Sadly the documentation is outdated (uses deprecated SingleRouteCamelConfiguration) and it is also not showing how to test a given route. The other doc is also not helping (using @CamelSpringTest instead is not helping).

It seems that spring annotations are working - adding stuff via @Autowired works!

This answer suggests that it should just work?! So how to get the camel annotations picked up and working?

dermoritz
  • 12,519
  • 25
  • 97
  • 185
  • In my case adding `@SpringBootTest` annotation along with `@CamelSpringBootTest` did the trick for camel 3.4 – Greenev Jul 09 '21 at 13:03
  • this did it indeed - too bad that documentation is missing this detail. On the other hand Spring boot related stuff like @Autowired is working. so this fix is not really obvious. make it an answer and earn some points :-) – dermoritz Jul 09 '21 at 13:48
  • hi! glad I could help, made it an answer as you suggested :) – Greenev Jul 12 '21 at 08:16

1 Answers1

1

It seems that you also need @SpringBootTest annotation to get it solved

@CamelSpringBootTest
@SpringBootTest
class UnmarshalXmlTest {
    ...
}
Greenev
  • 871
  • 6
  • 23
  • this is really odd "@CamelSpringBootTest" provides spring context but without camel context (camel annotations are null because there is no camecontext). as soon as a camelcontext is present the camel annotations begin to work. – dermoritz Jul 13 '21 at 13:30