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
<[email protected]> 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 : [...@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