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

Support @MockEndpoint and @MockEndpointAndSkip in Spring Boot

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.16.0
    • Fix Version/s: 2.17.1, 2.18.0
    • Labels:
      None
    • Environment:

      mac, jdk7

    • Estimated Complexity:
      Unknown

      Description

      My route looks like

      from(“direct:start”).to(“direct:end”)

      My unit test looks like

      @RunWith(SpringJUnit4ClassRunner.class)
      @SpringApplicationConfiguration(classes = Config.class)
      @MockEndpoints
      public class MyUnitTest {
      
       @Produce(uri=“direct:start”)
       private ProducerTemplate producer;
      
       @EndpointInject(uri=“mock:direct:end”)
       private MockEndpoint end;
      
      	@Test
      	public void testMock() throws InterruptedException {
      		end.expectedBodiesReceived("blah");
      		producerTemplate.sendBody("blah");
      		end.assertIsSatisfied();
      	}
      
      }
      

      It looks like the direct:end bit is never mocked so the assertion fails. It’s like @MockEndpoints is completely ignored.

      There are workarounds described here http://camel.465427.n5.nabble.com/spring-boot-test-mocks-td5773902.html

      There are disadvantages to these workarounds as listed in that thread. Thanks

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              mtran Minh Tran
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: