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

camel-test-spring - Mocking of Camel Endpoints breaks because adding 3rd party dependency with spring boot

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.4.3
    • 3.6.0
    • camel-test
    • None
    • Unknown

    Description

      As soon you add the dependency 

      <dependency>            
          <groupId>org.springframework.cloud</groupId>            
          <artifactId>spring-cloud-contract-wiremock</artifactId>               
          <version>2.2.3.RELEASE</version>            
          <scope>test</scope>        
      </dependency>

      to your project, the mocking of the endpoints breaks.

      I've created a simple example to reproduce the issue: 

      https://github.com/erard22/spring-boot-camel-bug-demo

       

      @Component
      public class SimpleCamelRoute extends RouteBuilder {
      
          @Override
          public void configure() {
      
              from("direct:processMessage")
                      .to("file:output");
          }
      }
      
      @CamelSpringBootTest
      @SpringBootTest(classes = DemoApplication.class)
      @ContextConfiguration
      @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
      @MockEndpoints("file:*")
      class SimpleCamelRouteTest {
      
          @Autowired
          private CamelContext camelContext;
      
          @Produce("direct:processMessage")
          private ProducerTemplate producer;
      
          @EndpointInject("mock://file:output")
          private MockEndpoint mockCamel;
      
          @Test
          void processMessage_successful() throws Exception {
              mockCamel.expectedBodiesReceived("foo");
              producer.sendBodyAndHeaders("foo", Collections.emptyMap());
              mockCamel.assertIsSatisfied();
          }
      }
      
      java.lang.AssertionError: mock://file:output Received message count. Expected: <1> but was: <0>
      Expected :<1>
      Actual   :<0>
      

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              erard22 Michel Erard
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: