camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From moorthy31 <manohar...@gmail.com>
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;
startupOrder=&quot;1&quot;>
			<from
				uri="activemq:queue:ABC-TEST" />
			<setExchangePattern pattern="InOnly" />
			<bean id="processor.bean" ref="ABCBean" />
			<to id="man.cdt.log.incoming"
			
uri="log:log.incoming?level=INFO&amp;multiline=true&amp;showHeaders=true&amp;showBodyType=false&amp;showBody=false&amp;showException=true&amp;showStackTrace=true"
/>
			<to id="log.stats"
			
uri="log:log.stats?level=INFO&amp;groupInterval=10000&amp;groupDelay=60000&amp;groupActiveOnly=false"
/>
		</route>
	</camelContext>

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


The below is the test method in my test case

@Test
	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
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(camelContext.getEndpoints());
		end.assertIsSatisfied();
		

	}


public class ABCBean {
	 @Handler
    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: http://camel.465427.n5.nabble.com/Set-referenced-Bean-as-end-point-tp5769738.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message