You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Charles Moulliard <cm...@gmail.com> on 2009/10/23 11:01:37 UTC
Strange error
I have created a unit test to unmarshal a FIX message into a model
(copy the model into another one) and marshal the result into a CSV
The result received by the mock is null. If I try to read the object,
I have this :
>>> Class : [B
>>> CSV generated : [B@12b19c5
Remark : the FIX message is well transformed into a model of objects
and bindy does not generate any error during the generation of the
outputstream from the model object
public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests {
private static final transient Log LOG =
LogFactory.getLog(VresEmxToCsvTest.class);
@Produce(uri = "direct:start")
private ProducerTemplate template;
@EndpointInject(uri = "mock:result")
private MockEndpoint resultEndpoint;
@Test
@DirtiesContext
public void testEmxtoCsv() throws Exception {
String record =
"8=FIX.4.19=98035=U334=6149=SERVER50=EMXSV52=20091021-14:58:0956=X3S115=AHPRO116=AHPADMIN128=AHINT129=AHIADMIN9426=VRES15=GBP58=TEXT117=first
response131=VAL
Multiple9400=*9442=UT9464=20090910-14:00:009469=Q9477=119488=AHINT9490=AHPRO9494=AGENCY
NO9504=desig29450=39470=122=448=ISINLU8989429=20091013-09:54:459448=2432.454549493=fgfhgfhg9470=222=448=ISINLU8989429=20091013-09:54:459448=2432.454549493=fgfhgfhg9470=322=448=ISINLU8989429=20091013-09:54:459448=2432.454549493=fgfhgfhg9425=20091008-13:11:129452=20091008-13:11:169453=20091008-13:11:169480=1.0~SHA-1~RSA~CN=EMX
Certificate Authority,OU=Certificate Authority,O=EMX Company
Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad949481=20091008-13:11:129491=400318210=190";
String result = "";
template.sendBody(record);
resultEndpoint.expectedMessageCount(1);
// resultEndpoint.expectedBodiesReceived(result);
resultEndpoint.assertIsSatisfied();
for (Exchange exch : resultEndpoint.getExchanges()) {
Object obj = exch.getIn().getBody();
System.out.println(">>> Class : " + obj.getClass().getName());
System.out.println(">>> CSV generated : " + obj.toString());
}
}
/* @Test
@DirtiesContext
public void testUnMarshallWithNullFields() throws Exception {
// TODO add null fields
String record =
"8=FIX.4.19=8935=U234=8449=SERVER52=20090630-10:29:2556=X3S9426=TBKD11=ORDER122=237=WWWWWW48=ISIN2432434354=158=TTT67=168=1121=Y152=33.43173=TTTTTTT174=TTTTTTTTTTT182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG183=HHHHHH184=YYYYYYYYY185=FFFFFFFFFFFFFF9400=TTTTTTTTTTT9401=19402=31.239403=19404=TTT9405=TTT9406=TTT9407=TTT9408=TTT9409=TTT9410=TTT9411=TTT9412=TTT9413=N9414=TTT9415=TTT9416=R9417=USD9418=DEM9419=8.659420=3349422=M9423=Y9424=HJHJKHJKHJ9428=20090303-12:25:559435=200803269436=jhkjkj9437=dddddddddd9438=eeeeeeeeee9439=12099440=AA9441=89442=PROTYP39443=19444=safdewfw9449=fsgsg9451=E9455=EUR9462=59468=?9471=433.4439474=E9475=Y9482=fwrfw9483=KKKKK9484=KLKLKL9485=JKIJKJKJ9488=ORIG19489=JJJJJ9490=PRV039492=kjlklk9494=AGENCY339495=23.189491=TBKD-5776517710=111";
template.sendBody(record);
resultEndpoint.expectedMessageCount(1);
resultEndpoint.assertIsSatisfied();
List<Exchange> exchanges = resultEndpoint.getExchanges();
for(Exchange exchange : exchanges) {
models = (List<Map<String, Object>>) exchange.getIn().getBody();
for (int i=0; i< models.size(); i++) {
model = models.get(i);
OutTbkdMessage tbkd =
(OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
Assert.assertEquals(tbkd.getOrdUntNb(), null);
LOG.debug("Model : " + tbkd.toString());
}
}
}*/
@Configuration
public static class ContextConfig extends SingleRouteCamelConfiguration {
BindyKeyValuePairDataFormat emxBindyDataFormat = new
BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
BindyCsvDataFormat csvBindyDataFormat = new
BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
@Override
@Bean
public RouteBuilder route() {
return new RouteBuilder() {
@Override
public void configure() {
from("direct:start")
.unmarshal(emxBindyDataFormat)
.process(new Processor() {
public void process(Exchange exchange) throws
Exception {
InVresMessage inVresMessage = new InVresMessage();
List<Map<String, Object>> models = new
ArrayList<Map<String, Object>>();
List<Map<String, Object>> modelsReceived;
Map<String, Object> model = new
HashMap<String, Object>();
modelsReceived = (List<Map<String, Object>>) exchange.getIn().getBody();
OutVresMessage outVresMessage = (OutVresMessage)
modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
PropertyUtils.copyProperties(inVresMessage, outVresMessage);
model.put(inVresMessage.getClass().getName(), inVresMessage);
models.add( model );
exchange.getIn().setBody(models);
}
}
)
.marshal(csvBindyDataFormat)
.to("mock:result");
}
};
}
}
}
Regards,
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Re: Strange error
Posted by Charles Moulliard <cm...@gmail.com>.
How can I receive the byte[] from the message ?
I suppose that the following method call will return an object :
resultEndpoint.getExchanges().get(0).getIn().getBody()
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Fri, Oct 23, 2009 at 11:05 AM, Claus Ibsen <cl...@gmail.com> wrote:
> The B[ stuff is Java way of telling its a byte array
>
> Force Camel to test against String etc
>
>> // resultEndpoint.expectedBodiesReceived(result);
>
> Could be
> resultEndpoint.message(0).body(String.class).isEqualTo(result);
>
> I guess we should add that type converter stuff into
> expectedBodiesReceived as well.
>
>
>
> On Fri, Oct 23, 2009 at 11:01 AM, Charles Moulliard
> <cm...@gmail.com> wrote:
>> I have created a unit test to unmarshal a FIX message into a model
>> (copy the model into another one) and marshal the result into a CSV
>>
>> The result received by the mock is null. If I try to read the object,
>> I have this :
>>
>>>>> Class : [B
>>>>> CSV generated : [B@12b19c5
>>
>> Remark : the FIX message is well transformed into a model of objects
>> and bindy does not generate any error during the generation of the
>> outputstream from the model object
>>
>> public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests {
>>
>> private static final transient Log LOG =
>> LogFactory.getLog(VresEmxToCsvTest.class);
>>
>> @Produce(uri = "direct:start")
>> private ProducerTemplate template;
>>
>> @EndpointInject(uri = "mock:result")
>> private MockEndpoint resultEndpoint;
>>
>>
>> @Test
>> @DirtiesContext
>> public void testEmxtoCsv() throws Exception {
>>
>> String record =
>> "8=FIX.4.1 9=980 35=U3 34=61 49=SERVER 50=EMXSV 52=20091021-14:58:09 56=X3S 115=AHPRO 116=AHPADMIN 128=AHINT 129=AHIADMIN 9426=VRES 15=GBP 58=TEXT 117=first
>> response 131=VAL
>> Multiple 9400=* 9442=UT 9464=20090910-14:00:00 9469=Q 9477=11 9488=AHINT 9490=AHPRO 9494=AGENCY
>> NO 9504=desig2 9450=3 9470=1 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=2 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=3 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9425=20091008-13:11:12 9452=20091008-13:11:16 9453=20091008-13:11:16 9480=1.0~SHA-1~RSA~CN=EMX
>> Certificate Authority,OU=Certificate Authority,O=EMX Company
>> Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad94 9481=20091008-13:11:12 9491=4003182 10=190 ";
>> String result = "";
>>
>> template.sendBody(record);
>>
>> resultEndpoint.expectedMessageCount(1);
>> // resultEndpoint.expectedBodiesReceived(result);
>> resultEndpoint.assertIsSatisfied();
>>
>> for (Exchange exch : resultEndpoint.getExchanges()) {
>> Object obj = exch.getIn().getBody();
>> System.out.println(">>> Class : " + obj.getClass().getName());
>> System.out.println(">>> CSV generated : " + obj.toString());
>> }
>>
>>
>>
>>
>> }
>>
>>
>>
>> /* @Test
>> @DirtiesContext
>> public void testUnMarshallWithNullFields() throws Exception {
>>
>> // TODO add null fields
>> String record =
>> "8=FIX.4.1 9=89 35=U2 34=84 49=SERVER 52=20090630-10:29:25 56=X3S 9426=TBKD 11=ORDER1 22=2 37=WWWWWW 48=ISIN24324343 54=1 58=TTT 67=1 68=1 121=Y 152=33.43 173=TTTTTTT 174=TTTTTTTTTTT 182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 183=HHHHHH 184=YYYYYYYYY 185=FFFFFFFFFFFFFF 9400=TTTTTTTTTTT 9401=1 9402=31.23 9403=1 9404=TTT 9405=TTT 9406=TTT 9407=TTT 9408=TTT 9409=TTT 9410=TTT 9411=TTT 9412=TTT 9413=N 9414=TTT 9415=TTT 9416=R 9417=USD 9418=DEM 9419=8.65 9420=334 9422=M 9423=Y 9424=HJHJKHJKHJ 9428=20090303-12:25:55 9435=20080326 9436=jhkjkj 9437=dddddddddd 9438=eeeeeeeeee 9439=1209 9440=AA 9441=8 9442=PROTYP3 9443=1 9444=safdewfw 9449=fsgsg 9451=E 9455=EUR 9462=5 9468=? 9471=433.443 9474=E 9475=Y 9482=fwrfw 9483=KKKKK 9484=KLKLKL 9485=JKIJKJKJ 9488=ORIG1 9489=JJJJJ 9490=PRV03 9492=kjlklk 9494=AGENCY33 9495=23.18 9491=TBKD-57765177 10=111 ";
>>
>> template.sendBody(record);
>>
>> resultEndpoint.expectedMessageCount(1);
>> resultEndpoint.assertIsSatisfied();
>>
>> List<Exchange> exchanges = resultEndpoint.getExchanges();
>>
>> for(Exchange exchange : exchanges) {
>>
>> models = (List<Map<String, Object>>) exchange.getIn().getBody();
>>
>> for (int i=0; i< models.size(); i++) {
>> model = models.get(i);
>> OutTbkdMessage tbkd =
>> (OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
>> Assert.assertEquals(tbkd.getOrdUntNb(), null);
>> LOG.debug("Model : " + tbkd.toString());
>> }
>>
>>
>> }
>> }*/
>>
>> @Configuration
>> public static class ContextConfig extends SingleRouteCamelConfiguration {
>> BindyKeyValuePairDataFormat emxBindyDataFormat = new
>> BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
>> BindyCsvDataFormat csvBindyDataFormat = new
>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>
>> @Override
>> @Bean
>> public RouteBuilder route() {
>> return new RouteBuilder() {
>> @Override
>> public void configure() {
>> from("direct:start")
>> .unmarshal(emxBindyDataFormat)
>> .process(new Processor() {
>>
>> public void process(Exchange exchange) throws
>> Exception {
>>
>> InVresMessage inVresMessage = new InVresMessage();
>> List<Map<String, Object>> models = new
>> ArrayList<Map<String, Object>>();
>> List<Map<String, Object>> modelsReceived;
>> Map<String, Object> model = new
>> HashMap<String, Object>();
>>
>> modelsReceived = (List<Map<String, Object>>) exchange.getIn().getBody();
>> OutVresMessage outVresMessage = (OutVresMessage)
>> modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
>>
>> PropertyUtils.copyProperties(inVresMessage, outVresMessage);
>> model.put(inVresMessage.getClass().getName(), inVresMessage);
>> models.add( model );
>>
>> exchange.getIn().setBody(models);
>> }
>> }
>>
>> )
>> .marshal(csvBindyDataFormat)
>> .to("mock:result");
>> }
>> };
>> }
>> }
>>
>> }
>>
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Re: Strange error
Posted by Charles Moulliard <cm...@gmail.com>.
Yes. Everything works fine except that endpoint receives null.
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Fri, Oct 23, 2009 at 12:40 PM, Willem Jiang <wi...@gmail.com> wrote:
> I don't know why the resultEndpoint can't receive any message.
>
> chris, are you using spring configuration.
> Can you check if the resultEndpoint is injected rightly?
>
> Willem
>
> Claus Ibsen wrote:
>>
>> The B[ stuff is Java way of telling its a byte array
>>
>> Force Camel to test against String etc
>>
>>> // resultEndpoint.expectedBodiesReceived(result);
>>
>> Could be
>> resultEndpoint.message(0).body(String.class).isEqualTo(result);
>>
>> I guess we should add that type converter stuff into
>> expectedBodiesReceived as well.
>>
>>
>>
>> On Fri, Oct 23, 2009 at 11:01 AM, Charles Moulliard
>> <cm...@gmail.com> wrote:
>>>
>>> I have created a unit test to unmarshal a FIX message into a model
>>> (copy the model into another one) and marshal the result into a CSV
>>>
>>> The result received by the mock is null. If I try to read the object,
>>> I have this :
>>>
>>>>>> Class : [B
>>>>>> CSV generated : [B@12b19c5
>>>
>>> Remark : the FIX message is well transformed into a model of objects
>>> and bindy does not generate any error during the generation of the
>>> outputstream from the model object
>>>
>>> public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests {
>>>
>>> private static final transient Log LOG =
>>> LogFactory.getLog(VresEmxToCsvTest.class);
>>>
>>> @Produce(uri = "direct:start")
>>> private ProducerTemplate template;
>>>
>>> @EndpointInject(uri = "mock:result")
>>> private MockEndpoint resultEndpoint;
>>>
>>>
>>> @Test
>>> @DirtiesContext
>>> public void testEmxtoCsv() throws Exception {
>>>
>>> String record =
>>> "8=FIX.4.1 9=980 35=U3 34=61 49=SERVER 50=EMXSV 52=20091021-14:58:09
>>> 56=X3S 115=AHPRO 116=AHPADMIN 128=AHINT 129=AHIADMIN 9426=VRES 15=GBP
>>> 58=TEXT 117=first
>>> response 131=VAL
>>> Multiple 9400=* 9442=UT 9464=20090910-14:00:00 9469=Q 9477=11 9488=AHINT
>>> 9490=AHPRO 9494=AGENCY
>>> NO 9504=desig2 9450=3 9470=1 22=4 48=ISINLU898 9429=20091013-09:54:45
>>> 9448=2432.45454 9493=fgfhgfhg 9470=2 22=4 48=ISINLU898
>>> 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=3 22=4
>>> 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg
>>> 9425=20091008-13:11:12 9452=20091008-13:11:16 9453=20091008-13:11:16
>>> 9480=1.0~SHA-1~RSA~CN=EMX
>>> Certificate Authority,OU=Certificate Authority,O=EMX Company
>>>
>>> Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad94
>>> 9481=20091008-13:11:12 9491=4003182 10=190 ";
>>> String result = "";
>>>
>>> template.sendBody(record);
>>>
>>> resultEndpoint.expectedMessageCount(1);
>>> // resultEndpoint.expectedBodiesReceived(result);
>>> resultEndpoint.assertIsSatisfied();
>>>
>>> for (Exchange exch : resultEndpoint.getExchanges()) {
>>> Object obj = exch.getIn().getBody();
>>> System.out.println(">>> Class : " + obj.getClass().getName());
>>> System.out.println(">>> CSV generated : " + obj.toString());
>>> }
>>>
>>>
>>>
>>>
>>> }
>>>
>>>
>>>
>>> /* @Test
>>> @DirtiesContext
>>> public void testUnMarshallWithNullFields() throws Exception {
>>>
>>> // TODO add null fields
>>> String record =
>>> "8=FIX.4.1 9=89 35=U2 34=84 49=SERVER 52=20090630-10:29:25 56=X3S
>>> 9426=TBKD 11=ORDER1 22=2 37=WWWWWW 48=ISIN24324343 54=1 58=TTT 67=1 68=1
>>> 121=Y 152=33.43 173=TTTTTTT 174=TTTTTTTTTTT
>>> 182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 183=HHHHHH
>>> 184=YYYYYYYYY 185=FFFFFFFFFFFFFF 9400=TTTTTTTTTTT 9401=1 9402=31.23 9403=1
>>> 9404=TTT 9405=TTT 9406=TTT 9407=TTT 9408=TTT 9409=TTT 9410=TTT 9411=TTT
>>> 9412=TTT 9413=N 9414=TTT 9415=TTT 9416=R 9417=USD 9418=DEM 9419=8.65
>>> 9420=334 9422=M 9423=Y 9424=HJHJKHJKHJ 9428=20090303-12:25:55 9435=20080326
>>> 9436=jhkjkj 9437=dddddddddd 9438=eeeeeeeeee 9439=1209 9440=AA 9441=8
>>> 9442=PROTYP3 9443=1 9444=safdewfw 9449=fsgsg 9451=E 9455=EUR 9462=5 9468=?
>>> 9471=433.443 9474=E 9475=Y 9482=fwrfw 9483=KKKKK 9484=KLKLKL 9485=JKIJKJKJ
>>> 9488=ORIG1 9489=JJJJJ 9490=PRV03 9492=kjlklk 9494=AGENCY33 9495=23.18
>>> 9491=TBKD-57765177 10=111 ";
>>>
>>> template.sendBody(record);
>>>
>>> resultEndpoint.expectedMessageCount(1);
>>> resultEndpoint.assertIsSatisfied();
>>>
>>> List<Exchange> exchanges = resultEndpoint.getExchanges();
>>>
>>> for(Exchange exchange : exchanges) {
>>>
>>> models = (List<Map<String, Object>>) exchange.getIn().getBody();
>>>
>>> for (int i=0; i< models.size(); i++) {
>>> model = models.get(i);
>>> OutTbkdMessage tbkd =
>>>
>>> (OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
>>> Assert.assertEquals(tbkd.getOrdUntNb(), null);
>>> LOG.debug("Model : " + tbkd.toString());
>>> }
>>>
>>>
>>> }
>>> }*/
>>>
>>> @Configuration
>>> public static class ContextConfig extends SingleRouteCamelConfiguration
>>> {
>>> BindyKeyValuePairDataFormat emxBindyDataFormat = new
>>>
>>> BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
>>> BindyCsvDataFormat csvBindyDataFormat = new
>>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>>
>>> @Override
>>> @Bean
>>> public RouteBuilder route() {
>>> return new RouteBuilder() {
>>> @Override
>>> public void configure() {
>>> from("direct:start")
>>> .unmarshal(emxBindyDataFormat)
>>> .process(new Processor() {
>>>
>>> public void process(Exchange exchange) throws
>>> Exception {
>>>
>>> InVresMessage
>>> inVresMessage = new InVresMessage();
>>> List<Map<String, Object>> models = new
>>> ArrayList<Map<String, Object>>();
>>> List<Map<String, Object>> modelsReceived;
>>> Map<String, Object> model = new
>>> HashMap<String, Object>();
>>>
>>> modelsReceived =
>>> (List<Map<String, Object>>) exchange.getIn().getBody();
>>> OutVresMessage
>>> outVresMessage = (OutVresMessage)
>>>
>>> modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
>>>
>>>
>>> PropertyUtils.copyProperties(inVresMessage, outVresMessage);
>>>
>>> model.put(inVresMessage.getClass().getName(), inVresMessage);
>>> models.add( model
>>> );
>>>
>>>
>>> exchange.getIn().setBody(models);
>>> }
>>> }
>>>
>>> )
>>> .marshal(csvBindyDataFormat)
>>> .to("mock:result");
>>> }
>>> };
>>> }
>>> }
>>>
>>> }
>>>
>>>
>>> Regards,
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>> twitter : http://twitter.com/cmoulliard
>>>
>>
>>
>>
>
>
Re: Strange error
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Oct 23, 2009 at 1:56 PM, Willem Jiang <wi...@gmail.com> wrote:
> Oh, it's a typical mock API usage.
> You need to set up the mock behavior (assertion) before doing the actual
> invocation.
> Then call the verification to check the assertion.
>
Yeah read chapter 5 in Camel in action again :)
> Willem
>
>
> Charles Moulliard wrote:
>>
>> I have found the reason : the line
>> "template.sendBody(Model.generateModel(
>> EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );"
>>
>> must be put after "resultEndpoint.expectedBodiesReceived( expected );"
>>
>> Why : I DON'T KNOW
>>
>> @Test
>> @DirtiesContext
>> public void testModeltoCsv() throws Exception {
>>
>> resultEndpoint.expectedMessageCount(1);
>> resultEndpoint.expectedBodiesReceived( expected );
>> template.sendBody(Model.generateModel(
>> EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );
>>
>> resultEndpoint.assertIsSatisfied();
>> }
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>>
>>
>> On Fri, Oct 23, 2009 at 1:16 PM, Charles Moulliard <cm...@gmail.com>
>> wrote:
>>>
>>> I have also this issue with the following test (the code is based on
>>> what I have done in camel-bindy where there are 25 unit tests like
>>> this one) :
>>>
>>> @Test
>>> @DirtiesContext
>>> public void testModeltoCsv() throws Exception {
>>>
>>> template.sendBody(Model.generateModel(
>>> EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );
>>>
>>> resultEndpoint.expectedMessageCount(1);
>>> resultEndpoint.expectedBodiesReceived( expected );
>>>
>>> resultEndpoint.assertIsSatisfied();
>>> }
>>>
>>> @Configuration
>>> public static class ContextConfig extends SingleRouteCamelConfiguration
>>> {
>>>
>>> BindyCsvDataFormat csvBindyDataFormat = new
>>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>>
>>> @Override
>>> @Bean
>>> public RouteBuilder route() {
>>> return new RouteBuilder() {
>>> @Override
>>> public void configure() {
>>> from("direct:start")
>>> .marshal(csvBindyDataFormat)
>>> .to("mock:result");
>>> }
>>> };
>>> }
>>> }
>>>
>>>
>>> FYI, the result generated by marshal method of camel-bindy is not null :
>>>
>>> for (Map<String, Object> model : models) {
>>>
>>> String result = factory.unbind(model);
>>> LOG.info(">>>> String generated : " + result); // CONTENT
>>> OF STRING IS NOT NULL
>>> byte[] bytes =
>>> exchange.getContext().getTypeConverter().convertTo(byte[].class,
>>> exchange, result);
>>> outputStream.write(bytes);
>>>
>>> // Add a carriage return
>>> outputStream.write(bytesCRLF);
>>> }
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>> twitter : http://twitter.com/cmoulliard
>>>
>>>
>>>
>>> On Fri, Oct 23, 2009 at 12:40 PM, Willem Jiang <wi...@gmail.com>
>>> wrote:
>>>>
>>>> I don't know why the resultEndpoint can't receive any message.
>>>>
>>>> chris, are you using spring configuration.
>>>> Can you check if the resultEndpoint is injected rightly?
>>>>
>>>> Willem
>>>>
>>>> Claus Ibsen wrote:
>>>>>
>>>>> The B[ stuff is Java way of telling its a byte array
>>>>>
>>>>> Force Camel to test against String etc
>>>>>
>>>>>> // resultEndpoint.expectedBodiesReceived(result);
>>>>>
>>>>> Could be
>>>>> resultEndpoint.message(0).body(String.class).isEqualTo(result);
>>>>>
>>>>> I guess we should add that type converter stuff into
>>>>> expectedBodiesReceived as well.
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Oct 23, 2009 at 11:01 AM, Charles Moulliard
>>>>> <cm...@gmail.com> wrote:
>>>>>>
>>>>>> I have created a unit test to unmarshal a FIX message into a model
>>>>>> (copy the model into another one) and marshal the result into a CSV
>>>>>>
>>>>>> The result received by the mock is null. If I try to read the object,
>>>>>> I have this :
>>>>>>
>>>>>>>>> Class : [B
>>>>>>>>> CSV generated : [B@12b19c5
>>>>>>
>>>>>> Remark : the FIX message is well transformed into a model of objects
>>>>>> and bindy does not generate any error during the generation of the
>>>>>> outputstream from the model object
>>>>>>
>>>>>> public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests
>>>>>> {
>>>>>>
>>>>>> private static final transient Log LOG =
>>>>>> LogFactory.getLog(VresEmxToCsvTest.class);
>>>>>>
>>>>>> @Produce(uri = "direct:start")
>>>>>> private ProducerTemplate template;
>>>>>>
>>>>>> @EndpointInject(uri = "mock:result")
>>>>>> private MockEndpoint resultEndpoint;
>>>>>>
>>>>>>
>>>>>> @Test
>>>>>> @DirtiesContext
>>>>>> public void testEmxtoCsv() throws Exception {
>>>>>>
>>>>>> String record =
>>>>>> "8=FIX.4.1 9=980 35=U3 34=61 49=SERVER 50=EMXSV 52=20091021-14:58:09
>>>>>> 56=X3S 115=AHPRO 116=AHPADMIN 128=AHINT 129=AHIADMIN 9426=VRES 15=GBP
>>>>>> 58=TEXT 117=first
>>>>>> response 131=VAL
>>>>>> Multiple 9400=* 9442=UT 9464=20090910-14:00:00 9469=Q 9477=11
>>>>>> 9488=AHINT
>>>>>> 9490=AHPRO 9494=AGENCY
>>>>>> NO 9504=desig2 9450=3 9470=1 22=4 48=ISINLU898 9429=20091013-09:54:45
>>>>>> 9448=2432.45454 9493=fgfhgfhg 9470=2 22=4 48=ISINLU898
>>>>>> 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=3 22=4
>>>>>> 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg
>>>>>> 9425=20091008-13:11:12 9452=20091008-13:11:16 9453=20091008-13:11:16
>>>>>> 9480=1.0~SHA-1~RSA~CN=EMX
>>>>>> Certificate Authority,OU=Certificate Authority,O=EMX Company
>>>>>>
>>>>>>
>>>>>> Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad94
>>>>>> 9481=20091008-13:11:12 9491=4003182 10=190 ";
>>>>>> String result = "";
>>>>>>
>>>>>> template.sendBody(record);
>>>>>>
>>>>>> resultEndpoint.expectedMessageCount(1);
>>>>>> // resultEndpoint.expectedBodiesReceived(result);
>>>>>> resultEndpoint.assertIsSatisfied();
>>>>>>
>>>>>> for (Exchange exch : resultEndpoint.getExchanges()) {
>>>>>> Object obj = exch.getIn().getBody();
>>>>>> System.out.println(">>> Class : " +
>>>>>> obj.getClass().getName());
>>>>>> System.out.println(">>> CSV generated : " + obj.toString());
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> /* @Test
>>>>>> @DirtiesContext
>>>>>> public void testUnMarshallWithNullFields() throws Exception {
>>>>>>
>>>>>> // TODO add null fields
>>>>>> String record =
>>>>>> "8=FIX.4.1 9=89 35=U2 34=84 49=SERVER 52=20090630-10:29:25 56=X3S
>>>>>> 9426=TBKD 11=ORDER1 22=2 37=WWWWWW 48=ISIN24324343 54=1 58=TTT 67=1
>>>>>> 68=1
>>>>>> 121=Y 152=33.43 173=TTTTTTT 174=TTTTTTTTTTT
>>>>>> 182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 183=HHHHHH
>>>>>> 184=YYYYYYYYY 185=FFFFFFFFFFFFFF 9400=TTTTTTTTTTT 9401=1 9402=31.23
>>>>>> 9403=1
>>>>>> 9404=TTT 9405=TTT 9406=TTT 9407=TTT 9408=TTT 9409=TTT 9410=TTT
>>>>>> 9411=TTT
>>>>>> 9412=TTT 9413=N 9414=TTT 9415=TTT 9416=R 9417=USD 9418=DEM 9419=8.65
>>>>>> 9420=334 9422=M 9423=Y 9424=HJHJKHJKHJ 9428=20090303-12:25:55
>>>>>> 9435=20080326
>>>>>> 9436=jhkjkj 9437=dddddddddd 9438=eeeeeeeeee 9439=1209 9440=AA 9441=8
>>>>>> 9442=PROTYP3 9443=1 9444=safdewfw 9449=fsgsg 9451=E 9455=EUR 9462=5
>>>>>> 9468=?
>>>>>> 9471=433.443 9474=E 9475=Y 9482=fwrfw 9483=KKKKK 9484=KLKLKL
>>>>>> 9485=JKIJKJKJ
>>>>>> 9488=ORIG1 9489=JJJJJ 9490=PRV03 9492=kjlklk 9494=AGENCY33 9495=23.18
>>>>>> 9491=TBKD-57765177 10=111 ";
>>>>>>
>>>>>> template.sendBody(record);
>>>>>>
>>>>>> resultEndpoint.expectedMessageCount(1);
>>>>>> resultEndpoint.assertIsSatisfied();
>>>>>>
>>>>>> List<Exchange> exchanges = resultEndpoint.getExchanges();
>>>>>>
>>>>>> for(Exchange exchange : exchanges) {
>>>>>>
>>>>>> models = (List<Map<String, Object>>)
>>>>>> exchange.getIn().getBody();
>>>>>>
>>>>>> for (int i=0; i< models.size(); i++) {
>>>>>> model = models.get(i);
>>>>>> OutTbkdMessage tbkd =
>>>>>>
>>>>>>
>>>>>> (OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
>>>>>> Assert.assertEquals(tbkd.getOrdUntNb(), null);
>>>>>> LOG.debug("Model : " + tbkd.toString());
>>>>>> }
>>>>>>
>>>>>>
>>>>>> }
>>>>>> }*/
>>>>>>
>>>>>> @Configuration
>>>>>> public static class ContextConfig extends
>>>>>> SingleRouteCamelConfiguration
>>>>>> {
>>>>>> BindyKeyValuePairDataFormat emxBindyDataFormat = new
>>>>>>
>>>>>>
>>>>>> BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
>>>>>> BindyCsvDataFormat csvBindyDataFormat = new
>>>>>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>>>>>
>>>>>> @Override
>>>>>> @Bean
>>>>>> public RouteBuilder route() {
>>>>>> return new RouteBuilder() {
>>>>>> @Override
>>>>>> public void configure() {
>>>>>> from("direct:start")
>>>>>> .unmarshal(emxBindyDataFormat)
>>>>>> .process(new Processor() {
>>>>>>
>>>>>> public void process(Exchange exchange) throws
>>>>>> Exception {
>>>>>>
>>>>>> InVresMessage
>>>>>> inVresMessage = new InVresMessage();
>>>>>> List<Map<String, Object>> models = new
>>>>>> ArrayList<Map<String, Object>>();
>>>>>> List<Map<String, Object>> modelsReceived;
>>>>>> Map<String, Object> model = new
>>>>>> HashMap<String, Object>();
>>>>>>
>>>>>> modelsReceived =
>>>>>> (List<Map<String, Object>>) exchange.getIn().getBody();
>>>>>> OutVresMessage
>>>>>> outVresMessage = (OutVresMessage)
>>>>>>
>>>>>>
>>>>>> modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
>>>>>>
>>>>>>
>>>>>> PropertyUtils.copyProperties(inVresMessage, outVresMessage);
>>>>>>
>>>>>> model.put(inVresMessage.getClass().getName(), inVresMessage);
>>>>>> models.add( model
>>>>>> );
>>>>>>
>>>>>>
>>>>>> exchange.getIn().setBody(models);
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> )
>>>>>> .marshal(csvBindyDataFormat)
>>>>>> .to("mock:result");
>>>>>> }
>>>>>> };
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Charles Moulliard
>>>>>> Senior Enterprise Architect
>>>>>> Apache Camel Committer
>>>>>>
>>>>>> *****************************
>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>> twitter : http://twitter.com/cmoulliard
>>>>>>
>>>>>
>>>>>
>>>>
>>
>
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Strange error
Posted by Willem Jiang <wi...@gmail.com>.
Oh, it's a typical mock API usage.
You need to set up the mock behavior (assertion) before doing the actual
invocation.
Then call the verification to check the assertion.
Willem
Charles Moulliard wrote:
> I have found the reason : the line
> "template.sendBody(Model.generateModel(
> EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );"
>
> must be put after "resultEndpoint.expectedBodiesReceived( expected );"
>
> Why : I DON'T KNOW
>
> @Test
> @DirtiesContext
> public void testModeltoCsv() throws Exception {
>
> resultEndpoint.expectedMessageCount(1);
> resultEndpoint.expectedBodiesReceived( expected );
> template.sendBody(Model.generateModel(
> EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );
>
> resultEndpoint.assertIsSatisfied();
> }
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
>
>
>
> On Fri, Oct 23, 2009 at 1:16 PM, Charles Moulliard <cm...@gmail.com> wrote:
>> I have also this issue with the following test (the code is based on
>> what I have done in camel-bindy where there are 25 unit tests like
>> this one) :
>>
>> @Test
>> @DirtiesContext
>> public void testModeltoCsv() throws Exception {
>>
>> template.sendBody(Model.generateModel(
>> EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );
>>
>> resultEndpoint.expectedMessageCount(1);
>> resultEndpoint.expectedBodiesReceived( expected );
>>
>> resultEndpoint.assertIsSatisfied();
>> }
>>
>> @Configuration
>> public static class ContextConfig extends SingleRouteCamelConfiguration {
>>
>> BindyCsvDataFormat csvBindyDataFormat = new
>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>
>> @Override
>> @Bean
>> public RouteBuilder route() {
>> return new RouteBuilder() {
>> @Override
>> public void configure() {
>> from("direct:start")
>> .marshal(csvBindyDataFormat)
>> .to("mock:result");
>> }
>> };
>> }
>> }
>>
>>
>> FYI, the result generated by marshal method of camel-bindy is not null :
>>
>> for (Map<String, Object> model : models) {
>>
>> String result = factory.unbind(model);
>> LOG.info(">>>> String generated : " + result); // CONTENT
>> OF STRING IS NOT NULL
>> byte[] bytes =
>> exchange.getContext().getTypeConverter().convertTo(byte[].class,
>> exchange, result);
>> outputStream.write(bytes);
>>
>> // Add a carriage return
>> outputStream.write(bytesCRLF);
>> }
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>>
>>
>> On Fri, Oct 23, 2009 at 12:40 PM, Willem Jiang <wi...@gmail.com> wrote:
>>> I don't know why the resultEndpoint can't receive any message.
>>>
>>> chris, are you using spring configuration.
>>> Can you check if the resultEndpoint is injected rightly?
>>>
>>> Willem
>>>
>>> Claus Ibsen wrote:
>>>> The B[ stuff is Java way of telling its a byte array
>>>>
>>>> Force Camel to test against String etc
>>>>
>>>>> // resultEndpoint.expectedBodiesReceived(result);
>>>> Could be
>>>> resultEndpoint.message(0).body(String.class).isEqualTo(result);
>>>>
>>>> I guess we should add that type converter stuff into
>>>> expectedBodiesReceived as well.
>>>>
>>>>
>>>>
>>>> On Fri, Oct 23, 2009 at 11:01 AM, Charles Moulliard
>>>> <cm...@gmail.com> wrote:
>>>>> I have created a unit test to unmarshal a FIX message into a model
>>>>> (copy the model into another one) and marshal the result into a CSV
>>>>>
>>>>> The result received by the mock is null. If I try to read the object,
>>>>> I have this :
>>>>>
>>>>>>>> Class : [B
>>>>>>>> CSV generated : [B@12b19c5
>>>>> Remark : the FIX message is well transformed into a model of objects
>>>>> and bindy does not generate any error during the generation of the
>>>>> outputstream from the model object
>>>>>
>>>>> public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests {
>>>>>
>>>>> private static final transient Log LOG =
>>>>> LogFactory.getLog(VresEmxToCsvTest.class);
>>>>>
>>>>> @Produce(uri = "direct:start")
>>>>> private ProducerTemplate template;
>>>>>
>>>>> @EndpointInject(uri = "mock:result")
>>>>> private MockEndpoint resultEndpoint;
>>>>>
>>>>>
>>>>> @Test
>>>>> @DirtiesContext
>>>>> public void testEmxtoCsv() throws Exception {
>>>>>
>>>>> String record =
>>>>> "8=FIX.4.1 9=980 35=U3 34=61 49=SERVER 50=EMXSV 52=20091021-14:58:09
>>>>> 56=X3S 115=AHPRO 116=AHPADMIN 128=AHINT 129=AHIADMIN 9426=VRES 15=GBP
>>>>> 58=TEXT 117=first
>>>>> response 131=VAL
>>>>> Multiple 9400=* 9442=UT 9464=20090910-14:00:00 9469=Q 9477=11 9488=AHINT
>>>>> 9490=AHPRO 9494=AGENCY
>>>>> NO 9504=desig2 9450=3 9470=1 22=4 48=ISINLU898 9429=20091013-09:54:45
>>>>> 9448=2432.45454 9493=fgfhgfhg 9470=2 22=4 48=ISINLU898
>>>>> 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=3 22=4
>>>>> 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg
>>>>> 9425=20091008-13:11:12 9452=20091008-13:11:16 9453=20091008-13:11:16
>>>>> 9480=1.0~SHA-1~RSA~CN=EMX
>>>>> Certificate Authority,OU=Certificate Authority,O=EMX Company
>>>>>
>>>>> Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad94
>>>>> 9481=20091008-13:11:12 9491=4003182 10=190 ";
>>>>> String result = "";
>>>>>
>>>>> template.sendBody(record);
>>>>>
>>>>> resultEndpoint.expectedMessageCount(1);
>>>>> // resultEndpoint.expectedBodiesReceived(result);
>>>>> resultEndpoint.assertIsSatisfied();
>>>>>
>>>>> for (Exchange exch : resultEndpoint.getExchanges()) {
>>>>> Object obj = exch.getIn().getBody();
>>>>> System.out.println(">>> Class : " + obj.getClass().getName());
>>>>> System.out.println(">>> CSV generated : " + obj.toString());
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> /* @Test
>>>>> @DirtiesContext
>>>>> public void testUnMarshallWithNullFields() throws Exception {
>>>>>
>>>>> // TODO add null fields
>>>>> String record =
>>>>> "8=FIX.4.1 9=89 35=U2 34=84 49=SERVER 52=20090630-10:29:25 56=X3S
>>>>> 9426=TBKD 11=ORDER1 22=2 37=WWWWWW 48=ISIN24324343 54=1 58=TTT 67=1 68=1
>>>>> 121=Y 152=33.43 173=TTTTTTT 174=TTTTTTTTTTT
>>>>> 182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 183=HHHHHH
>>>>> 184=YYYYYYYYY 185=FFFFFFFFFFFFFF 9400=TTTTTTTTTTT 9401=1 9402=31.23 9403=1
>>>>> 9404=TTT 9405=TTT 9406=TTT 9407=TTT 9408=TTT 9409=TTT 9410=TTT 9411=TTT
>>>>> 9412=TTT 9413=N 9414=TTT 9415=TTT 9416=R 9417=USD 9418=DEM 9419=8.65
>>>>> 9420=334 9422=M 9423=Y 9424=HJHJKHJKHJ 9428=20090303-12:25:55 9435=20080326
>>>>> 9436=jhkjkj 9437=dddddddddd 9438=eeeeeeeeee 9439=1209 9440=AA 9441=8
>>>>> 9442=PROTYP3 9443=1 9444=safdewfw 9449=fsgsg 9451=E 9455=EUR 9462=5 9468=?
>>>>> 9471=433.443 9474=E 9475=Y 9482=fwrfw 9483=KKKKK 9484=KLKLKL 9485=JKIJKJKJ
>>>>> 9488=ORIG1 9489=JJJJJ 9490=PRV03 9492=kjlklk 9494=AGENCY33 9495=23.18
>>>>> 9491=TBKD-57765177 10=111 ";
>>>>>
>>>>> template.sendBody(record);
>>>>>
>>>>> resultEndpoint.expectedMessageCount(1);
>>>>> resultEndpoint.assertIsSatisfied();
>>>>>
>>>>> List<Exchange> exchanges = resultEndpoint.getExchanges();
>>>>>
>>>>> for(Exchange exchange : exchanges) {
>>>>>
>>>>> models = (List<Map<String, Object>>) exchange.getIn().getBody();
>>>>>
>>>>> for (int i=0; i< models.size(); i++) {
>>>>> model = models.get(i);
>>>>> OutTbkdMessage tbkd =
>>>>>
>>>>> (OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
>>>>> Assert.assertEquals(tbkd.getOrdUntNb(), null);
>>>>> LOG.debug("Model : " + tbkd.toString());
>>>>> }
>>>>>
>>>>>
>>>>> }
>>>>> }*/
>>>>>
>>>>> @Configuration
>>>>> public static class ContextConfig extends SingleRouteCamelConfiguration
>>>>> {
>>>>> BindyKeyValuePairDataFormat emxBindyDataFormat = new
>>>>>
>>>>> BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
>>>>> BindyCsvDataFormat csvBindyDataFormat = new
>>>>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>>>>
>>>>> @Override
>>>>> @Bean
>>>>> public RouteBuilder route() {
>>>>> return new RouteBuilder() {
>>>>> @Override
>>>>> public void configure() {
>>>>> from("direct:start")
>>>>> .unmarshal(emxBindyDataFormat)
>>>>> .process(new Processor() {
>>>>>
>>>>> public void process(Exchange exchange) throws
>>>>> Exception {
>>>>>
>>>>> InVresMessage
>>>>> inVresMessage = new InVresMessage();
>>>>> List<Map<String, Object>> models = new
>>>>> ArrayList<Map<String, Object>>();
>>>>> List<Map<String, Object>> modelsReceived;
>>>>> Map<String, Object> model = new
>>>>> HashMap<String, Object>();
>>>>>
>>>>> modelsReceived =
>>>>> (List<Map<String, Object>>) exchange.getIn().getBody();
>>>>> OutVresMessage
>>>>> outVresMessage = (OutVresMessage)
>>>>>
>>>>> modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
>>>>>
>>>>>
>>>>> PropertyUtils.copyProperties(inVresMessage, outVresMessage);
>>>>>
>>>>> model.put(inVresMessage.getClass().getName(), inVresMessage);
>>>>> models.add( model
>>>>> );
>>>>>
>>>>>
>>>>> exchange.getIn().setBody(models);
>>>>> }
>>>>> }
>>>>>
>>>>> )
>>>>> .marshal(csvBindyDataFormat)
>>>>> .to("mock:result");
>>>>> }
>>>>> };
>>>>> }
>>>>> }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> Regards,
>>>>>
>>>>> Charles Moulliard
>>>>> Senior Enterprise Architect
>>>>> Apache Camel Committer
>>>>>
>>>>> *****************************
>>>>> blog : http://cmoulliard.blogspot.com
>>>>> twitter : http://twitter.com/cmoulliard
>>>>>
>>>>
>>>>
>>>
>
Re: Strange error
Posted by Charles Moulliard <cm...@gmail.com>.
I have found the reason : the line
"template.sendBody(Model.generateModel(
EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );"
must be put after "resultEndpoint.expectedBodiesReceived( expected );"
Why : I DON'T KNOW
@Test
@DirtiesContext
public void testModeltoCsv() throws Exception {
resultEndpoint.expectedMessageCount(1);
resultEndpoint.expectedBodiesReceived( expected );
template.sendBody(Model.generateModel(
EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );
resultEndpoint.assertIsSatisfied();
}
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Fri, Oct 23, 2009 at 1:16 PM, Charles Moulliard <cm...@gmail.com> wrote:
> I have also this issue with the following test (the code is based on
> what I have done in camel-bindy where there are 25 unit tests like
> this one) :
>
> @Test
> @DirtiesContext
> public void testModeltoCsv() throws Exception {
>
> template.sendBody(Model.generateModel(
> EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );
>
> resultEndpoint.expectedMessageCount(1);
> resultEndpoint.expectedBodiesReceived( expected );
>
> resultEndpoint.assertIsSatisfied();
> }
>
> @Configuration
> public static class ContextConfig extends SingleRouteCamelConfiguration {
>
> BindyCsvDataFormat csvBindyDataFormat = new
> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>
> @Override
> @Bean
> public RouteBuilder route() {
> return new RouteBuilder() {
> @Override
> public void configure() {
> from("direct:start")
> .marshal(csvBindyDataFormat)
> .to("mock:result");
> }
> };
> }
> }
>
>
> FYI, the result generated by marshal method of camel-bindy is not null :
>
> for (Map<String, Object> model : models) {
>
> String result = factory.unbind(model);
> LOG.info(">>>> String generated : " + result); // CONTENT
> OF STRING IS NOT NULL
> byte[] bytes =
> exchange.getContext().getTypeConverter().convertTo(byte[].class,
> exchange, result);
> outputStream.write(bytes);
>
> // Add a carriage return
> outputStream.write(bytesCRLF);
> }
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
>
>
>
> On Fri, Oct 23, 2009 at 12:40 PM, Willem Jiang <wi...@gmail.com> wrote:
>> I don't know why the resultEndpoint can't receive any message.
>>
>> chris, are you using spring configuration.
>> Can you check if the resultEndpoint is injected rightly?
>>
>> Willem
>>
>> Claus Ibsen wrote:
>>>
>>> The B[ stuff is Java way of telling its a byte array
>>>
>>> Force Camel to test against String etc
>>>
>>>> // resultEndpoint.expectedBodiesReceived(result);
>>>
>>> Could be
>>> resultEndpoint.message(0).body(String.class).isEqualTo(result);
>>>
>>> I guess we should add that type converter stuff into
>>> expectedBodiesReceived as well.
>>>
>>>
>>>
>>> On Fri, Oct 23, 2009 at 11:01 AM, Charles Moulliard
>>> <cm...@gmail.com> wrote:
>>>>
>>>> I have created a unit test to unmarshal a FIX message into a model
>>>> (copy the model into another one) and marshal the result into a CSV
>>>>
>>>> The result received by the mock is null. If I try to read the object,
>>>> I have this :
>>>>
>>>>>>> Class : [B
>>>>>>> CSV generated : [B@12b19c5
>>>>
>>>> Remark : the FIX message is well transformed into a model of objects
>>>> and bindy does not generate any error during the generation of the
>>>> outputstream from the model object
>>>>
>>>> public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests {
>>>>
>>>> private static final transient Log LOG =
>>>> LogFactory.getLog(VresEmxToCsvTest.class);
>>>>
>>>> @Produce(uri = "direct:start")
>>>> private ProducerTemplate template;
>>>>
>>>> @EndpointInject(uri = "mock:result")
>>>> private MockEndpoint resultEndpoint;
>>>>
>>>>
>>>> @Test
>>>> @DirtiesContext
>>>> public void testEmxtoCsv() throws Exception {
>>>>
>>>> String record =
>>>> "8=FIX.4.1 9=980 35=U3 34=61 49=SERVER 50=EMXSV 52=20091021-14:58:09
>>>> 56=X3S 115=AHPRO 116=AHPADMIN 128=AHINT 129=AHIADMIN 9426=VRES 15=GBP
>>>> 58=TEXT 117=first
>>>> response 131=VAL
>>>> Multiple 9400=* 9442=UT 9464=20090910-14:00:00 9469=Q 9477=11 9488=AHINT
>>>> 9490=AHPRO 9494=AGENCY
>>>> NO 9504=desig2 9450=3 9470=1 22=4 48=ISINLU898 9429=20091013-09:54:45
>>>> 9448=2432.45454 9493=fgfhgfhg 9470=2 22=4 48=ISINLU898
>>>> 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=3 22=4
>>>> 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg
>>>> 9425=20091008-13:11:12 9452=20091008-13:11:16 9453=20091008-13:11:16
>>>> 9480=1.0~SHA-1~RSA~CN=EMX
>>>> Certificate Authority,OU=Certificate Authority,O=EMX Company
>>>>
>>>> Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad94
>>>> 9481=20091008-13:11:12 9491=4003182 10=190 ";
>>>> String result = "";
>>>>
>>>> template.sendBody(record);
>>>>
>>>> resultEndpoint.expectedMessageCount(1);
>>>> // resultEndpoint.expectedBodiesReceived(result);
>>>> resultEndpoint.assertIsSatisfied();
>>>>
>>>> for (Exchange exch : resultEndpoint.getExchanges()) {
>>>> Object obj = exch.getIn().getBody();
>>>> System.out.println(">>> Class : " + obj.getClass().getName());
>>>> System.out.println(">>> CSV generated : " + obj.toString());
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> /* @Test
>>>> @DirtiesContext
>>>> public void testUnMarshallWithNullFields() throws Exception {
>>>>
>>>> // TODO add null fields
>>>> String record =
>>>> "8=FIX.4.1 9=89 35=U2 34=84 49=SERVER 52=20090630-10:29:25 56=X3S
>>>> 9426=TBKD 11=ORDER1 22=2 37=WWWWWW 48=ISIN24324343 54=1 58=TTT 67=1 68=1
>>>> 121=Y 152=33.43 173=TTTTTTT 174=TTTTTTTTTTT
>>>> 182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 183=HHHHHH
>>>> 184=YYYYYYYYY 185=FFFFFFFFFFFFFF 9400=TTTTTTTTTTT 9401=1 9402=31.23 9403=1
>>>> 9404=TTT 9405=TTT 9406=TTT 9407=TTT 9408=TTT 9409=TTT 9410=TTT 9411=TTT
>>>> 9412=TTT 9413=N 9414=TTT 9415=TTT 9416=R 9417=USD 9418=DEM 9419=8.65
>>>> 9420=334 9422=M 9423=Y 9424=HJHJKHJKHJ 9428=20090303-12:25:55 9435=20080326
>>>> 9436=jhkjkj 9437=dddddddddd 9438=eeeeeeeeee 9439=1209 9440=AA 9441=8
>>>> 9442=PROTYP3 9443=1 9444=safdewfw 9449=fsgsg 9451=E 9455=EUR 9462=5 9468=?
>>>> 9471=433.443 9474=E 9475=Y 9482=fwrfw 9483=KKKKK 9484=KLKLKL 9485=JKIJKJKJ
>>>> 9488=ORIG1 9489=JJJJJ 9490=PRV03 9492=kjlklk 9494=AGENCY33 9495=23.18
>>>> 9491=TBKD-57765177 10=111 ";
>>>>
>>>> template.sendBody(record);
>>>>
>>>> resultEndpoint.expectedMessageCount(1);
>>>> resultEndpoint.assertIsSatisfied();
>>>>
>>>> List<Exchange> exchanges = resultEndpoint.getExchanges();
>>>>
>>>> for(Exchange exchange : exchanges) {
>>>>
>>>> models = (List<Map<String, Object>>) exchange.getIn().getBody();
>>>>
>>>> for (int i=0; i< models.size(); i++) {
>>>> model = models.get(i);
>>>> OutTbkdMessage tbkd =
>>>>
>>>> (OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
>>>> Assert.assertEquals(tbkd.getOrdUntNb(), null);
>>>> LOG.debug("Model : " + tbkd.toString());
>>>> }
>>>>
>>>>
>>>> }
>>>> }*/
>>>>
>>>> @Configuration
>>>> public static class ContextConfig extends SingleRouteCamelConfiguration
>>>> {
>>>> BindyKeyValuePairDataFormat emxBindyDataFormat = new
>>>>
>>>> BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
>>>> BindyCsvDataFormat csvBindyDataFormat = new
>>>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>>>
>>>> @Override
>>>> @Bean
>>>> public RouteBuilder route() {
>>>> return new RouteBuilder() {
>>>> @Override
>>>> public void configure() {
>>>> from("direct:start")
>>>> .unmarshal(emxBindyDataFormat)
>>>> .process(new Processor() {
>>>>
>>>> public void process(Exchange exchange) throws
>>>> Exception {
>>>>
>>>> InVresMessage
>>>> inVresMessage = new InVresMessage();
>>>> List<Map<String, Object>> models = new
>>>> ArrayList<Map<String, Object>>();
>>>> List<Map<String, Object>> modelsReceived;
>>>> Map<String, Object> model = new
>>>> HashMap<String, Object>();
>>>>
>>>> modelsReceived =
>>>> (List<Map<String, Object>>) exchange.getIn().getBody();
>>>> OutVresMessage
>>>> outVresMessage = (OutVresMessage)
>>>>
>>>> modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
>>>>
>>>>
>>>> PropertyUtils.copyProperties(inVresMessage, outVresMessage);
>>>>
>>>> model.put(inVresMessage.getClass().getName(), inVresMessage);
>>>> models.add( model
>>>> );
>>>>
>>>>
>>>> exchange.getIn().setBody(models);
>>>> }
>>>> }
>>>>
>>>> )
>>>> .marshal(csvBindyDataFormat)
>>>> .to("mock:result");
>>>> }
>>>> };
>>>> }
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>> Regards,
>>>>
>>>> Charles Moulliard
>>>> Senior Enterprise Architect
>>>> Apache Camel Committer
>>>>
>>>> *****************************
>>>> blog : http://cmoulliard.blogspot.com
>>>> twitter : http://twitter.com/cmoulliard
>>>>
>>>
>>>
>>>
>>
>>
>
Re: Strange error
Posted by Charles Moulliard <cm...@gmail.com>.
I have also this issue with the following test (the code is based on
what I have done in camel-bindy where there are 25 unit tests like
this one) :
@Test
@DirtiesContext
public void testModeltoCsv() throws Exception {
template.sendBody(Model.generateModel(
EmxMessageType.VRES.getValue(), Model.getInVresMessage()) );
resultEndpoint.expectedMessageCount(1);
resultEndpoint.expectedBodiesReceived( expected );
resultEndpoint.assertIsSatisfied();
}
@Configuration
public static class ContextConfig extends SingleRouteCamelConfiguration {
BindyCsvDataFormat csvBindyDataFormat = new
BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
@Override
@Bean
public RouteBuilder route() {
return new RouteBuilder() {
@Override
public void configure() {
from("direct:start")
.marshal(csvBindyDataFormat)
.to("mock:result");
}
};
}
}
FYI, the result generated by marshal method of camel-bindy is not null :
for (Map<String, Object> model : models) {
String result = factory.unbind(model);
LOG.info(">>>> String generated : " + result); // CONTENT
OF STRING IS NOT NULL
byte[] bytes =
exchange.getContext().getTypeConverter().convertTo(byte[].class,
exchange, result);
outputStream.write(bytes);
// Add a carriage return
outputStream.write(bytesCRLF);
}
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Fri, Oct 23, 2009 at 12:40 PM, Willem Jiang <wi...@gmail.com> wrote:
> I don't know why the resultEndpoint can't receive any message.
>
> chris, are you using spring configuration.
> Can you check if the resultEndpoint is injected rightly?
>
> Willem
>
> Claus Ibsen wrote:
>>
>> The B[ stuff is Java way of telling its a byte array
>>
>> Force Camel to test against String etc
>>
>>> // resultEndpoint.expectedBodiesReceived(result);
>>
>> Could be
>> resultEndpoint.message(0).body(String.class).isEqualTo(result);
>>
>> I guess we should add that type converter stuff into
>> expectedBodiesReceived as well.
>>
>>
>>
>> On Fri, Oct 23, 2009 at 11:01 AM, Charles Moulliard
>> <cm...@gmail.com> wrote:
>>>
>>> I have created a unit test to unmarshal a FIX message into a model
>>> (copy the model into another one) and marshal the result into a CSV
>>>
>>> The result received by the mock is null. If I try to read the object,
>>> I have this :
>>>
>>>>>> Class : [B
>>>>>> CSV generated : [B@12b19c5
>>>
>>> Remark : the FIX message is well transformed into a model of objects
>>> and bindy does not generate any error during the generation of the
>>> outputstream from the model object
>>>
>>> public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests {
>>>
>>> private static final transient Log LOG =
>>> LogFactory.getLog(VresEmxToCsvTest.class);
>>>
>>> @Produce(uri = "direct:start")
>>> private ProducerTemplate template;
>>>
>>> @EndpointInject(uri = "mock:result")
>>> private MockEndpoint resultEndpoint;
>>>
>>>
>>> @Test
>>> @DirtiesContext
>>> public void testEmxtoCsv() throws Exception {
>>>
>>> String record =
>>> "8=FIX.4.1 9=980 35=U3 34=61 49=SERVER 50=EMXSV 52=20091021-14:58:09
>>> 56=X3S 115=AHPRO 116=AHPADMIN 128=AHINT 129=AHIADMIN 9426=VRES 15=GBP
>>> 58=TEXT 117=first
>>> response 131=VAL
>>> Multiple 9400=* 9442=UT 9464=20090910-14:00:00 9469=Q 9477=11 9488=AHINT
>>> 9490=AHPRO 9494=AGENCY
>>> NO 9504=desig2 9450=3 9470=1 22=4 48=ISINLU898 9429=20091013-09:54:45
>>> 9448=2432.45454 9493=fgfhgfhg 9470=2 22=4 48=ISINLU898
>>> 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=3 22=4
>>> 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg
>>> 9425=20091008-13:11:12 9452=20091008-13:11:16 9453=20091008-13:11:16
>>> 9480=1.0~SHA-1~RSA~CN=EMX
>>> Certificate Authority,OU=Certificate Authority,O=EMX Company
>>>
>>> Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad94
>>> 9481=20091008-13:11:12 9491=4003182 10=190 ";
>>> String result = "";
>>>
>>> template.sendBody(record);
>>>
>>> resultEndpoint.expectedMessageCount(1);
>>> // resultEndpoint.expectedBodiesReceived(result);
>>> resultEndpoint.assertIsSatisfied();
>>>
>>> for (Exchange exch : resultEndpoint.getExchanges()) {
>>> Object obj = exch.getIn().getBody();
>>> System.out.println(">>> Class : " + obj.getClass().getName());
>>> System.out.println(">>> CSV generated : " + obj.toString());
>>> }
>>>
>>>
>>>
>>>
>>> }
>>>
>>>
>>>
>>> /* @Test
>>> @DirtiesContext
>>> public void testUnMarshallWithNullFields() throws Exception {
>>>
>>> // TODO add null fields
>>> String record =
>>> "8=FIX.4.1 9=89 35=U2 34=84 49=SERVER 52=20090630-10:29:25 56=X3S
>>> 9426=TBKD 11=ORDER1 22=2 37=WWWWWW 48=ISIN24324343 54=1 58=TTT 67=1 68=1
>>> 121=Y 152=33.43 173=TTTTTTT 174=TTTTTTTTTTT
>>> 182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 183=HHHHHH
>>> 184=YYYYYYYYY 185=FFFFFFFFFFFFFF 9400=TTTTTTTTTTT 9401=1 9402=31.23 9403=1
>>> 9404=TTT 9405=TTT 9406=TTT 9407=TTT 9408=TTT 9409=TTT 9410=TTT 9411=TTT
>>> 9412=TTT 9413=N 9414=TTT 9415=TTT 9416=R 9417=USD 9418=DEM 9419=8.65
>>> 9420=334 9422=M 9423=Y 9424=HJHJKHJKHJ 9428=20090303-12:25:55 9435=20080326
>>> 9436=jhkjkj 9437=dddddddddd 9438=eeeeeeeeee 9439=1209 9440=AA 9441=8
>>> 9442=PROTYP3 9443=1 9444=safdewfw 9449=fsgsg 9451=E 9455=EUR 9462=5 9468=?
>>> 9471=433.443 9474=E 9475=Y 9482=fwrfw 9483=KKKKK 9484=KLKLKL 9485=JKIJKJKJ
>>> 9488=ORIG1 9489=JJJJJ 9490=PRV03 9492=kjlklk 9494=AGENCY33 9495=23.18
>>> 9491=TBKD-57765177 10=111 ";
>>>
>>> template.sendBody(record);
>>>
>>> resultEndpoint.expectedMessageCount(1);
>>> resultEndpoint.assertIsSatisfied();
>>>
>>> List<Exchange> exchanges = resultEndpoint.getExchanges();
>>>
>>> for(Exchange exchange : exchanges) {
>>>
>>> models = (List<Map<String, Object>>) exchange.getIn().getBody();
>>>
>>> for (int i=0; i< models.size(); i++) {
>>> model = models.get(i);
>>> OutTbkdMessage tbkd =
>>>
>>> (OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
>>> Assert.assertEquals(tbkd.getOrdUntNb(), null);
>>> LOG.debug("Model : " + tbkd.toString());
>>> }
>>>
>>>
>>> }
>>> }*/
>>>
>>> @Configuration
>>> public static class ContextConfig extends SingleRouteCamelConfiguration
>>> {
>>> BindyKeyValuePairDataFormat emxBindyDataFormat = new
>>>
>>> BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
>>> BindyCsvDataFormat csvBindyDataFormat = new
>>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>>
>>> @Override
>>> @Bean
>>> public RouteBuilder route() {
>>> return new RouteBuilder() {
>>> @Override
>>> public void configure() {
>>> from("direct:start")
>>> .unmarshal(emxBindyDataFormat)
>>> .process(new Processor() {
>>>
>>> public void process(Exchange exchange) throws
>>> Exception {
>>>
>>> InVresMessage
>>> inVresMessage = new InVresMessage();
>>> List<Map<String, Object>> models = new
>>> ArrayList<Map<String, Object>>();
>>> List<Map<String, Object>> modelsReceived;
>>> Map<String, Object> model = new
>>> HashMap<String, Object>();
>>>
>>> modelsReceived =
>>> (List<Map<String, Object>>) exchange.getIn().getBody();
>>> OutVresMessage
>>> outVresMessage = (OutVresMessage)
>>>
>>> modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
>>>
>>>
>>> PropertyUtils.copyProperties(inVresMessage, outVresMessage);
>>>
>>> model.put(inVresMessage.getClass().getName(), inVresMessage);
>>> models.add( model
>>> );
>>>
>>>
>>> exchange.getIn().setBody(models);
>>> }
>>> }
>>>
>>> )
>>> .marshal(csvBindyDataFormat)
>>> .to("mock:result");
>>> }
>>> };
>>> }
>>> }
>>>
>>> }
>>>
>>>
>>> Regards,
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>> twitter : http://twitter.com/cmoulliard
>>>
>>
>>
>>
>
>
Re: Strange error
Posted by Willem Jiang <wi...@gmail.com>.
I don't know why the resultEndpoint can't receive any message.
chris, are you using spring configuration.
Can you check if the resultEndpoint is injected rightly?
Willem
Claus Ibsen wrote:
> The B[ stuff is Java way of telling its a byte array
>
> Force Camel to test against String etc
>
>> // resultEndpoint.expectedBodiesReceived(result);
>
> Could be
> resultEndpoint.message(0).body(String.class).isEqualTo(result);
>
> I guess we should add that type converter stuff into
> expectedBodiesReceived as well.
>
>
>
> On Fri, Oct 23, 2009 at 11:01 AM, Charles Moulliard
> <cm...@gmail.com> wrote:
>> I have created a unit test to unmarshal a FIX message into a model
>> (copy the model into another one) and marshal the result into a CSV
>>
>> The result received by the mock is null. If I try to read the object,
>> I have this :
>>
>>>>> Class : [B
>>>>> CSV generated : [B@12b19c5
>> Remark : the FIX message is well transformed into a model of objects
>> and bindy does not generate any error during the generation of the
>> outputstream from the model object
>>
>> public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests {
>>
>> private static final transient Log LOG =
>> LogFactory.getLog(VresEmxToCsvTest.class);
>>
>> @Produce(uri = "direct:start")
>> private ProducerTemplate template;
>>
>> @EndpointInject(uri = "mock:result")
>> private MockEndpoint resultEndpoint;
>>
>>
>> @Test
>> @DirtiesContext
>> public void testEmxtoCsv() throws Exception {
>>
>> String record =
>> "8=FIX.4.1 9=980 35=U3 34=61 49=SERVER 50=EMXSV 52=20091021-14:58:09 56=X3S 115=AHPRO 116=AHPADMIN 128=AHINT 129=AHIADMIN 9426=VRES 15=GBP 58=TEXT 117=first
>> response 131=VAL
>> Multiple 9400=* 9442=UT 9464=20090910-14:00:00 9469=Q 9477=11 9488=AHINT 9490=AHPRO 9494=AGENCY
>> NO 9504=desig2 9450=3 9470=1 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=2 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=3 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9425=20091008-13:11:12 9452=20091008-13:11:16 9453=20091008-13:11:16 9480=1.0~SHA-1~RSA~CN=EMX
>> Certificate Authority,OU=Certificate Authority,O=EMX Company
>> Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad94 9481=20091008-13:11:12 9491=4003182 10=190 ";
>> String result = "";
>>
>> template.sendBody(record);
>>
>> resultEndpoint.expectedMessageCount(1);
>> // resultEndpoint.expectedBodiesReceived(result);
>> resultEndpoint.assertIsSatisfied();
>>
>> for (Exchange exch : resultEndpoint.getExchanges()) {
>> Object obj = exch.getIn().getBody();
>> System.out.println(">>> Class : " + obj.getClass().getName());
>> System.out.println(">>> CSV generated : " + obj.toString());
>> }
>>
>>
>>
>>
>> }
>>
>>
>>
>> /* @Test
>> @DirtiesContext
>> public void testUnMarshallWithNullFields() throws Exception {
>>
>> // TODO add null fields
>> String record =
>> "8=FIX.4.1 9=89 35=U2 34=84 49=SERVER 52=20090630-10:29:25 56=X3S 9426=TBKD 11=ORDER1 22=2 37=WWWWWW 48=ISIN24324343 54=1 58=TTT 67=1 68=1 121=Y 152=33.43 173=TTTTTTT 174=TTTTTTTTTTT 182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 183=HHHHHH 184=YYYYYYYYY 185=FFFFFFFFFFFFFF 9400=TTTTTTTTTTT 9401=1 9402=31.23 9403=1 9404=TTT 9405=TTT 9406=TTT 9407=TTT 9408=TTT 9409=TTT 9410=TTT 9411=TTT 9412=TTT 9413=N 9414=TTT 9415=TTT 9416=R 9417=USD 9418=DEM 9419=8.65 9420=334 9422=M 9423=Y 9424=HJHJKHJKHJ 9428=20090303-12:25:55 9435=20080326 9436=jhkjkj 9437=dddddddddd 9438=eeeeeeeeee 9439=1209 9440=AA 9441=8 9442=PROTYP3 9443=1 9444=safdewfw 9449=fsgsg 9451=E 9455=EUR 9462=5 9468=? 9471=433.443 9474=E 9475=Y 9482=fwrfw 9483=KKKKK 9484=KLKLKL 9485=JKIJKJKJ 9488=ORIG1 9489=JJJJJ 9490=PRV03 9492=kjlklk 9494=AGENCY33 9495=23.18 9491=TBKD-57765177 10=111 ";
>>
>> template.sendBody(record);
>>
>> resultEndpoint.expectedMessageCount(1);
>> resultEndpoint.assertIsSatisfied();
>>
>> List<Exchange> exchanges = resultEndpoint.getExchanges();
>>
>> for(Exchange exchange : exchanges) {
>>
>> models = (List<Map<String, Object>>) exchange.getIn().getBody();
>>
>> for (int i=0; i< models.size(); i++) {
>> model = models.get(i);
>> OutTbkdMessage tbkd =
>> (OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
>> Assert.assertEquals(tbkd.getOrdUntNb(), null);
>> LOG.debug("Model : " + tbkd.toString());
>> }
>>
>>
>> }
>> }*/
>>
>> @Configuration
>> public static class ContextConfig extends SingleRouteCamelConfiguration {
>> BindyKeyValuePairDataFormat emxBindyDataFormat = new
>> BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
>> BindyCsvDataFormat csvBindyDataFormat = new
>> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>>
>> @Override
>> @Bean
>> public RouteBuilder route() {
>> return new RouteBuilder() {
>> @Override
>> public void configure() {
>> from("direct:start")
>> .unmarshal(emxBindyDataFormat)
>> .process(new Processor() {
>>
>> public void process(Exchange exchange) throws
>> Exception {
>>
>> InVresMessage inVresMessage = new InVresMessage();
>> List<Map<String, Object>> models = new
>> ArrayList<Map<String, Object>>();
>> List<Map<String, Object>> modelsReceived;
>> Map<String, Object> model = new
>> HashMap<String, Object>();
>>
>> modelsReceived = (List<Map<String, Object>>) exchange.getIn().getBody();
>> OutVresMessage outVresMessage = (OutVresMessage)
>> modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
>>
>> PropertyUtils.copyProperties(inVresMessage, outVresMessage);
>> model.put(inVresMessage.getClass().getName(), inVresMessage);
>> models.add( model );
>>
>> exchange.getIn().setBody(models);
>> }
>> }
>>
>> )
>> .marshal(csvBindyDataFormat)
>> .to("mock:result");
>> }
>> };
>> }
>> }
>>
>> }
>>
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>
>
>
Re: Strange error
Posted by Claus Ibsen <cl...@gmail.com>.
The B[ stuff is Java way of telling its a byte array
Force Camel to test against String etc
> // resultEndpoint.expectedBodiesReceived(result);
Could be
resultEndpoint.message(0).body(String.class).isEqualTo(result);
I guess we should add that type converter stuff into
expectedBodiesReceived as well.
On Fri, Oct 23, 2009 at 11:01 AM, Charles Moulliard
<cm...@gmail.com> wrote:
> I have created a unit test to unmarshal a FIX message into a model
> (copy the model into another one) and marshal the result into a CSV
>
> The result received by the mock is null. If I try to read the object,
> I have this :
>
>>>> Class : [B
>>>> CSV generated : [B@12b19c5
>
> Remark : the FIX message is well transformed into a model of objects
> and bindy does not generate any error during the generation of the
> outputstream from the model object
>
> public class VresEmxToCsvTest extends AbstractJUnit4SpringContextTests {
>
> private static final transient Log LOG =
> LogFactory.getLog(VresEmxToCsvTest.class);
>
> @Produce(uri = "direct:start")
> private ProducerTemplate template;
>
> @EndpointInject(uri = "mock:result")
> private MockEndpoint resultEndpoint;
>
>
> @Test
> @DirtiesContext
> public void testEmxtoCsv() throws Exception {
>
> String record =
> "8=FIX.4.1 9=980 35=U3 34=61 49=SERVER 50=EMXSV 52=20091021-14:58:09 56=X3S 115=AHPRO 116=AHPADMIN 128=AHINT 129=AHIADMIN 9426=VRES 15=GBP 58=TEXT 117=first
> response 131=VAL
> Multiple 9400=* 9442=UT 9464=20090910-14:00:00 9469=Q 9477=11 9488=AHINT 9490=AHPRO 9494=AGENCY
> NO 9504=desig2 9450=3 9470=1 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=2 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9470=3 22=4 48=ISINLU898 9429=20091013-09:54:45 9448=2432.45454 9493=fgfhgfhg 9425=20091008-13:11:12 9452=20091008-13:11:16 9453=20091008-13:11:16 9480=1.0~SHA-1~RSA~CN=EMX
> Certificate Authority,OU=Certificate Authority,O=EMX Company
> Limited,C=GB~3ea639ba~3ee270f7e32929b5fb32eede09dd10c4f8e6809b83b7831165534be991e7845d6bfa7b6964f4336896d8f43e86e22d58b38362b6b6d096643d00351221df9b6d74ce9852689dc599c641182286de2b4ec8d47df6883d61a0664233daf34ec24026b985205ea2dbba5ca5856bb64ab911b8122c326bd1ccdd5d2b415b4d97ad94 9481=20091008-13:11:12 9491=4003182 10=190 ";
> String result = "";
>
> template.sendBody(record);
>
> resultEndpoint.expectedMessageCount(1);
> // resultEndpoint.expectedBodiesReceived(result);
> resultEndpoint.assertIsSatisfied();
>
> for (Exchange exch : resultEndpoint.getExchanges()) {
> Object obj = exch.getIn().getBody();
> System.out.println(">>> Class : " + obj.getClass().getName());
> System.out.println(">>> CSV generated : " + obj.toString());
> }
>
>
>
>
> }
>
>
>
> /* @Test
> @DirtiesContext
> public void testUnMarshallWithNullFields() throws Exception {
>
> // TODO add null fields
> String record =
> "8=FIX.4.1 9=89 35=U2 34=84 49=SERVER 52=20090630-10:29:25 56=X3S 9426=TBKD 11=ORDER1 22=2 37=WWWWWW 48=ISIN24324343 54=1 58=TTT 67=1 68=1 121=Y 152=33.43 173=TTTTTTT 174=TTTTTTTTTTT 182=BIGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 183=HHHHHH 184=YYYYYYYYY 185=FFFFFFFFFFFFFF 9400=TTTTTTTTTTT 9401=1 9402=31.23 9403=1 9404=TTT 9405=TTT 9406=TTT 9407=TTT 9408=TTT 9409=TTT 9410=TTT 9411=TTT 9412=TTT 9413=N 9414=TTT 9415=TTT 9416=R 9417=USD 9418=DEM 9419=8.65 9420=334 9422=M 9423=Y 9424=HJHJKHJKHJ 9428=20090303-12:25:55 9435=20080326 9436=jhkjkj 9437=dddddddddd 9438=eeeeeeeeee 9439=1209 9440=AA 9441=8 9442=PROTYP3 9443=1 9444=safdewfw 9449=fsgsg 9451=E 9455=EUR 9462=5 9468=? 9471=433.443 9474=E 9475=Y 9482=fwrfw 9483=KKKKK 9484=KLKLKL 9485=JKIJKJKJ 9488=ORIG1 9489=JJJJJ 9490=PRV03 9492=kjlklk 9494=AGENCY33 9495=23.18 9491=TBKD-57765177 10=111 ";
>
> template.sendBody(record);
>
> resultEndpoint.expectedMessageCount(1);
> resultEndpoint.assertIsSatisfied();
>
> List<Exchange> exchanges = resultEndpoint.getExchanges();
>
> for(Exchange exchange : exchanges) {
>
> models = (List<Map<String, Object>>) exchange.getIn().getBody();
>
> for (int i=0; i< models.size(); i++) {
> model = models.get(i);
> OutTbkdMessage tbkd =
> (OutTbkdMessage)model.get("com.xpectis.x3s.model.backoffice.emx.tbkd.out.OutTbkdMessage");
> Assert.assertEquals(tbkd.getOrdUntNb(), null);
> LOG.debug("Model : " + tbkd.toString());
> }
>
>
> }
> }*/
>
> @Configuration
> public static class ContextConfig extends SingleRouteCamelConfiguration {
> BindyKeyValuePairDataFormat emxBindyDataFormat = new
> BindyKeyValuePairDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.out","com.xpectis.x3s.model.backoffice.emx.common");
> BindyCsvDataFormat csvBindyDataFormat = new
> BindyCsvDataFormat("com.xpectis.x3s.model.backoffice.emx.vres.in");
>
> @Override
> @Bean
> public RouteBuilder route() {
> return new RouteBuilder() {
> @Override
> public void configure() {
> from("direct:start")
> .unmarshal(emxBindyDataFormat)
> .process(new Processor() {
>
> public void process(Exchange exchange) throws
> Exception {
>
> InVresMessage inVresMessage = new InVresMessage();
> List<Map<String, Object>> models = new
> ArrayList<Map<String, Object>>();
> List<Map<String, Object>> modelsReceived;
> Map<String, Object> model = new
> HashMap<String, Object>();
>
> modelsReceived = (List<Map<String, Object>>) exchange.getIn().getBody();
> OutVresMessage outVresMessage = (OutVresMessage)
> modelsReceived.get(0).get("com.xpectis.x3s.model.backoffice.emx.vres.out.OutVresMessage");
>
> PropertyUtils.copyProperties(inVresMessage, outVresMessage);
> model.put(inVresMessage.getClass().getName(), inVresMessage);
> models.add( model );
>
> exchange.getIn().setBody(models);
> }
> }
>
> )
> .marshal(csvBindyDataFormat)
> .to("mock:result");
> }
> };
> }
> }
>
> }
>
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus