camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gael Anex <>
Subject How to create a message manually for mock testing
Date Mon, 13 Aug 2012 13:46:11 GMT
Hi all,

I am new to Camel.

I am discovering Camel through an implementation done in a Java Application.

As a introduction to Camel, I must develop mock testing in this application.

I am creating a Junit class and would like to create a mock representing a

Is there a way to initialize "mockMessage" as a Camel Message using the
method "setBody", etc... ?

Thank you very much

Here is my code

import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.Map;
import junit.framework.Assert;
import org.apache.camel.Message;
import org.apache.camel.spring.util.ReflectionUtils;
import org.apache.poi.hssf.record.formula.functions.SLOPE;
import org.hibernate.mapping.Array;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.test.util.ReflectionTestUtils;

public class ImageJLaunchBeanTest {

	private ImageJLaunchBean imageJLaunchBean;
	public void init(){

		//J'instancie la classe à tester
		imageJLaunchBean = new ImageJLaunchBean();
		Message mockMessage = null;
		Map<String, Object> ipv = new HashMap<String, Object>();
		long expRunStepPk = 60053;
		ipv.put("experimentRunStepPk", expRunStepPk);
		long ssa[] = {1458};
		ipv.put("SELECT_ATTACHMENT", ssa[0]);

		SWorkflowInitParam swfip = new SWorkflowInitParam();

		Message message = Mockito.mock(Message.class);


		ReflectionTestUtils.setField(imageJLaunchBean, "message", message);
		public void MessageTest(){

			test here

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

View raw message