| From | Sent On | Attachments |
|---|---|---|
| Graham Smith | Aug 18, 2005 7:12 am | |
| Don Brown | Aug 18, 2005 8:01 am | |
| Graham Smith | Aug 18, 2005 8:31 am | |
| Craig McClanahan | Aug 18, 2005 9:31 am | |
| Mark Benussi | Aug 18, 2005 9:36 am | |
| John Martyniak | Aug 18, 2005 12:07 pm | |
| Michael Jouravlev | Aug 18, 2005 12:32 pm | |
| Graham Smith | Aug 18, 2005 12:42 pm | |
| Leon Rosenberg | Aug 18, 2005 12:44 pm | |
| Leon Rosenberg | Aug 18, 2005 12:52 pm | |
| Graham Smith | Aug 18, 2005 1:05 pm | |
| Michael Jouravlev | Aug 18, 2005 1:10 pm | |
| Luiz Godoy | Aug 18, 2005 1:21 pm | |
| Leon Rosenberg | Aug 18, 2005 1:27 pm | |
| Eduardo Ribeiro da Silva | Aug 18, 2005 1:32 pm | |
| Dhar...@ubs.com | Aug 18, 2005 2:10 pm | |
| Peter Maas | Aug 18, 2005 10:41 pm | |
| Mitchell, Steven C | Aug 19, 2005 5:29 am | |
| Craig McClanahan | Aug 19, 2005 2:52 pm |
| Subject: | RE: Testing Struts With JUnit | |
|---|---|---|
| From: | Mitchell, Steven C (Stev...@umb.com) | |
| Date: | Aug 19, 2005 5:29:34 am | |
| List: | org.apache.struts.user | |
Luiz,
Are you aware that there is an extension of Junit made for testing Struts?
http://strutstestcase.sourceforge.net/
-----Original Message----- From: Luiz Godoy [mailto:octa...@yahoo.com] Sent: Thursday, August 18, 2005 3:22 PM To: Struts Users Mailing List Subject: Testing Struts With JUnit
I´m trying to test the action below :
public class FamiliaDNCAction extends BasicAction {
public ActionForward unspecified(ActionMapping actionMapping, ActionForm
actionForm, HttpServletRequest request, HttpServletResponse response) throws
BusinessException {
Set msgs = new HashSet();
return loadPage(actionMapping,actionForm,request,response);
}
public ActionForward loadPage(ActionMapping actionMapping, ActionForm
actionForm, HttpServletRequest request, HttpServletResponse response) throws
BusinessException {
HttpSession session=request.getSession();
CadastroFamiliaDNC cad = new CadastroFamiliaDNC();
FamiliaDNCForm form = (FamiliaDNCForm) actionForm;
List dados = cad.findByCodigoDependencia(form.getCodDependencia().intValue());
session.setAttribute("dadosdnc",dados);
return actionMapping.findForward("inicial");
}
}
The parameters for the action are
FamiliaDNC.do -- calls the class ev --> the parameter for the method, when not set calls "unspecified" method
public class TestFamiliaDNCAction extends MockStrutsTestCase{ FamiliaDNCAction
fdnca;
public TestFamiliaDNCAction(String nomeDoTeste) {
super(nomeDoTeste);
}
public void setUp() throws Exception { super.setUp(); fdnca = new FamiliaDNCAction(); }
public void testLoadPage() {
addRequestParameter("codDependencia","1"); addRequestParameter("codTipoFamiliaInsumo","0"); addRequestParameter("ev","unspecified"); setRequestPathInfo("/corporativo/cadastro/cadFamiliaDNC"); actionPerform(); verifyForward("inicial"); verifyForwardPath("/corporativo/cadastro/corp_cad_familia_dnc.jsp"); verifyNoActionErrors(); }
I´m getting nullPointerException, when i try to test it. I´m not sure witch parameters i add to the request for example in the action form i have:
<form name="form2" method="post" action="./cadFamiliaDNC.do"> <input type="hidden" name="codFamiliaDNC" value=""> <input type="hidden" name="codTipoFamiliaInsumo"> <input type="hidden" name="codDependencia"> ..... /form>
My question is, witch parameters do i put in the addRequestParameter("?","?"); ?
any clue ?
Thanks in advance
regards..
Luiz Octavio Godoy
Desenvolvimento de Sistemas
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com





