jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bryan hansen <b...@yahoo.com>
Subject RE: Cactus test and Struts
Date Wed, 16 Mar 2005 17:09:01 GMT
Thank you for your response Pedro. I was a little
hesitant to use the the StrutsTestCase stuff because
there were a lot of open issues that looked like they
weren't being resolved or even responded to. I will
try your approach and see it that works out better for
me. 

Thanks,

Bryan

--- Pedro Nevado <pnevado@javato.com> wrote:
> I use Cactus without StrutsTestCase to test my
> servlet 2.4 applications.
> 
> Here it is some code:
> 
> public class EmailEnvioActionTest extends
> ServletTestCase {
> 
> private static RequestDispatcher dispatcher;
> 
> protected void setUp() throws DaoException {
>    dispatcher =
>
request.getRequestDispatcher("/email_VistaPrevia_Submit.do");
>    assert dispatcher != null : "dispatcher not
> null";
> }
> 
> public void testCaso_1() throws IOException,
> ServletException {
>         dispatcher.forward(request, response);
> }
> 
> I do not instantiate in my test an ActionServlet if
> I want to test an
> Action. I use a dispatcher to put in place all the
> Struts machinery, and I
> focus the test on the request parameters and
> attributes, and the session
> attributes, that I send and what to do with them.
> 
> I hope this helps.
> Regards.
> Pedro
> 
> -----Mensaje original-----
> De: Nicolas Chalumeau
> [mailto:nicolas.chalumeau@gmail.com]
> Enviado el: miércoles, 16 de marzo de 2005 10:19
> Para: Cactus Users List
> Asunto: Re: Cactus test and Struts
> 
> 
> Hi bryan
> 
> I will not answer your question as I don't know (I
> didn't search ;) so ...)
> 
> I personnally use CactusStrutsTestCase to test my
> Action
> (http://strutstestcase.sourceforge.net/). It include
> all the
> mechanisme to load the struts-config, execute plugin
> ... Maybe it
> could solve some of your problems.
> 
> If you choose this solution the StrutsTestCase
> mailling should be the
> best place to ask in that case.
> 
> Nicolas,
> 
> On Tue, 15 Mar 2005 13:41:20 -0800 (PST), bryan
> hansen <bh5k@yahoo.com>
> wrote:
> > We are using cactus to test some struts actions. I
> am
> > getting an error and not sure what the cause is.
> BTW
> > if somebody has found a better way to do this, I
> am
> > open for suggestions.
> >
> > We simply add the URI that we want to request and
> the
> > appropriate paramaters in the begin method:
> >
> > private void beginAction(WebRequest request) {
> >   request.addHeader("URI",
> "/lease/leaseSummary.do");
> >   request.addParameter("command", "viewLease");
> >   request.addParameter("itemId","1301");
> >   request.addParameter("structureId", "1111");
> > }
> >
> > We then access the action servlet:
> >
> > public void testAction() throws Exception {
> >   ActionServlet servlet = new ActionServlet();
> >   servlet.init(config);
> >   UserSessionValues usv = new UserSessionValues();
> >   session.setAttribute("userInfo", usv);
> >
> >   servlet.doPost(request, response);
> >
> >   UserSessionValues usvSession =
> (UserSessionValues)
> > request.getSession().getAttribute("userInfo");
> >
> >    assertNotNull(usvSession);
> >
> > }
> >
> > The output from this test results in a bunch of
> debug
> > code, but ultimately this:
> >
> >     [cactus] 14:09:54,114 DEBUG wire: << "HTTP/1.1
> 404
> > Invalid path /ServletRedirector was
> requested[\r][\n]"
> >
> > I get the same error message on Tomcat and JBoss.
> >
> > Any ideas?
> >
> > Thanks,
> >
> > Bryan
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> cactus-user-help@jakarta.apache.org
> >
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> cactus-user-help@jakarta.apache.org
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> cactus-user-help@jakarta.apache.org
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

Mime
View raw message