Perry,
-->please see my response below

-----Original Message-----
From: Perry Hoekstra [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 08, 2001 8:51 AM
To: '[EMAIL PROTECTED]'
Subject: Cactus and Testing Struts Action Classes


This is for anybody using Cactus to test Struts-based applications.  I have
a question concerning the testing of a Struts Action class through the
<perform> method.  In the definition of an ActionMapping, a section of code
would look like this:

ActionMapping t_actionMapping = actionServlet.findMapping("/somepage.jsp");

How do I configure the ServletRedirector in the web.xml file in order for
the findMapping method call to successfully resolve somepage.jsp?

Perry Hoekstra
Ingenix Corporation
[EMAIL PROTECTED]

--> In short, you just send the ServletRedirector an init parameter named
config that points to your struts-config.xml.  This looks the same as how
you init the struts action class as well.  See my web.xml snip below for an
example.

Hope that helps,
Ryan


[web.xml snip]
        <!-- STRUTS: Action Servlet Config -->
        <servlet>
                <servlet-name>action</servlet-name>
                <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
                <init-param>
                        <param-name>application</param-name>
                        <param-value>com.ApplicationResources</param-value>
                </init-param>
                <init-param>
                        <param-name>config</param-name>
                        <param-value>/WEB-INF/struts-config.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>
                <init-param>
                        <param-name>validate</param-name>
                        <param-value>true</param-value>
                </init-param>
                <load-on-startup>2</load-on-startup>
        </servlet>

      <!-- CACTUS: ServletRedirector Servlet Config -->
        <servlet>
                <servlet-name>ServletRedirector</servlet-name>
            <description>Cactus Testing ServletRedirector</description>

<servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class
>
                <init-param>
                        <param-name>application</param-name>
                        <param-value>com.ApplicationResources</param-value>
                </init-param>
                <init-param>
                        <param-name>config</param-name>
                        <param-value>/WEB-INF/struts-config.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>
                <init-param>
                        <param-name>validate</param-name>
                        <param-value>true</param-value>
                </init-param>
     </servlet>

Reply via email to