1 package servletunit.struts.tests.cactus; 2 3 import servletunit.struts.CactusStrutsTestCase; 4 import org.apache.cactus.WebResponse; 5 6 public class TestProcessResults extends CactusStrutsTestCase { 7 8 public void testSuccessfulLogin() { 9 processRequest(true); 10 addRequestParameter("username","deryl"); 11 addRequestParameter("password","radar"); 12 setRequestPathInfo("/login"); 13 actionPerform(); 14 verifyForward("success"); 15 verifyForwardPath("/main/success.jsp"); 16 assertEquals("deryl", getSession().getAttribute("authentication")); 17 verifyNoActionErrors(); 18 } 19 20 public void endSuccessfulLogin(WebResponse response) { 21 assertEquals("unexpected response code",200,response.getStatusCode()); 22 String [] text = response.getTextAsArray(); 23 for (int i = 0; i < text.length; i++) { 24 String line = text[i]; 25 if (line != null && 26 !line.equals("<h2>You have successfully logged in!</h2>") && 27 !line.equals("<a HREF=\"/test/login/login.jsp\">Go back</a>") && 28 !line.equals("")) 29 fail("unexpected text: " + line); 30 31 } 32 } 33 } 34 | Popular Tags |