You need to click quicker, because I am actively working on this
project! :) Just download the whole project and you should have an
example for yourself

Sent from my iPhone

On Nov 10, 2012, at 3:13 PM, David Karlsen <[email protected]> wrote:

> That gave a 404 too :)
>
> 2012/11/8 James Carman <[email protected]>:
>> Sorry, I've been tweaking the code:
>>
>> https://github.com/jwcarman/camel-transaction/blob/master/src/test/java/com/carmanconsulting/camel/TestJdbcRouteBuilder.java
>>
>> On Thu, Nov 8, 2012 at 3:07 PM, David Karlsen <[email protected]> wrote:
>>> The 1st link gave a 404.
>>> Den 8. nov. 2012 14:25 skrev "James Carman" <[email protected]>
>>> følgende:
>>>
>>>> Have you tried just overriding the isMockEndpoints() method:
>>>>
>>>>
>>>> https://github.com/jwcarman/camel-transaction/blob/master/src/test/java/com/carmanconsulting/camel/TestMyRouteBuilder.java
>>>>
>>>> Alternatively, you can just use JMS in your unit test:
>>>>
>>>>
>>>> https://github.com/jwcarman/camel-transaction/blob/master/src/test/java/com/carmanconsulting/camel/AbstractRouteBuilderTest.java
>>>>
>>>>
>>>> On Thu, Nov 8, 2012 at 2:34 AM, David Karlsen <[email protected]>
>>>> wrote:
>>>>> I have a follow up question on this.
>>>>> I have this route:
>>>>>
>>>>> <camel:route id="inboundFromRtsRoute">
>>>>>                        <camel:from
>>>> uri="jms:queue:{{.online.mq.reservationsReceiveQueue}}?connectionFactory=#rtsConnectionFactory&amp;destinationResolver=#rtsDestinationResolver&amp;asyncStartListener=true&amp;transactionManager=#rtsJmsTransactionManager&amp;transacted=true&amp;lazyCreateTransactionManager=false&amp;disableReplyTo=true"
>>>>> />
>>>>>                        <camel:transacted id="transacted"
>>>>> ref="TransactionManagerPolicyRequired" /> <!--look further down the
>>>>> mail on this one-->
>>>>>                        <camel:to
>>>> uri="log:PERF_LOG?level=INFO&amp;groupInterval=60000&amp;groupDelay=10000&amp;groupActiveOnly=false"
>>>>> />
>>>>>                        <camel:log logName="RTS_MESSAGE_TRACE"
>>>>> loggingLevel="INFO"
>>>>>                                message="REQUEST: ${body}" />
>>>>>                        <camel:choice>
>>>>>                                <camel:when
>>>>> xmlns:ledgerres="fc:evry:com:xsd:fundscheckmaintainavailablebalance">
>>>>>
>>>>> <camel:xpath>/ledgerres:Document</camel:xpath>
>>>>>                                        <camel:to
>>>>>
>>>>> uri="validator:META-INF/xsd/fundscheckmaintainavailablebalance.xsd" />
>>>>>                                        <camel:unmarshal>
>>>>>                                                <camel:jaxb
>>>> prettyPrint="true"
>>>>>
>>>>> contextPath="fc.evry.com.xsd.fundscheckmaintainavailablebalance"
>>>>>
>>>>> partClass="fc.evry.com.xsd.fundscheckmaintainavailablebalance.Document"
>>>>> />
>>>>>                                        </camel:unmarshal>
>>>>>                                        <camel:to
>>>> uri="bean:mainLedgerIntegrationServiceImpl?method=processReservationFromMainLedger(
>>>>> ${body} )" />
>>>>>                                </camel:when>
>>>>>                                <camel:when
>>>>> xmlns:ledgerposting="tg:evry:com:xsd:transactiongatetransfertransaction">
>>>>>
>>>>> <camel:xpath>/ledgerposting:Document</camel:xpath>
>>>>>                                        <camel:to
>>>>>
>>>>> uri="validator:META-INF/xsd/transactiongatetransfertransaction.xsd" />
>>>>>                                        <camel:unmarshal>
>>>>>                                                <camel:jaxb
>>>> prettyPrint="true"
>>>>>
>>>>> contextPath="tg.evry.com.xsd.transactiongatetransfertransaction"
>>>>>
>>>>> partClass="tg.evry.com.xsd.transactiongatetransfertransaction.Document"
>>>>> />
>>>>>                                        </camel:unmarshal>
>>>>>                                        <camel:to
>>>> uri="bean:mainLedgerIntegrationServiceImpl?method=processPostingFromMainLedger(
>>>>> ${body} )" />
>>>>>                                </camel:when>
>>>>>                        </camel:choice>
>>>>>                        <camel:onException useOriginalMessage="true">
>>>>>
>>>>> <camel:exception>java.lang.Exception</camel:exception>
>>>>>                                <camel:handled>
>>>> <camel:constant>true</camel:constant>
>>>>>                                </camel:handled>
>>>>>                                <camel:to
>>>>> uri="log:RTS_MSG_EXCHANGE?showAll=true&amp;level=ERROR" />
>>>>>                                <camel:to id="inboundFromErrorQueue"
>>>> uri="jms:queue:{{.online.mq.reservationsReceiveErrorQueue}}?connectionFactory=#rtsConnectionFactory&amp;destinationResolver=#rtsDestinationResolver&amp;transactionManager=#rtsJmsTransactionManager&amp;disableReplyTo=true"
>>>>> />
>>>>>                        </camel:onException>
>>>>>                </camel:route>
>>>>>
>>>>> this route was easily unit-testable by doing overrides in my setup:
>>>>> camelContext.getRouteDefinition( "inboundFromRtsRoute" ).adviceWith(
>>>>> camelContext, new AdviceWithRouteBuilder()
>>>>>        {
>>>>>            @Override
>>>>>            public void configure()
>>>>>                throws Exception
>>>>>            {
>>>>>                replaceFromWith( mockEndpoint.getDefaultEndpoint() );
>>>>>                weaveById( "inboundFromRtsErrorQueue" ).replace().to(
>>>>> mockInboundFromRtsErrorQueue );
>>>>>            }
>>>>>        } );
>>>>>
>>>>> before I added the transacted element.
>>>>> Is there any easy way for me to skip the transacted node in the route?
>>>>> I tried weaveById( "transacted" ).remove(); but that removes the node
>>>>> and all child nodes it seems. I just wanna replace the jms input route
>>>>> AND the transacted element with my mock endpoint.
>>>>>
>>>>> Is this possible?
>>>>>
>>>>> Yes I could use embedded active mq for testing - but that leads to a
>>>>> lot of excessive config.
>>>>>
>>>>>
>>>>>
>>>>> 2012/11/8 James Carman <[email protected]>:
>>>>>> You can inject mock objects into your route builders very easily.
>>>>>> Just pick your mock object framework of choice and inject them when
>>>>>> you create your RouteBuilder.
>>>>>>
>>>>>> On Wed, Nov 7, 2012 at 10:37 AM, zzkozak <[email protected]> wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have the following route and would like to test it by throwing an
>>>>>>> exception by the orderRequestCreator bean. How do I do that?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I am using annotated JUnit tests, like this:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thank you in advance,
>>>>>>> Marcin
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>> http://camel.465427.n5.nabble.com/How-to-mock-a-bean-in-a-route-tp5722307.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> --
>>>>> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
>
>
>
> --
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Reply via email to