1 20 21 package com.methodhead.reg; 22 23 import java.util.*; 24 import java.io.*; 25 import java.sql.*; 26 import junit.framework.*; 27 import org.apache.log4j.*; 28 import com.methodhead.persistable.*; 29 import com.methodhead.test.*; 30 import com.methodhead.sitecontext.*; 31 import com.methodhead.auth.*; 32 import com.methodhead.*; 33 import servletunit.struts.*; 34 import org.apache.struts.action.*; 35 import org.apache.struts.util.*; 36 import org.apache.cactus.*; 37 38 public class ProfileFormTest extends CactusStrutsTestCase { 39 40 List list = null; 41 LabelValueBean labelValue = null; 42 DynaActionForm form = null; 43 User user = null; 44 45 static { 46 TestUtils.initLogger(); 47 } 48 49 public ProfileFormTest( String name ) { 50 super( name ); 51 } 52 53 public void setUp() throws Exception { 54 super.setUp(); 55 56 ConnectionSingleton.runBatchUpdate( new FileReader( "webapp/WEB-INF/db/transfer-reset.sql" ) ); 57 58 TestData.createUsers(); 59 AuthUtil.setUser( request, TestData.user1 ); 60 } 61 62 public void tearDown() 63 throws 64 Exception { 65 super.tearDown(); 66 } 67 68 public void testValidateMissingEmail() throws Exception { 69 70 setRequestPathInfo( "/profile" ); 71 addRequestParameter( "email", "" ); 72 actionPerform(); 73 74 verifyActionErrors( new String [] { "reg.profile.missingemail" } ); 75 } 76 77 public void testValidateInvalidEmail() throws Exception { 78 setRequestPathInfo( "/profile" ); 79 addRequestParameter( "email", "invalid e!mail" ); 80 actionPerform(); 81 82 verifyActionErrors( new String [] { "reg.profile.invalidemail" } ); 83 } 84 85 public void testValidateUserExists() throws Exception { 86 clearRequestParameters(); 87 setRequestPathInfo( "/profile" ); 88 addRequestParameter( "email", "test2@methodhead.com" ); 89 actionPerform(); 90 91 verifyActionErrors( new String [] { "reg.profile.userExists" } ); 92 } 93 } 94 | Popular Tags |