i follow <<camel in action>>'s chapter3/order demo, i confused with
following situation:
1) i create simple Pojo class in same package with PurchaseOrder.java
//content as follows:
@CsvRecord(separator = ",", crlf = "UNIX")
public class Person {
@DataField(pos = 1) //because this field's pos ==1, it make
PurchaseOrder.name ==null
private String name2;
public String getName2() {
return name2;
}
public void setName(String name2) {
this.name2 = name2;
}
@Override
public String toString() {
return String.format("%s", name2);
}
}
2)this is my RouteBuilder defination:
public class MainEntry extends CamelTestSupport {
public static class MyBean {
public void convert(Exchange exchange) {
Object object = exchange.getIn().getBody();
//at this point,Object isInstanceOf PurchaseOrder but
object.name ==null
System.out.println("===============");
}
}
@EndpointInject(uri = "mock:end")
protected MockEndpoint toEndpoint;
@Produce(uri = "direct:start")
protected ProducerTemplate template;
@Test
public void test_marshal() throws Exception {
// must set expect before call template.sendBody()
toEndpoint.expectedMessageCount(1);
template.sendBody("Camel in Action,39.95,1");
toEndpoint.assertIsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
// return super.createRouteBuilder();
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal()
.bindy(BindyType.Csv, PurchaseOrder.class)
//use class instead of
package name
.bean(new MyBean())
.to("mock:end");
}
};
}
}
my question is in MyBean.convert method, object.name ==null ?????
3)attachment is my test project.
is it a bug or there is some thing wrong with my code?
how to workaround it?
any answer is appreciate camelbug.zip
<http://camel.465427.n5.nabble.com/file/n5731369/camelbug.zip>
--
View this message in context:
http://camel.465427.n5.nabble.com/when-two-Pojo-class-annotated-with-CsvRecord-in-same-package-camel-goes-wrong-tp5731369.html
Sent from the Camel Development mailing list archive at Nabble.com.