You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Kumuda Bhaskar <Ku...@symphonysv.com> on 2006/03/13 13:26:44 UTC

Please Help me, the beginXXX() method is not getting called

Hello,

I am using tomcat 5.0.4 and the beginXXX method is not getting called.

I am trying to test the file upload using struts.

Please help me in resolving my issues. I am not able to identify the
problem.

 

 

My Tester is as follows:

 

 

public class Tester extends CactusStrutsTestCase {

            

            public Tester(String testName) {

                        super(testName);

            }

            

            public void setUp() throws Exception {

                        logger.info("*** setUp() - start ***");

                        super.setUp();

 
setConfigFile("/WEB-INF/conf/struts-config.xml");

                        logger.info("*** setUp() - end ***");

            }

            

            

            NVPair[] hdrs = new NVPair[1]; 

             

            

            public void beginUploadFile(org.apache.cactus.WebRequest
theRequest) throws ServletException, IOException

            { 

                        /* use this one to make the template public and
user instantiable 

                        NVPair[] form_data = new NVPair[] { new
NVPair("public", "someValue"); 

                        new NVPair("usersetup", "someValue"); }; 

                        */ 

                         

            //          use this one for basic testing where we are
simply 

            //          uploading the template, not setting any
attributes on it 

                        NVPair[] form_data = null;

                        

                        if(logger.isInfoEnabled()) {

                                    logger.info("Upload Tester : Started
beginUploadFile");

                        }

                        

                        System.out.println("Upload Tester : Started
beginUploadFile");

                        

            //          setup the file(s) name value pair object.  

                        System.out.println("Start of BeginUpload File");

                        NVPair[] file = { new
NVPair("fileList[0].profile","C:/INSTALL.LOG"), new
NVPair("fileList[1].profile","C:/LOGFILE.txt") }; 

                         

                        try  

                        { 

                                    byte[] data =
Codecs.mpFormDataEncode(form_data, file, hdrs); 

                                    InputStream i = new
ByteArrayInputStream(data); 

                                    theRequest.setUserData(i); 

 
theRequest.setContentType(hdrs[0].getValue()); 

                                    i.close(); 

                        } catch (IOException e)  

                        { 

                                    System.out.println("Error Building
Multipart"); 

                                    if(logger.isInfoEnabled()) {

                                                logger.info("Error
Building Multipart");

                                    }

                                    logger.debug("Error Building
Multipart");

                        } 

                        if(logger.isInfoEnabled()) {

                                    logger.info("testUploadFile --
End");

                                    

                        }

                        System.out.println("testUploadFile -- End");

                        System.out.println("End of BeginUpload File");

            } 

            

            public void testUploadFile() throws ServletException,
IOException

            { 

//          *********************************** 

//          need to put an admin into the session here 

//          *********************************** 

            //NxUser u = NxUserAdmin.getNxUser("admin"); 

            //getSession().setAttribute("NxUser", u); 

            

            if(logger.isInfoEnabled()) {

                        logger.info("testUploadFile -- Start");

            }

            System.out.println("testUploadFile -- Start");

//          grab the output stream to do some console writing 

            ServletOutputStreamSimulator sos = new
ServletOutputStreamSimulator(); 

             

            sos.println("\n\n************************************"); 

            //sos.println("# templates before action call: "+
NxTemplateAdmin.getNxTemplates().length); 

            sos.println("************************************\n\n"); 

             

            setRequestPathInfo("/loadtasks.loadextract.do"); 

            if(logger.isInfoEnabled()) {

                        logger.info("testUploadFile -- Before action
call");

            }

            System.out.println("testUploadFile -- Before action call");

            actionPerform(); 

            

            if(logger.isInfoEnabled()) {

                        logger.info("testUploadFile -- after action
call");

            }

            System.out.println("testUploadFile -- after action call");

            verifyForward("success"); 

 
//verifyForwardPath("/modules/com/hyperion/hfm/web/loadtasks/loadmetadat
a/temp.jsp"); 

            verifyNoActionErrors(); 

             

            sos.println("\n\n************************************"); 

            //sos.println("# templates after action call: "+
NxTemplateAdmin.getNxTemplates().length); 

            sos.println("************************************\n\n"); 

             

            } 

             

            public static void main(String[] args) {

                        junit.textui.TestRunner.run(Tester.class);

            }

            

            public void tearDown() throws Exception {

                        logger.info("*** tearDown() - start ***");

                        super.tearDown();

                        logger.info("*** tearDown() - end ***");

            }

 

}

 

My web.xml has the following entry

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN"

       "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

      

       <filter>

      <filter-name>FilterRedirector</filter-name>

      <filter-class>

         org.apache.cactus.server.FilterTestRedirector

      </filter-class>

   </filter>

   <filter-mapping>

      <filter-name>FilterRedirector</filter-name>

      <url-pattern>/FilterRedirector</url-pattern>

   </filter-mapping>

      

      <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/conf/struts-config.xml</param-value>

                  </init-param>

                  <load-on-startup>1</load-on-startup>

            </servlet>

      <servlet>

 

      <servlet-name>ServletRedirector</servlet-name>

 
<servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-c
lass>

      </servlet>

      <servlet>

      <servlet-name>JspRedirector</servlet-name>

      <jsp-file>/jspRedirector.jsp</jsp-file>

   </servlet>

      

 

      <servlet-mapping>

            <servlet-name>ServletRedirector</servlet-name>

            <url-pattern>/ServletRedirector</url-pattern>

      </servlet-mapping>

      <servlet-mapping>

      <servlet-name>JspRedirector</servlet-name>

      <url-pattern>/JspRedirector</url-pattern>

   </servlet-mapping>

      

      

      <servlet-mapping>

            <servlet-name>action</servlet-name>

            <url-pattern>*.do</url-pattern>

      </servlet-mapping>

 

      

</web-app>

 

 

And my cactus.properties is as follows:

 

cactus.contextURL = http://localhost:8080/abc/

cactus.username=admin

cactus.password=password

cactus.clusterServiceHost= localhost

cactus.appServiceHost= localhost

cactus.securityServiceHost=localhost

cactus.cluster= localhost

cactus.server= localhost

cactus.servletRedirectorName=ServletRedirector

cactus.jspRedirectorName=JspRedirector

cactus.filterRedirectorName=FilterRedirector

# must be 10 character or less

cactus.newAppName=JUnitTest

cactus.newAppDescription=New Application

cactus.provisioningProject=abc

cactus.serverUrl=http:// localhost:80/abc


Re: Please Help me, the beginXXX() method is not getting called

Posted by Kazuhito SUGURI <su...@lab.ntt.co.jp>.
Hi Kumuda,

In article <85...@BLRMAIL.symphonysv.com>,
Mon, 13 Mar 2006 17:56:44 +0530,
"Kumuda Bhaskar" <Ku...@symphonysv.com> wrote: 
Kumuda> I am using tomcat 5.0.4 and the beginXXX method is not getting called.

You must show us logs so that we can see there is the problem.

Are you seeing a client-side log to judge that
the beginXXX method is not getting called?
If you are only seeing log files of tomcat (i.e. server-side),
you cannnot find any info coded in the beginXXX method in there.


Kumuda> My Tester is as follows:
[snip]
Kumuda>             public static void main(String[] args) {
Kumuda> 
Kumuda>                         junit.textui.TestRunner.run(Tester.class);
Kumuda> 
Kumuda>             }

You have a good method :-)
Have you tried `java Tester` from command line?
What info did you see on your console?

Regards,
----
Kazuhito SUGURI