struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miguel Almeida <mig...@almeida.at>
Subject Re: Unit Test Struts2 Action - Custom type converters not being run?
Date Wed, 21 Sep 2011 17:22:14 GMT
On Wed, 2011-09-21 at 17:55 +0200, Carl Ballantyne wrote:


> How can I try the nightly build if using Maven? I do not see it listed as an
> option.

Would be nice if Struts released SNAPSHOT versions into maven. Does it?



> > Be aware that you can write your test as follow:
> >
> > public void testValidationRequired() throws Exception {
> >            request.setParameter("user.roles", "");
> >             executeAction("/your_package/your_action.action");
> >
> >           // asserts to check errors etc......
> >    }
> > }

Maurizio: you can't use this if you have to set objects (eg:
action.setSession(session );), does it? In my sessioned test I need:
		action.setSession(session );

actionProxy.getInvocation().getInvocationContext().setSession(session);
perhaps the first could be replaced with request.setParameter() (can
it?), but I need the second - otherwise I'll have a nullpointerexception
in my action's session.get() method (because ServletConfigInterceptor's
((SessionAware) action).setSession(context.getSession()); (line 146)
will set it to null and override the action.setSession(session)
instruction)

Miguel

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message