I think by default the CactusStrutsTestCase reads the /WEB-INF/struts-
config.xml only. If you have multiple config files you would have to set the 
appropriate config file in your test method. For eg:

public void testDisplay() throws Exception {
setConfigFile("/WEB-INF/struts-config.xml,/WEB-INF/struts-my.xml");
setRequestPathInfo("/MyAction");
actionPerform();
verifyForward("Your_forwardTarget_Path");
verifyNoActionErrors();
}



On 9/15/05, Carl Smith <[EMAIL PROTECTED]> wrote:
> 
> 
> I have two struts-config.xml files. One is Struts default 
> struts-config.xml and the other one is called
> struts-my.xml. and I have configued these two xml files in web.xml so that 
> ActionServlet can take both struts-config.xml
> and struts-my.xml. See following:
> 
> <servlet>
> <servlet-name>action</servlet-name>
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> <init-param>
> <param-name>config</param-name>
> <param-value>/WEB-INF/struts-config.xml,/WEB-INF/struts-my.xml
> </param-value>
> </init-param>
> <init-param>
> <param-name>debug</param-name>
> <param-value>2</param-value>
> </init-param>
> <init-param>
> <param-name>detail</param-name>
> <param-value>2</param-value>
> </init-param>
> <load-on-startup>2</load-on-startup>
> </servlet>
> 
> 
> Now I have a Cactus testing action to test MyAction.java (not included 
> here), I found out a wired issue:
> if I configure MyAction.java in struts-config.xml, then my test succeed, 
> however if I configure MyAction.java
> in struts-my.xml, the test fails with the following error. Any 
> suggestions?
> 
> junit.framework.AssertionFailedError: Cannot find forward 
> 'Your_forwardTarget_Path' - it is possible that it is not mapped correctly.
> at java.lang.Throwable.<init>(Throwable.java:52)
> at java.lang.Throwable.<init>(Throwable.java:66)
> 
> 
> 
> 
> package com.ford.hr.mpc.performance.web.struts.action;
> 
> import org.apache.cactus.WebRequest;
> import org.apache.cactus.client.authentication.BasicAuthentication;
> 
> import servletunit.struts.CactusStrutsTestCase;
> 
> 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();
> verifyForward("Your_forwardTarget_Path");
> verifyNoActionErrors();
> }
> 
> }
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Reply via email to