camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aida <ai.d...@gmail.com>
Subject Re: [Bindy] Having trouble with the "required" field
Date Thu, 29 Mar 2012 09:17:38 GMT
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.

Mime
View raw message