package org.appfuse.webapp.action;
import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.Globals;
import org.appfuse.Constants;
public class RegistrationServletTest extends ServletTestCase {
private Log log = LogFactory.getLog(RegistrationServletTest.class);
RegistrationServlet servlet = null;
public RegistrationServletTest(String name) {
super(name);
}
public RegistrationServlet createInstance() throws Exception {
return new RegistrationServlet();
}
protected void setUp() throws Exception {
super.setUp();
servlet = new RegistrationServlet();
servlet.init(config);
}
protected void tearDown() throws Exception {
servlet = null;
super.tearDown();
}
public void beginAddUser(WebRequest wRequest) {
wRequest.addParameter("username", "self-registered");
wRequest.addParameter("password", "Password1");
wRequest.addParameter("confirmPassword", "Password1");
wRequest.addParameter("firstName", "First");
wRequest.addParameter("lastName", "Last");
wRequest.addParameter("city", "Denver");
wRequest.addParameter("province", "Colorado");
wRequest.addParameter("country", "USA");
wRequest.addParameter("postalCode", "80210");
wRequest.addParameter("email", "[email protected]");
wRequest.addParameter("website", "http://raibledesigns.com");
wRequest.addParameter("passwordHint", "Password is one with you.");
}
public void testAddUser() throws Exception {
servlet.execute(request, response);
assertTrue(request.getAttribute(Globals.ERROR_KEY) == null);
assertTrue(request.getSession(false).getAttribute(Constants.REGISTERED) != null);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(RegistrationServletTest.class);
}
}