camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From moorthy31 <>
Subject Set referenced Bean as end point
Date Wed, 22 Jul 2015 09:33:03 GMT
As part of camel integration test, I am trying to set bean referenced in the
route builder as end point where body and header message is used to process
the data and insert into the database. I don't know how to set  reference
bean as end point in my test case

This is my camel contest :
<camelContext id=&quot;camel.main&quot; trace=&quot;true&quot;
&lt;route id=&quot;inbound.processing.route&quot;
				uri="activemq:queue:ABC-TEST" />
			<setExchangePattern pattern="InOnly" />
			<bean id="processor.bean" ref="ABCBean" />
			<to id="man.cdt.log.incoming"
			<to id="log.stats"

<bean id="ABCBean" class="com.processor.ABCBean">
			<property name="parserFactory" ref="parserFactory" />
		<property name="hibernateTransform" ref="hibernateTransform" />

The below is the test method in my test case

	public void testAsyncEndpointOK() throws InterruptedException {

		CamelContext camelContext = null;

		MockEndpoint end = null;
		try {
			ApplicationContext context = createApplicationContext();			
			camelContext = (CamelContext) context.getBean("camel.main");	
			ProducerTemplate producer = camelContext.createProducerTemplate();
			end = getMockEndpoint("mock:ABCBean.class");
			String messageBody = readMessage();
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("messageType", "MSG_TYPE");
			map.put("table", "TABLE");
			// producer.sendBody(messageBody);
			// producer.sendBody("mock:ProcessorBean.class", messageBody);
			producer.sendBodyAndHeaders(end, messageBody, map);
		} catch (CamelExecutionException e) {
			// TODO Auto-generated catch block
		} catch (Exception e) {
			// TODO Auto-generated catch block


public class ABCBean {
    public void handler(@Body String body,
            @Header(Constants.TABLE_NAME) String tableName,
            @Header(Constants.APP_ID) String appId) throws
ApplicationException {

        try {  
		methdod A{}

I want my test control goes to ABC bean where  the messages get inserted
into the table. Currently test control is not going to bean end point. Could
you please help me, how do I send the message and header info into the
referenced Bean?

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message