Hmm, I had a hard time recreating the issue when trying to extend the
current JUnit test.
Turns out that it already works in 2.10-SNAPSHOT.
Uncertain when and how, still trying to figure it out since it does seem to
be a side effect of some other change.


Den 31 mars 2012 13:18 skrev Magnus Palmér <magnus.palmer.w...@gmail.com>:

> JIRA ticket created:
> https://issues.apache.org/jira/browse/CAMEL-5133
>
>
> Den 31 mars 2012 12:56 skrev Magnus Palmér <magnus.palmer.w...@gmail.com>:
>
> Sure, I can create a JIRA ticket for it.
>> Will have to set up my dev-environment properly to be able to patch it
>> though.
>> It is in my plan to do anyway but since I am on paternity leave it will
>> take a few days since I only have a few hours every day to stuff like this.
>> I will migrate a legacy integration platform from in-house framework to
>> Camel so I will finally get to spend a lot more time to get familiar with
>> the details of Camel.
>>
>> Anyway, not sure how to patch it.
>>
>> The problem occurs only when separator is considered a whitespace
>> character.
>> Could be tested via Character.isWhitespace(separator)
>> The other way around is to remove the trim(), I don't see the point in
>> trimming the read line, but then I could jeopardize working code.
>> Or maybe only trim if Character.isWhitespace(separator) == false?
>>
>> Perhaps such questions is better placed on the dev-list (not subscribing
>> to that one yet)?
>>
>> Kind regards, Magnus
>>
>>
>> Den 31 mars 2012 12:05 skrev Claus Ibsen <claus.ib...@gmail.com>:
>>
>> 2012/3/29 Magnus Palmér <magnus.palmer.w...@gmail.com>:
>>> > 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
>>> >
>>> >  138               // Read the line
>>> >  139              String line = 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 <ai.d...@gmail.com>:
>>> >
>>> >> 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
>>> trouble.
>>> >> The "required=false" option is working for me always except in one
>>> case.
>>> >>
>>> >> This case is when the two missing fields occur at the end of a line
>>> at the
>>> >> 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)
>>> >>      .unmarshal().bindy(BindyType.Csv, "com.mypackage")
>>> >>              .to(URI_END_PROCESS_MOCK);
>>> >>
>>> >>
>>> >> My class (I have only one) in "com.mypackage" has the following
>>> >> annotations:
>>> >> @CsvRecord(separator="\t")
>>> >> from positions 1 to 5: @DataField(pos = N, required = true)
>>> >> for positions 6 and 7 : @DataField(pos = N, required = false)  (so
>>> fields 6
>>> >> and 7 are optional)
>>> >>
>>> >> Test Cases:
>>> >>
>>> >> Case 1: Processing two lines with ALL the fields    (Works like a
>>> charm)
>>> >> String data2Process = "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 = "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 = "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 = "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
>>> were
>>> >> no
>>> >> problems.
>>> >>
>>> >> The exception is the one I said before: "Some fields are missing
>>> (optional
>>> >> 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.
>>> >>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>>> FuseSource
>>> Email: cib...@fusesource.com
>>> Web: http://fusesource.com
>>> Twitter: davsclaus, fusenews
>>> Blog: http://davsclaus.blogspot.com/
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>
>>
>>
>

Reply via email to