Mule ESB Email testing with GreenMail

1. A core file that contains the services
<service name="SampleService">
		<jms:inbound-endpoint queue="in"
			transformer-refs="JMSMessageToObject" />
	<component class="org.mule.example.hello.Greeter" />
	// Above class will collect the payload and append with Hello(Hello
			<smtp:outbound-endpoint port="${smtp.port}"
				host="${smtp.server}" from="${smtp.from.address}" subject="Accounting Invoice"
				<email:string-to-email-transformer />

2. A file that contains Mule XML configuration appropriate for unit tests
Note that the jms definition fires up Apache Active-MQ inside a virtual machine (vm://localhost), but that the smtp definition is very generic.

<mule xmlns="" 
	<context:property-placeholder location="classpath*" />
	<jms:activemq-connector name="jmsConnector"
		specification="1.1" brokerURL="vm://localhost" />
	<smtp:connector name="smtpConnector" />

3. A file that contains Mule XML configuration appropriate for development
Note that we are using a Weblogic JMS queue definition here, rather than the Apache MQ definition used in our test file.
<mule xmlns="" ...   
	<context:property-placeholder location="classpath*" />
	<jms:activemq-connector name="jmsConnector"
		specification="1.1" brokerURL="jms://localhost:8030" />
	<smtp:connector name="smtpConnector" />

4. A file that contains configuration properties appropriate for unit tests

5. A file that contains configuration properties appropriate for development

6. The unit test:
Now we take a quick look at the unit test, which just fires up an in-memory SMTP server running on port 3025, pushes a message into the in-memory JMS queue, and checks that the expected email is sent using the "Greenmail" apis:
   public class GreeterTest extends FunctionalTestCase {
 private GreenMail greenMail; 
 	protected void setUp() throws Exception {      
		 ServerSetup setup = new ServerSetup(65438, "localhost", "smtp");   
		 //Test properties      
		 GreenMail server = new GreenMail(setup);      
 	protected void tearDown() throws Exception {    
	 public void testJmsToEmail() {    
		 MuleClient client = new MuleClient();    
		 String payload = "Bob";   
		 client.send("jms://in", new DefaultMuleMessage(payload));    
		 assertTrue(greenMail.waitForIncomingEmail(5000, 1));    
		 assertEquals( "Hello Bob", 

As with the previous cases, for a full example I suggest that you take a look at the Mule functional test cases for the FTP transport, starting with