activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kanth <reddy.pes...@gmail.com>
Subject How can i send multipart/form-data request to a servlet which under unit testing by using cacuts
Date Tue, 26 Aug 2008 05:43:10 GMT

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.


Mime
View raw message