Hi,

 

So, first off, I'm doing some unit testing with Struts2.  So far, using
different solutions provided from other sites, I've been able to run a unit
test on an Action.  However, I had to tell Struts2 to NOT execute the
result.  This is fine when I'm testing that my Action is a-ok, however, I
would like to execute the result to verify that I have no major errors in my
view.  Specifically, for my actions that use Velocity as their view
technology, I'd like to execute them.

 

The problem is that I'm running these tests outside of a container.  This
means that the location of my template files are different than what the
struts configuration is expecting (/WebContent/WEB-INF/templates/hello.vm
instead of /WEB-INF/templates/hello.vm).  So, my first thought is, write my
own class that extends from VelocityResult and override the getTemplate
method to tweak the location, and then call the super.getTemplate(.).

 

Well, I very quickly realized that I had no real way of easily overriding
the velocity result mapping (at least, its not as apparent as the
VelocityManager override).  I contemplated creating my own mapping file (ala
struts-default.xl) just for testing, but, then realized that this wouldn't
work as my actual Struts mappings all extend from struts-default.

 

Does anybody know how to do this?

 

Thanks,

Dan Slack

Reply via email to