Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C3FDDBE1 for ; Thu, 8 Nov 2012 20:29:45 +0000 (UTC) Received: (qmail 31813 invoked by uid 500); 8 Nov 2012 20:29:45 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 31647 invoked by uid 500); 8 Nov 2012 20:29:45 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 31639 invoked by uid 99); 8 Nov 2012 20:29:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Nov 2012 20:29:45 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.215.45] (HELO mail-la0-f45.google.com) (209.85.215.45) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Nov 2012 20:29:41 +0000 Received: by mail-la0-f45.google.com with SMTP id m13so2880230lah.32 for ; Thu, 08 Nov 2012 12:29:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding:x-gm-message-state; bh=FO5zltvT7grSnHYXpl3N2sOChJNi7Xel3U062pRxLzQ=; b=BG9C7GnompK7PB2EDsCfAr7p3AkWFjwvXm5qo0KgxycH7qcG1aSk24X0tcBLIfr/k+ xxCwHu9BVH5H1RaaObvukwYkpBva+gztJSg0jP0EjyPoYDeUrpTZ8b/94OtjylFrxb20 w6lG8pmmziCzN0JDB9//XA2yQdtFVdsi4Rvzq/Dl9tTBGbcsRCkOQYk1Fidzv+chKPiT 9+WKH5Vu50//9gAJbBZC9PM05pYspk3bpcnOWdhL1pQqDz+FL7cpaNe+vZ+zk3qOBdKk MS9tChXrN+hjOQUFWGJkejuTP+qNhTzWsol4e2Ebym6ReUY39w08o6ZbKwu8AEYBOU0G babQ== Received: by 10.152.124.83 with SMTP id mg19mr8713729lab.6.1352406559001; Thu, 08 Nov 2012 12:29:19 -0800 (PST) MIME-Version: 1.0 Sender: jcarman@carmanconsulting.com Received: by 10.112.93.172 with HTTP; Thu, 8 Nov 2012 12:28:58 -0800 (PST) In-Reply-To: References: <1352302651741-5722307.post@n5.nabble.com> From: James Carman Date: Thu, 8 Nov 2012 15:28:58 -0500 X-Google-Sender-Auth: RPbCMC-Kddk12T0z6DcgMpoDstg Message-ID: Subject: Re: How to mock a bean in a route? To: "users@camel.apache.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQl8rKOpVEGhWhwwZhY8hvls6r7HZVPcQ0rdxI7AOpqjVd6zSGZC2p9bxoh/AK2EWSBRz+8u X-Virus-Checked: Checked by ClamAV on apache.org 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 wrot= e: > The 1st link gave a 404. > Den 8. nov. 2012 14:25 skrev "James Carman" > f=F8lgende: > >> 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 >> wrote: >> > I have a follow up question on this. >> > I have this route: >> > >> > >> > > > >> > >> uri=3D"jms:queue:{{.online.mq.reservationsReceiveQueue}}?connectionFacto= ry=3D#rtsConnectionFactory&destinationResolver=3D#rtsDestinationResolve= r&asyncStartListener=3Dtrue&transactionManager=3D#rtsJmsTransaction= Manager&transacted=3Dtrue&lazyCreateTransactionManager=3Dfalse&= disableReplyTo=3Dtrue" >> > /> >> > > > ref=3D"TransactionManagerPolicyRequired" /> >> > > > >> > >> uri=3D"log:PERF_LOG?level=3DINFO&groupInterval=3D60000&groupDela= y=3D10000&groupActiveOnly=3Dfalse" >> > /> >> > > > loggingLevel=3D"INFO" >> > message=3D"REQUEST: ${body}" /> >> > >> > > > xmlns:ledgerres=3D"fc:evry:com:xsd:fundscheckmaintainavailablebalance"= > >> > >> > /ledgerres:Document >> > > > >> > uri=3D"validator:META-INF/xsd/fundscheckmaintainavailablebalance.xsd" = /> >> > >> > > prettyPrint=3D"true" >> > >> > contextPath=3D"fc.evry.com.xsd.fundscheckmaintainavailablebalance" >> > >> > partClass=3D"fc.evry.com.xsd.fundscheckmaintainavailablebalance.Docume= nt" >> > /> >> > >> > > > >> > >> uri=3D"bean:mainLedgerIntegrationServiceImpl?method=3DprocessReservation= FromMainLedger( >> > ${body} )" /> >> > >> > > > xmlns:ledgerposting=3D"tg:evry:com:xsd:transactiongatetransfertransact= ion"> >> > >> > /ledgerposting:Document >> > > > >> > uri=3D"validator:META-INF/xsd/transactiongatetransfertransaction.xsd" = /> >> > >> > > prettyPrint=3D"true" >> > >> > contextPath=3D"tg.evry.com.xsd.transactiongatetransfertransaction" >> > >> > partClass=3D"tg.evry.com.xsd.transactiongatetransfertransaction.Docume= nt" >> > /> >> > >> > > > >> > >> uri=3D"bean:mainLedgerIntegrationServiceImpl?method=3DprocessPostingFrom= MainLedger( >> > ${body} )" /> >> > >> > >> > >> > >> > java.lang.Exception >> > >> > >> true >> > >> > > > uri=3D"log:RTS_MSG_EXCHANGE?showAll=3Dtrue&level=3DERROR" /> >> > > > >> uri=3D"jms:queue:{{.online.mq.reservationsReceiveErrorQueue}}?connection= Factory=3D#rtsConnectionFactory&destinationResolver=3D#rtsDestinationRe= solver&transactionManager=3D#rtsJmsTransactionManager&disableReplyT= o=3Dtrue" >> > /> >> > >> > >> > >> > 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 : >> >> 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 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-tp572230= 7.html >> >>> Sent from the Camel - Users mailing list archive at Nabble.com. >> > >> > >> > >> > -- >> > -- >> > David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen >>