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 783AB10B86 for ; Tue, 8 Oct 2013 04:34:10 +0000 (UTC) Received: (qmail 22309 invoked by uid 500); 8 Oct 2013 04:34:06 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 22248 invoked by uid 500); 8 Oct 2013 04:34:04 -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 22233 invoked by uid 99); 8 Oct 2013 04:34:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Oct 2013 04:34:03 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of kraythe@gmail.com designates 74.125.82.46 as permitted sender) Received: from [74.125.82.46] (HELO mail-wg0-f46.google.com) (74.125.82.46) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Oct 2013 04:33:57 +0000 Received: by mail-wg0-f46.google.com with SMTP id k14so7998676wgh.1 for ; Mon, 07 Oct 2013 21:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=oxXhBy3c2ZRPb9i7d9SMcaOmtV0ye5q3t4Wzn8GTnO4=; b=jYvk3hvx1ZDCoJ0vSI0oDLLeQ3eeMcYywdw7tfgOQmEtPO/5WFsmbXyQTf0CurA2vF 9KOd2eMo2JEvCAxTwwclxQdKAkp/oE8jh6udtqCaOYcl8vXKahvdCo3w/eUCvxGk9U3s 7WuEo/nGZqozz5eS2spyLxEvrv3KC7kyOAGxCMvcefz6Ht3diNA2yBgEDRqrYcEDj3+r rkTaov9J4PSlT3Wn+GCZgZWmGWoJzjBDYBwra0sykB0EBE90aaRrr2ryoiPwyDAOyFt1 5EV/ZUi94mqhGNxAdvjmuF89u8aJoTM0QkKkD4+Oox9mr1FQi9DgSxDwvznLpThUuPG6 twdA== MIME-Version: 1.0 X-Received: by 10.194.21.131 with SMTP id v3mr163691wje.44.1381206817349; Mon, 07 Oct 2013 21:33:37 -0700 (PDT) Received: by 10.194.206.71 with HTTP; Mon, 7 Oct 2013 21:33:37 -0700 (PDT) In-Reply-To: <1381166237958-5741050.post@n5.nabble.com> References: <1381166237958-5741050.post@n5.nabble.com> Date: Mon, 7 Oct 2013 23:33:37 -0500 Message-ID: Subject: Re: Problem with mock end points and testing error handling From: "kraythe ." To: Camel Users List Content-Type: multipart/alternative; boundary=047d7b5d64f2b5a52404e8334552 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b5d64f2b5a52404e8334552 Content-Type: text/plain; charset=ISO-8859-1 Yeah you need to mock and skip and then you need to find the mock endpoint and attach it using the weaving code. So something like this: in your advice: mockEndpointsAndSkip("bean:*"); Then in your test: final String beanURI = "mock:bean:myBean"; assertNotNull(beanURI); // << DONT FORGET THIS or you will chase ghosts a lot MockEndpoint mep = getMockEndpoint(beanURI); mep.whenAnyExchangeReceived(new Processor() { @Override process(final Exchange exchange) { throw RuntimeException("hi"); } } Then send the message to the route. [1] http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#whenAnyExchangeReceived(org.apache.camel.Processor) *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of: Hardcore Java (2003) and Maintainable Java (2012)* *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39* On Mon, Oct 7, 2013 at 12:17 PM, berhack wrote: > I have context level defined error handling (retry interval and retry > attempts defined) that I am trying to test out. Yet it will never be > invoked no matter how I simulate the error with mock end points. Does > anyone how this can work? > > Given my route I'm testing just looks like: > > from(myQueue).to("bean:myBean?method=processOrder") > > Here's what I've tried: > > Insert advice to skip send to bean endpoint, and send to mock:myBean > instead. Have mock:myBean throw an exception. Error handler is NOT > invoked > (I can see no retry attempt at all in the logs). > > Override (via Spring injection) the bean endpoint with mock:myBean. Have > mock:myBean throw an exception. Error handler is NOT invoked. > > In either above attempts, also tried setting the exception off the Exchange > object (i.e. exchange.setException), instead of throwing an exception > explicitly (what's the difference anyway?), again no luck, error handler > not > invoked. > > Here's what WORKS: > > When NO mock end point is involved, i.e. my original bean endpoint throws a > null pointer exception, I can see error handler working. > > > Any ideas? > > Thanks! > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Problem-with-mock-end-points-and-testing-error-handling-tp5741050.html > Sent from the Camel - Users mailing list archive at Nabble.com. > --047d7b5d64f2b5a52404e8334552--