struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carl Ballantyne <carlballant...@gmail.com>
Subject Unit Test Struts2 Action - Custom type converters not being run?
Date Wed, 21 Sep 2011 15:31:44 GMT
Hi All,

I have an action that I am trying to unit test. However it seems the
converters I have set for the User object that is being create by the action
are not being applied at all when running the unit test. The converters are
run when running the application.

For example I have a test class:

public class UserCreateTest extends StrutsSpringTestCase {


public void testValidationRequired() throws Exception {
             request.setParameter("user.roles", "");

             ActionProxy proxy = getActionProxy("/createUser.action");

            ActionSupport action = (ActionSupport)proxy.getAction();

            proxy.setExecuteResult(false); // Do not execute view
(JSP/Tiles)
            proxy.execute();

            // asserts to check errors etc......
     }
}



And then for that test class I have getUser and setUser methods that return
a User object. This object has an attribute roles that has a converter
applied by puting a User-conversion.properties file in the same folder as
the User class. All this works fine when running the app. It is just when
running the unit test it does not seem to get run. Or at least it is not
getting run before the Validation interceptor which seems odd to me.

Anyone have any ideas? Anyone testing validation for actions that involve
custom convertors?

Cheers,
Carl.

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