[
https://issues.apache.org/jira/browse/CAMEL-3578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12985574#action_12985574
]
Claus Ibsen edited comment on CAMEL-3578 at 1/24/11 4:13 AM:
-------------------------------------------------------------
In Spring XML you can add a spring bean to enable mocking
{code:xml}
<!-- bean which enables mocking all endpoints -->
<bean id="mockAllEndpoints"
class="org.apache.camel.impl.InterceptSendToMockEndpointStrategy"/>
<!-- the camel context with the routs we want to test -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<to uri="direct:foo"/>
<to uri="log:foo"/>
<to uri="mock:result"/>
</route>
<route>
<from uri="direct:foo"/>
<transform>
<constant>Bye World</constant>
</transform>
</route>
</camelContext>
{code}
It supports a pattern so you can for example say to only mock all log endpoints:
{code:xml}
<bean id="mockAllEndpoints"
class="org.apache.camel.impl.InterceptSendToMockEndpointStrategy">
<constructor-arg index="0" name="log*"/>
</bean>
{code}
was (Author: davsclaus):
In Spring XML you can add a spring bean to enable mocking
{code:xml}
<!-- bean which enables mocking all endpoints -->
<bean id="mockAllEndpoints"
class="org.apache.camel.impl.InterceptSendToMockEndpointStrategy"/>
<!-- the camel context with the routs we want to test -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<to uri="direct:foo"/>
<to uri="log:foo"/>
<to uri="mock:result"/>
</route>
<route>
<from uri="direct:foo"/>
<transform>
<constant>Bye World</constant>
</transform>
</route>
</camelContext>
{code}
It supports a pattern so you can for example say to only mock all log endpoints:
{code:xml}
<bean id="mockAllEndpoints"
class="org.apache.camel.impl.InterceptSendToMockEndpointStrategy">
<constructor-arg index="0" name="log*"/>
</bean>
{code}
</bean>
{code}
> MockEndpoint - Add feature to mock any endpoint
> -----------------------------------------------
>
> Key: CAMEL-3578
> URL: https://issues.apache.org/jira/browse/CAMEL-3578
> Project: Camel
> Issue Type: New Feature
> Components: camel-core
> Affects Versions: 2.5.0
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Fix For: 2.7.0
>
>
> See nabble
> http://camel.465427.n5.nabble.com/Unit-Testing-Route-td3284803.html
> The idea is to be able to mock any endpoint on a route and thus be able to
> set expectations.
> In the 2.x architecture we will have to implement this using the adviceWith
> as the route must be {{re-processed}} so we can add the interceptor logic to
> mock
> any endpoints.
> In Camel 3.x this could be applied dynamically on the Channel.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.