You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kilmer, Erich" <Er...@bellhowell.com> on 2003/01/27 18:40:02 UTC
RE: Is there something tricky about instantiating a DynaValidator
Form ?
Thanks for your response.
I am still looking for an way to instantiate a DynaValidatorForm.
We are using struts1.1b3 so the DynaActionFormClass class has no
getDynaActionFormClass method.
Is there another way to do this properly?
How else are we going to unit test action methods if we can't create the
form classes?
Erich
-----Original Message-----
From: Ashish Kulkarni [mailto:kulkarni_ash1312@yahoo.com]
Sent: Monday, January 27, 2003 11:09 AM
To: Struts Users Mailing List
Subject: Re: Is there something tricky about instantiating a
DynaValidatorForm ?
Hi,
When i have to put some values in DynaValidatorForm i
do the following to instantiate it in struts1.1b2
DynaValidatorForm PL1820UpdateForm =
(DynaValidatorForm)
DynaActionFormClass.getDynaActionFormClass(
"PL1820UpdateForm").newInstance();
Where PL1820UpdateForm is form definiation in
struts-config file.
I think this method of instantiating has been shcnage
in struts1.1b3
People correct me if i am wrong
Ashish
--- "Kilmer, Erich" <Er...@bellhowell.com>
wrote:
> Hello,
> I am trying to Junit test my Struts code. Not sure
> how many people have
> tried to do this. If there is a more appropriate
> forum to send this to
> please let me know.
> Here is my test code. When it gets to:
> dynaValidatorForm.set("areaId",
> "-1"); it crashes.
> I never tried to instantiate a DynaValidatorForm
> before (I always just cast
> ActionForm in the action method to a
> DynaValidatorForm).
> Is there something tricky about instantiating a
> DynaValidatorForm ?
>
> public void testSaveEdit()
> {
> try
> {
> appbean.login("admin", "project");
> addRequestParameter("method","Save");
> addRequestParameter("areaId","-1");
> setRequestPathInfo("/saveArea.do");
> DynaValidatorForm dynaValidatorForm = new
> DynaValidatorForm();
> dynaValidatorForm.set("areaId", "-1");
> dynaValidatorForm.set("description",
> "area1");
>
>
dynaValidatorForm.set("projectCoordinatorContactName",
> "new name
> 1");
>
>
dynaValidatorForm.set("projectCoordinatorContactPhoneNumber",
> "new
> number 1");
>
>
dynaValidatorForm.set("maintenanceManagerContactName",
> "new name
> 2");
>
>
dynaValidatorForm.set("maintenanceManagerContactPhoneNumber",
> "new
> number 2");
> setActionForm(dynaValidatorForm);
> actionPerform();
> verifyForward("success");
> verifyNoActionErrors();
> verifyActionErrors(new
> String[]{"message.saved"});
> appbean.logout();
>
> }
> catch(Exception e)
> {
> fail("Unexpected Exception - " +
> e.getMessage());
> }
> }
>
>
=====
A$HI$H
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
RE: Is there something tricky about instantiating a DynaValidator Form ?
Posted by Ashish Kulkarni <ku...@yahoo.com>.
Hi,
I had once read this message, but never tried it as i
am not using 1.1b3 as of now may be u can give it a
try and let me know if it works
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg12464.html
Ashish
--- "Kilmer, Erich" <Er...@bellhowell.com>
wrote:
> Thanks for your response.
> I am still looking for an way to instantiate a
> DynaValidatorForm.
> We are using struts1.1b3 so the DynaActionFormClass
> class has no
> getDynaActionFormClass method.
> Is there another way to do this properly?
> How else are we going to unit test action methods if
> we can't create the
> form classes?
> Erich
>
> -----Original Message-----
> From: Ashish Kulkarni
> [mailto:kulkarni_ash1312@yahoo.com]
> Sent: Monday, January 27, 2003 11:09 AM
> To: Struts Users Mailing List
> Subject: Re: Is there something tricky about
> instantiating a
> DynaValidatorForm ?
>
>
> Hi,
> When i have to put some values in DynaValidatorForm
> i
> do the following to instantiate it in struts1.1b2
> DynaValidatorForm PL1820UpdateForm =
> (DynaValidatorForm)
> DynaActionFormClass.getDynaActionFormClass(
>
> "PL1820UpdateForm").newInstance();
>
> Where PL1820UpdateForm is form definiation in
> struts-config file.
> I think this method of instantiating has been
> shcnage
> in struts1.1b3
> People correct me if i am wrong
> Ashish
>
>
>
> --- "Kilmer, Erich" <Er...@bellhowell.com>
> wrote:
> > Hello,
> > I am trying to Junit test my Struts code. Not sure
> > how many people have
> > tried to do this. If there is a more appropriate
> > forum to send this to
> > please let me know.
> > Here is my test code. When it gets to:
> > dynaValidatorForm.set("areaId",
> > "-1"); it crashes.
> > I never tried to instantiate a DynaValidatorForm
> > before (I always just cast
> > ActionForm in the action method to a
> > DynaValidatorForm).
> > Is there something tricky about instantiating a
> > DynaValidatorForm ?
> >
> > public void testSaveEdit()
> > {
> > try
> > {
> > appbean.login("admin", "project");
> > addRequestParameter("method","Save");
> > addRequestParameter("areaId","-1");
> > setRequestPathInfo("/saveArea.do");
> > DynaValidatorForm dynaValidatorForm = new
> > DynaValidatorForm();
> > dynaValidatorForm.set("areaId", "-1");
> > dynaValidatorForm.set("description",
> > "area1");
> >
> >
>
dynaValidatorForm.set("projectCoordinatorContactName",
> > "new name
> > 1");
> >
> >
>
dynaValidatorForm.set("projectCoordinatorContactPhoneNumber",
> > "new
> > number 1");
> >
> >
>
dynaValidatorForm.set("maintenanceManagerContactName",
> > "new name
> > 2");
> >
> >
>
dynaValidatorForm.set("maintenanceManagerContactPhoneNumber",
> > "new
> > number 2");
> > setActionForm(dynaValidatorForm);
> > actionPerform();
> > verifyForward("success");
> > verifyNoActionErrors();
> > verifyActionErrors(new
> > String[]{"message.saved"});
> > appbean.logout();
> >
> > }
> > catch(Exception e)
> > {
> > fail("Unexpected Exception - " +
> > e.getMessage());
> > }
> > }
> >
> >
>
>
> =====
> A$HI$H
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
=====
A$HI$H
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>