Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 67568 invoked from network); 27 May 2010 13:18:34 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 27 May 2010 13:18:34 -0000 Received: (qmail 89821 invoked by uid 500); 27 May 2010 13:18:34 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 89791 invoked by uid 500); 27 May 2010 13:18:34 -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 89783 invoked by uid 99); 27 May 2010 13:18:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 May 2010 13:18:34 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=AWL,FREEMAIL_FROM,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 74.125.82.45 as permitted sender) Received: from [74.125.82.45] (HELO mail-ww0-f45.google.com) (74.125.82.45) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 May 2010 13:18:30 +0000 Received: by wwg30 with SMTP id 30so1173170wwg.32 for ; Thu, 27 May 2010 06:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=gmqDsc94VS7RdLd4C/w/AVoMjnnSlC1Es5e7B8Ny/A0=; b=QqsPalPupBohjKT95Yr7bdsD+qGYPWPZ0y9QfiJ7iUQxva1ku/LibBz4RVdZMHIO0J 7h+BODt6RxU4AT2dbr4hu11gKj0di7D0Sp9If7EO0OsYDILerllZbq898hBHrM7+5RN/ 2vt/JrRMy3aI7K5oKrXV3myFfys27aPXtfr4k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=QTOTiwSGBAJ4wNFOrW/hvPvjvpw36tkSgozvNClzN0LL/w46N5JVLD+vRdA8F0+wWS qHtZPeJYEsvyGco1PP0vTu2WqT624S5BgIRL0ZuBw0zfX1K/TGw1icezsd7UqbPXS1dT Opar5XlcCaD2bPCG8cbSeUI391aiU5wMviBGU= Received: by 10.227.143.198 with SMTP id w6mr9830635wbu.34.1274966285158; Thu, 27 May 2010 06:18:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.6.140 with HTTP; Thu, 27 May 2010 06:17:45 -0700 (PDT) In-Reply-To: <28693620.post@talk.nabble.com> References: <28693620.post@talk.nabble.com> From: Claus Ibsen Date: Thu, 27 May 2010 15:17:45 +0200 Message-ID: Subject: Re: Using mockito to mock endpoint behavior To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Can you try latest code as we have committed a fix after the 2.3 release. On Thu, May 27, 2010 at 2:51 PM, eirilwan wrote: > > Hi > > When upgrading from Camel 2.1.0 to 2.3.0 we encountered a problem using > Mockito to mock endpoint behaviour while testing camel routes. > > Our test is running with junit4 using Spring context configuration. We > inject mockito mocked endpoints into both the test and the route like thi= s: > > =A0 =A0@Produce(uri =3D "mock:successConsumer") > =A0 =A0protected MockEndpoint successConsumer; > > =A0 =A0@Resource(name =3D "testRepo") > =A0 =A0protected TestRepository someRepo; > > The TestRepo is created in spring using XML configuration: > =A0 =A0 > =A0 =A0 =A0 =A0 > =A0 =A0 > > > The code we try to test is: > =A0 =A0 =A0 =A0from("direct:calveConsumer") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.bean(someRepo, "someRepoMethod").to(succe= ssConsumer) > > > When running the test, camel don't seem to find the someRepoMethod on the > "someRepo" bean. We have tracked down the problem to getTargetClass in > org.apache.camel.component.bean.BeanInfo.class. > > Since mockito is using cglib for enhancing interfaces, this method return > the superclass of the mock, which is Object. This behaviour will work fin= e > when an object is enhanced with cglib, but not when you use cglib to enha= nce > an =A0interface. > > An solution could be to check if the class before $$ is an interface and > return it if it is. > > Any thoughts? > > Our solution right now is to create real mock stubs of all interfaces to > work around the problem. > > regards > Eirik L. Wang > > -- > View this message in context: http://old.nabble.com/Using-mockito-to-mock= -endpoint-behavior-tp28693620p28693620.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > --=20 Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus