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 1BD1199A0 for ; Sat, 31 Mar 2012 10:06:34 +0000 (UTC) Received: (qmail 99125 invoked by uid 500); 31 Mar 2012 10:06:33 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 99070 invoked by uid 500); 31 Mar 2012 10:06:32 -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 99052 invoked by uid 99); 31 Mar 2012 10:06:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Mar 2012 10:06:32 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.215.45 as permitted sender) Received: from [209.85.215.45] (HELO mail-lpp01m010-f45.google.com) (209.85.215.45) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Mar 2012 10:06:26 +0000 Received: by lahe6 with SMTP id e6so2050393lah.32 for ; Sat, 31 Mar 2012 03:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=lnap0bVtfCVVn61Rm7wD7tNtzkyHz2QRi6JP+SXmsmI=; b=YxIBqboj8isdzD4tLkqN5e1bShXd6cKBVgjzTzwUu1Qy5a2rnmhgPxt1R5g7puR++M LQ2vuRQ0ivPdizMVlIPiybI0OYijAXnfw2k4nMZSATHDztH0znjvHe2Ro/0OBom2qKEM bDoDsu4+iW6i0P0SJwwFL5U9CrXY4G9c/vUBrVXK8jx4mlET1PyO/mOdUpddkG39+dUK PnR7JpHn3VKzZxwSmWelkeUsHxyL9Tt2mI2F6atVBn9j2U6wPxf5At+MQXtBCVXN1x8o NZpNWQxquZFIqER/dJmOHWAws1HOzT/xf8Z2g1Z0QcLANgxZwLnRKKps6qNseUuVBwVo Nd9w== Received: by 10.152.129.74 with SMTP id nu10mr1819785lab.50.1333188366203; Sat, 31 Mar 2012 03:06:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.75.130 with HTTP; Sat, 31 Mar 2012 03:05:45 -0700 (PDT) In-Reply-To: References: <1332835085957-5597196.post@n5.nabble.com> <1333012658249-5603131.post@n5.nabble.com> From: Claus Ibsen Date: Sat, 31 Mar 2012 12:05:45 +0200 Message-ID: Subject: Re: [Bindy] Having trouble with the "required" field To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2012/3/29 Magnus Palm=E9r : > I can confirm, I get the same error as you do when I remove the two last > fields at the end of the line as you did. > > I think this is the where it starts to get wrong: > BindyCsvDataFormat.java > > =A0138 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Read the line > =A0139 =A0 =A0 =A0 =A0 =A0 =A0 =A0String line =3D scanner.nextLine().trim= (); > > String.trim() trims all the remaining tabs... > Well spotted. Do you mind created a JIRA ticket? And patches is welcome. > Den 29 mars 2012 11:17 skrev Aida : > >> Hi again, thank you for the quick answers. >> >> I think I have been able to replicate the problem in an easy way. I have >> built some test cases and I have found the one in which I'm having troub= le. >> The "required=3Dfalse" option is working for me always except in one cas= e. >> >> This case is when the two missing fields occur at the end of a line at t= he >> same time. I'm going to explain it with my test cases. >> >> I have built a simple route for my unitary tests: >> >> from(URI_START_PROCESS) >> =A0 =A0 =A0.unmarshal().bindy(BindyType.Csv, "com.mypackage") >> =A0 =A0 =A0 =A0 =A0 =A0 =A0.to(URI_END_PROCESS_MOCK); >> >> >> My class (I have only one) in "com.mypackage" has the following >> annotations: >> @CsvRecord(separator=3D"\t") >> from positions 1 to 5: @DataField(pos =3D N, required =3D true) >> for positions 6 and 7 : @DataField(pos =3D N, required =3D false) =A0(so= fields 6 >> and 7 are optional) >> >> Test Cases: >> >> Case 1: Processing two lines with ALL the fields =A0 =A0(Works like a ch= arm) >> String data2Process =3D "data1\t14700\t2011-10-04 >> 04:00\t5\t1\t5\t9\ndata2\t14700\t2011-10-04 05:00\t49\t2\t5"; >> >> Case 2: Processing two lines. In the first line the 6th field is missing >> (works perfectly) >> String data2Process =3D "data1\t14700\t2011-10-04 >> 04:00\t5\t0*\t\t*0\ndata2\t14700\t2011-10-04 05:00\t149\t0\t0"; >> >> Case 3: Processing two lines. In the first line the 7th field is missing >> (works perfectly) >> String data2Process =3D "data1\t14700\t2011-10-04 >> 04:00\t5\t0\t0*\t\n*data2\t14700\t2011-10-04 05:00\t149\t0\t0"; >> >> Case 4: Processing two lines. In the first line, both 6th and 7th field = are >> missing (is not working) >> String data2Process =3D "data1\t14700\t2011-10-04 >> 04:00\t5\t0*\t\t\n*data2\t14700\t2011-10-04 05:00\t149\t0\t0"; >> >> >> I also tried a variation of Case 4, in which I made field 5 also not >> required and the missing fields were 5th and 6th, in this case there wer= e >> no >> problems. >> >> The exception is the one I said before: "Some fields are missing (option= al >> or mandatory), line:1" >> >> >> >> -- >> View this message in context: >> http://camel.465427.n5.nabble.com/Bindy-Having-trouble-with-the-required= -field-tp5597196p5603131.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> --=20 Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource Email: cibsen@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/