1   package br.org.articulus.server;
2   
3   import org.springframework.context.ApplicationContext;
4   import org.springframework.context.ConfigurableApplicationContext;
5   import org.springframework.context.support.ClassPathXmlApplicationContext;
6   import org.springframework.test.AbstractSpringContextTests;
7   
8   
9   /**
10   * TestCase of SendMail class
11   * @author anderson
12   * @version 2.0
13   */
14  public class SendMailTest extends AbstractSpringContextTests {
15  
16  	private SendMail sendMail;
17  	private ApplicationContext ctx;
18  	
19  	
20  	/**
21  	 * Load the application context
22  	 * @author anderson
23  	 * @version 1.0
24  	 */
25  	protected void setUp() throws Exception {
26  		ctx = loadContext(
27  				new String[] {"applicationContext-javamail.xml"});
28  	}
29  	
30  	
31  	/**
32  	 * Test of send method
33  	 * @author anderson
34  	 * @version 1.0
35  	 */
36  	public void testSend() {
37  		String to = "andersonajx@gmail.com";
38  		String subject = "TestCase";
39  		String msg = "Sended by testcase of Spring";
40  		
41  		sendMail = (SendMail)ctx.getBean("sendMail");
42  		sendMail.send(to,subject,msg);
43  		
44  		assertNotNull(to);
45  		assertNotNull(subject);
46  		assertNotNull(msg);
47  	}
48  	
49  	
50  	/**
51  	 * Method to load an application context
52  	 * @author anderson
53  	 * @version 1.0
54  	 */
55  	protected ConfigurableApplicationContext loadContext(Object arg0)
56  			throws Exception {
57  		return new ClassPathXmlApplicationContext((String[])arg0);
58  	}
59  
60  }