You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Michel Erard (Jira)" <ji...@apache.org> on 2020/08/31 09:47:00 UTC
[jira] [Updated] (CAMEL-15486) Mocking of Camel Endpoints breaks
because dependency
[ https://issues.apache.org/jira/browse/CAMEL-15486?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michel Erard updated CAMEL-15486:
---------------------------------
Description:
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}
was:
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]
> Mocking of Camel Endpoints breaks because dependency
> ----------------------------------------------------
>
> 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: Major
>
> 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)