You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by kanth <re...@gmail.com> on 2008/08/26 07:43:10 UTC

How can i send multipart/form-data request to a servlet which under unit testing by using cacuts

Hi all,
      i am doing unit testing for a servlet by using cactus. i am getting
error at servletfileupload. 
        

        FileItemFactory factory = new DiskFileItemFactory();
        //Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        //NOTE: This progress listener can be useful
        //Create a progress listener
        ProgressListener progressListener = new ProgressListener()
        {
            public void update(long pBytesRead, long pContentLength, int
pItems) {
                logger.info("We are currently reading item " + pItems);
                if(pContentLength>307200)
                	throw new MmsReportingException(MmsResponseCodes.
               			 CONTENT_LENGTH_EXCEEDED_ERROR,
               			 "The Size of The Attachment is Exceeded ");
                if(pBytesRead>307200)
                	throw new MmsReportingException(MmsResponseCodes.
                			CONTENT_LENGTH_EXCEEDED_ERROR,
                			"The Size of The Attachment is Exceeded ");
                if(pContentLength>0)
                    logger.info("So far, " + pBytesRead + " of " +
pContentLength
                            + " bytes have been read.");
                else
                	logger.info("So far, " + pBytesRead + " bytes have been
read.");
             }
        };
        upload.setProgressListener(progressListener);

        //Parse the request
        List<FileItem> items = null;
		try {
			items = upload.parseRequest(request);
		
		} catch( FileUploadException e) {
			throw new MmsReportingException(MmsResponseCodes.NETWORK_ERROR);
		} 


in actual servlet the request is of type "multipart/form-data".
i am getting the error at the code which i gave bold font.
pls help me.
-- 
View this message in context: http://www.nabble.com/How-can-i-send-multipart-form-data-request-to-a-servlet-which-under-unit-testing-by-using-cacuts-tp19156102p19156102.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.