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 34035EE66 for ; Mon, 4 Feb 2013 14:04:40 +0000 (UTC) Received: (qmail 17624 invoked by uid 500); 4 Feb 2013 14:04:39 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 17431 invoked by uid 500); 4 Feb 2013 14:04:39 -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 17413 invoked by uid 99); 4 Feb 2013 14:04:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Feb 2013 14:04:39 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [212.227.126.187] (HELO moutng.kundenserver.de) (212.227.126.187) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Feb 2013 14:04:34 +0000 Received: from JanmySN (dsdf-5d828537.pool.mediaWays.net [93.130.133.55]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MQdCf-1UPCy00XSX-00UCGY; Mon, 04 Feb 2013 15:04:13 +0100 From: =?iso-8859-1?Q?Jan_Mat=E8rne_=28jhm=29?= To: References: <1359979199141-5726886.post@n5.nabble.com> <1359981915351-5726891.post@n5.nabble.com> <003b01ce02da$f5a79610$e0f6c230$@de> <004401ce02dc$6405de90$2c119bb0$@de> In-Reply-To: <004401ce02dc$6405de90$2c119bb0$@de> Subject: AW: Calling count function in the camel route Date: Mon, 4 Feb 2013 15:04:12 +0100 Message-ID: <004501ce02e0$829fbe80$87df3b80$@de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac4C2JI9yfyOwS+VRVu5B1dUvTkWCwAAk0YAAABbytAAAQbscA== Content-Language: de X-Provags-ID: V02:K0:dPDBrF1XIncj+YJTzW4VWc8dkVIP6CePCW5Ey18TNbt xeeNnrmgjBjbRac7N0DPRWQ0yt7duMC/Kwz9g+q/iB89/kSuwi x3+YqP/WMC6o4MD7RRmJYgQkzjCK44vykiTyR1lhe+y4XXiMUi hk0NAjr2UegGOUG4yXuhAhcSD3lk61D9yKZVOmYzmwXpAFmCFe dNKOgxaj5X0l9yg53kA0QlsHGCAi7P4FIrxlbtUOOAymB/D3RG v86Q3zdC9tDOcIyDD/HUp38hEznx/aqWmSAxwG96ZbKPKDiHJ9 OvHcN55XwMXdBcfDmGlIihOd95i86kMn5Pxps6m0ZuSaoslwPX d9pJgczvJun1Bh5NkDLU= X-Virus-Checked: Checked by ClamAV on apache.org Ok, forgotten to invoke the assertIdSatisfied() ... @Test public void count() throws InterruptedException { MockEndpoint mock =3D getMockEndpoint("mock:result"); mock.expectedMessageCount(1); mock.expectedHeaderReceived("count", 3); =20 template.sendBody("direct:in", ""); mock.assertIsSatisfied(); } Jan -----Urspr=FCngliche Nachricht----- Von: Jan Mat=E8rne (jhm) [mailto:apache@materne.de]=20 Gesendet: Montag, 4. Februar 2013 14:35 An: users@camel.apache.org Betreff: AW: Calling count function in the camel route I tried some of mock.expect* methods, but I couldnt write the assert = with one of them. Is this possible? Jan -----Urspr=FCngliche Nachricht----- Von: Jan Mat=E8rne (jhm) [mailto:apache@materne.de] Gesendet: Montag, 4. Februar 2013 14:24 An: users@camel.apache.org Betreff: AW: Calling count function in the camel route Played a little bit with that. This example works for me. cheers Jan public class XpathCountTest extends CamelTestSupport { @Test public void count() { final MockEndpoint mock =3D getMockEndpoint("mock:result"); mock.expectedMessageCount(1); =20 template.sendBody("direct:in", ""); =20 assertEquals( "Wrong count", 3, mock.getExchanges().get(0).getIn().getHeader("count")); } =09 @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from("direct:in") .setHeader("count", xpath("count(//A)").resultType(Integer.class)) .to("mock:result"); } }; } =09 } -----Urspr=FCngliche Nachricht----- Von: Claus Ibsen [mailto:claus.ibsen@gmail.com] Gesendet: Montag, 4. Februar 2013 14:07 An: users@camel.apache.org Betreff: Re: Calling count function in the camel route On Mon, Feb 4, 2013 at 1:45 PM, dkum003 = wrote: > Hi Claus, > > The xml is pretty simple.. say a list of tags... > > > So i need to get the count of h3 tags and store it in the exchange = header. > Hi See this page http://camel.apache.org/xpath About namespace auditing. If your xml has namespaces, then your xpath expression must have that as well. And then its not so easy to get working. There may be some xpath tools / tutorials you can take a look at to make = the count work Maybe something like "count(//h3)" Mind that if you have namesapces, you need to add that to the count "count(//foo:h3)" Where foo is your namespace "key". > Thanks. > > > > -- > View this message in context:=20 > http://camel.465427.n5.nabble.com/Calling-count-function-in-the-camel- > route-tp5726886p5726891.html Sent from the Camel - Users mailing list=20 > archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cibsen@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen