1 20 21 package com.methodhead.reg; 22 23 import java.util.*; 24 import java.sql.*; 25 import java.io.*; 26 import junit.framework.*; 27 import org.apache.log4j.*; 28 import com.methodhead.persistable.*; 29 import com.methodhead.test.*; 30 import com.methodhead.auth.*; 31 import com.methodhead.aikp.*; 32 import com.methodhead.sitecontext.*; 33 import com.methodhead.*; 34 import servletunit.struts.*; 35 import org.apache.struts.action.*; 36 import org.apache.cactus.*; 37 38 public class SendPasswordActionTest extends CactusStrutsTestCase { 39 40 User user = null; 41 Role role = null; 42 43 static { 44 TestUtils.initLogger(); 45 } 46 47 public SendPasswordActionTest( String name ) { 48 super( name ); 49 } 50 51 public void setUp() { 52 try { 53 super.setUp(); 54 55 ConnectionSingleton.runBatchUpdate( new FileReader( "webapp/WEB-INF/db/transfer-reset.sql" ) ); 56 } 57 catch ( Exception e ) { 58 fail( e.getMessage() ); 59 } 60 } 61 62 public void tearDown() 63 throws 64 Exception { 65 super.tearDown(); 66 } 67 68 public void testDoSendPasswordForm() { 69 TestData.createUsers(); 70 71 SiteContext.setContext( request, TestData.siteContext1 ); 72 73 setRequestPathInfo( "/sendPasswordForm" ); 74 actionPerform(); 75 76 verifyForward( "form" ); 77 } 78 79 public void testDoSendPassword() { 80 TestData.createUsers(); 81 82 SiteContext.setContext( request, TestData.siteContext1 ); 83 84 setRequestPathInfo( "/sendPassword" ); 85 addRequestParameter( "email", "test1@methodhead.com" ); 86 actionPerform(); 87 88 verifyForward( "success" ); 89 90 94 user = new User(); 98 user.load( new IntKey( 1 ) ); 99 assertEquals( "password", user.getString( "password" ) ); 100 101 verifyActionMessages( new String [] { "reg.sendpassword.passwordSent" } ); 105 } 106 107 public void testDoSendPasswordEncrypted() { 108 System.out.println( "SendPasswordActionTest.testDoSendPasswordEncrypted(): Can't test encrypted passwords with DefaultTransferPolicy." ); 109 137 } 138 } 139 | Popular Tags |