I am sorry for this a little long question, but you will be finding it
interesting... Simply put, I have (1),(2) and (3), then we I run struts
testing, I got error described as (4)
(1) item in struts-config.xml
<action path="/MyAction"
type="my.actions.myAction"
name="myForm"
scope="request"
validate="true"
input="myInput">
<forward name="display" path="myApp.display.page" />
</action>
(2) item in tiles-defs.xml
<definition name="myDefault" path="/jsp/default.jsp">
<put name="header" value="/jsp/myHeader.jsp" />
</definition>
<definition name="myApp.display.page" extends="myDefault">
<put name="bodyContent" value="/jsp/myApp.jsp" />
</definition>
(3)
I was trying to test MyAction.java (not shown here since it is just some simple
stuff),
I wrote the following struts testing case:
public class MyActionTest extends CactusStrutsTestCase {
public MyActionTest(String testingName){
super(testingName);
}
public void begin(WebRequest req){
req.setAuthentication(new BasicAuthentication("username","password"));
}
public void testDisplay() throws Exception {
setRequestPathInfo("/MyAction");
actionPerform();
// after actionPerform(), MyAction is really forwarding to
myApp.display.page
// so the testing should have passed, but it did not, see below error
verifyForward("display");
}
}
(4)
junit.framework.AssertionFailedError: was expecting
'/myContentRoot/myApp.display.page' but received
'/myContentRoot/jsp/default.jsp'
at servletunit.struts.Common.verifyForwardPath(Common.java:170)
at
servletunit.struts.CactusStrutsTestCase.verifyForward(CactusStrutsTestCase.java:432)
However, if I delete extends="myDefault" from the configure for
myApp.display.page in tiles-defs.xml, then the test case passed.
It seems there is an issue with the tiles extend, why this is happening? Do
you have any idea or workaround?
---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.