[
https://issues.apache.org/jira/browse/CAMEL-15486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17187624#comment-17187624
]
Claus Ibsen commented on CAMEL-15486:
-------------------------------------
Try without that dirties context and otherwise thinker with the test. And what
does that spring dependency do, maybe it does something that causes the restart
to fail and in line of this camel too
> Mocking of Camel Endpoints breaks because adding 3rd party dependency with
> spring boot
> --------------------------------------------------------------------------------------
>
> Key: CAMEL-15486
> URL: https://issues.apache.org/jira/browse/CAMEL-15486
> Project: Camel
> Issue Type: Bug
> Components: camel-test
> Affects Versions: 3.4.3
> Reporter: Michel Erard
> Priority: Minor
>
> As soon you add the dependency
> {code:java}
> <dependency>
> <groupId>org.springframework.cloud</groupId>
> <artifactId>spring-cloud-contract-wiremock</artifactId>
> <version>2.2.3.RELEASE</version>
> <scope>test</scope>
> </dependency>{code}
> 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]
>
> {code:java}
> @Component
> public class SimpleCamelRoute extends RouteBuilder {
> @Override
> public void configure() {
> from("direct:processMessage")
> .to("file:output");
> }
> }
> {code}
> {code:java}
> @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();
> }
> }
> {code}
> {code:java}
> java.lang.AssertionError: mock://file:output Received message count.
> Expected: <1> but was: <0>
> Expected :<1>
> Actual :<0>
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)