You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by su...@apache.org on 2002/10/27 18:05:52 UTC

cvs commit: jakarta-commons/fileupload/src/test/org/apache/commons/fileupload MultipartStreamTest.java MyHttpServletRequest.java FileUploadTest.java

sullis      2002/10/27 09:05:52

  Modified:    fileupload/src/test/org/apache/commons/fileupload
                        MultipartStreamTest.java MyHttpServletRequest.java
                        FileUploadTest.java
  Log:
  enhanced test code
  
  Revision  Changes    Path
  1.2       +2 -1      jakarta-commons/fileupload/src/test/org/apache/commons/fileupload/MultipartStreamTest.java
  
  Index: MultipartStreamTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/test/org/apache/commons/fileupload/MultipartStreamTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultipartStreamTest.java	26 Oct 2002 22:42:34 -0000	1.1
  +++ MultipartStreamTest.java	27 Oct 2002 17:05:52 -0000	1.2
  @@ -68,6 +68,7 @@
   
       public void testMultipartStream()
       {
  -    	// todo - implement
  +    	// todo 
       }
  +
   }
  
  
  
  1.2       +6 -2      jakarta-commons/fileupload/src/test/org/apache/commons/fileupload/MyHttpServletRequest.java
  
  Index: MyHttpServletRequest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/test/org/apache/commons/fileupload/MyHttpServletRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MyHttpServletRequest.java	27 Oct 2002 02:41:20 -0000	1.1
  +++ MyHttpServletRequest.java	27 Oct 2002 17:05:52 -0000	1.2
  @@ -28,6 +28,7 @@
   
   	private byte[] m_requestData;
   	private String m_strContentType;
  +	private Map m_headers = new java.util.HashMap();
   	
   	public MyHttpServletRequest(
   			final byte[] requestData,
  @@ -35,6 +36,7 @@
   	{
   		m_requestData = requestData;
   		m_strContentType = strContentType;
  +		m_headers.put(FileUpload.CONTENT_TYPE, strContentType);
   	}
   
   	/**
  @@ -64,9 +66,9 @@
   	/**
   	 * @see javax.servlet.http.HttpServletRequest#getHeader(String)
   	 */
  -	public String getHeader(String arg0)
  +	public String getHeader(String headerName)
   	{
  -		return null;
  +		return (String) m_headers.get(headerName);
   	}
   
   	/**
  @@ -74,6 +76,7 @@
   	 */
   	public Enumeration getHeaders(String arg0)
   	{
  +		// todo - implement
   		return null;
   	}
   
  @@ -82,6 +85,7 @@
   	 */
   	public Enumeration getHeaderNames()
   	{
  +		// todo - implement
   		return null;
   	}
   
  
  
  
  1.3       +47 -0     jakarta-commons/fileupload/src/test/org/apache/commons/fileupload/FileUploadTest.java
  
  Index: FileUploadTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/test/org/apache/commons/fileupload/FileUploadTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileUploadTest.java	26 Oct 2002 22:43:01 -0000	1.2
  +++ FileUploadTest.java	27 Oct 2002 17:05:52 -0000	1.3
  @@ -57,6 +57,7 @@
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  +import javax.servlet.http.HttpServletRequest;
   
   /**
    * Unit tests {@link org.apache.commons.fileupload.FileUpload}.
  @@ -65,6 +66,52 @@
    */
   public class FileUploadTest extends TestCase
   {
  +	public void testWithInvalidRequest()
  +    {
  +    	HttpServletRequest hsr = HttpServletRequestFactory.createInvalidHttpServletRequest();
  +    	
  +    	FileUpload fu = null;
  +    	
  +    	fu = new FileUpload();
  +    	
  +    	HttpServletRequest req = HttpServletRequestFactory.createInvalidHttpServletRequest();
  +    	
  +    	try
  +    	{
  +    		fu.parseRequest(req);
  +    		fail("expected exception was not thrown");
  +    	}
  +    	catch (FileUploadException expected)
  +    	{
  +    		// this exception is expected
  +    	}
  +    	
  +    }
  +
  +
  +	public void testWithNullContentType()
  +    {
  +    	HttpServletRequest hsr = HttpServletRequestFactory.createInvalidHttpServletRequest();
  +    	
  +    	FileUpload fu = null;
  +    	
  +    	fu = new FileUpload();
  +    	
  +    	HttpServletRequest req = HttpServletRequestFactory.createHttpServletRequestWithNullContentType();
  +    	
  +    	try
  +    	{
  +    		fu.parseRequest(req);
  +    		fail("expected exception was not thrown");
  +    	}
  +    	catch (FileUploadException expected)
  +    	{
  +    		// this exception is expected
  +    	}
  +    	
  +    }
  +
  +
       public FileUploadTest(String name)
       {
           super(name);
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>