KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > appfuse > webapp > action > PasswordHintControllerTest


1 package org.appfuse.webapp.action;
2
3 import org.springframework.mock.web.MockHttpServletRequest;
4 import org.springframework.mock.web.MockHttpServletResponse;
5
6 import com.dumbster.smtp.SimpleSmtpServer;
7
8
9 public class PasswordHintControllerTest extends BaseControllerTestCase {
10     private PasswordHintController c;
11
12     protected void setUp() throws Exception JavaDoc {
13         super.setUp(); // needed to initialize a user
14
c = (PasswordHintController) ctx.getBean("passwordHintController");
15     }
16     
17     protected void tearDown() throws Exception JavaDoc {
18         super.tearDown();
19         c = null;
20     }
21
22     public void testExecute() throws Exception JavaDoc {
23         MockHttpServletRequest request = newGet("/passwordHint.html");
24         request.addParameter("username", "tomcat");
25
26         SimpleSmtpServer server = SimpleSmtpServer.start(2525);
27         
28         c.handleRequest(request, new MockHttpServletResponse());
29         
30         // verify an account information e-mail was sent
31
server.stop();
32         assertTrue(server.getReceivedEmailSize() == 1);
33         
34         // verify that success messages are in the session
35
assertNotNull(request.getSession().getAttribute("messages"));
36     }
37 }
38
Popular Tags