You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2013/03/05 22:20:30 UTC

svn commit: r1453002 - /commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/

Author: simonetripodi
Date: Tue Mar  5 21:20:29 2013
New Revision: 1453002

URL: http://svn.apache.org/r1453002
Log:
trivial: no tabs, spaces only

Modified:
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileUploadTestCase.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/HttpServletRequestFactory.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/SizesTest.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/StreamingTest.java

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java Tue Mar  5 21:20:29 2013
@@ -33,52 +33,52 @@ public class FileItemHeadersTest extends
      * @throws Exception
      */
     public void testFileItemHeaders() throws Exception {
-    	FileItemHeadersImpl aMutableFileItemHeaders = new FileItemHeadersImpl();
-    	aMutableFileItemHeaders.addHeader("Content-Disposition", "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
-    	aMutableFileItemHeaders.addHeader("Content-Type", "text/plain");
-
-    	aMutableFileItemHeaders.addHeader("TestHeader", "headerValue1");
-    	aMutableFileItemHeaders.addHeader("TestHeader", "headerValue2");
-    	aMutableFileItemHeaders.addHeader("TestHeader", "headerValue3");
-    	aMutableFileItemHeaders.addHeader("testheader", "headerValue4");
-
-    	Iterator<String> headerNameEnumeration = aMutableFileItemHeaders.getHeaderNames();
-    	assertEquals("content-disposition", (String) headerNameEnumeration.next());
-    	assertEquals("content-type", (String) headerNameEnumeration.next());
-    	assertEquals("testheader", (String) headerNameEnumeration.next());
-    	assertFalse(headerNameEnumeration.hasNext());
-
-    	assertEquals(aMutableFileItemHeaders.getHeader("Content-Disposition"), "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
-    	assertEquals(aMutableFileItemHeaders.getHeader("Content-Type"), "text/plain");
-    	assertEquals(aMutableFileItemHeaders.getHeader("content-type"), "text/plain");
-    	assertEquals(aMutableFileItemHeaders.getHeader("TestHeader"), "headerValue1");
-    	assertNull(aMutableFileItemHeaders.getHeader("DummyHeader"));
-
-    	Iterator<String> headerValueEnumeration;
-
-    	headerValueEnumeration = aMutableFileItemHeaders.getHeaders("Content-Type");
-    	assertTrue(headerValueEnumeration.hasNext());
-    	assertEquals(headerValueEnumeration.next(), "text/plain");
-    	assertFalse(headerValueEnumeration.hasNext());
-
-    	headerValueEnumeration = aMutableFileItemHeaders.getHeaders("content-type");
-    	assertTrue(headerValueEnumeration.hasNext());
-    	assertEquals(headerValueEnumeration.next(), "text/plain");
-    	assertFalse(headerValueEnumeration.hasNext());
-
-    	headerValueEnumeration = aMutableFileItemHeaders.getHeaders("TestHeader");
-    	assertTrue(headerValueEnumeration.hasNext());
-    	assertEquals(headerValueEnumeration.next(), "headerValue1");
-    	assertTrue(headerValueEnumeration.hasNext());
-    	assertEquals(headerValueEnumeration.next(), "headerValue2");
-    	assertTrue(headerValueEnumeration.hasNext());
-    	assertEquals(headerValueEnumeration.next(), "headerValue3");
-    	assertTrue(headerValueEnumeration.hasNext());
-    	assertEquals(headerValueEnumeration.next(), "headerValue4");
-    	assertFalse(headerValueEnumeration.hasNext());
+        FileItemHeadersImpl aMutableFileItemHeaders = new FileItemHeadersImpl();
+        aMutableFileItemHeaders.addHeader("Content-Disposition", "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
+        aMutableFileItemHeaders.addHeader("Content-Type", "text/plain");
+
+        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue1");
+        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue2");
+        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue3");
+        aMutableFileItemHeaders.addHeader("testheader", "headerValue4");
+
+        Iterator<String> headerNameEnumeration = aMutableFileItemHeaders.getHeaderNames();
+        assertEquals("content-disposition", (String) headerNameEnumeration.next());
+        assertEquals("content-type", (String) headerNameEnumeration.next());
+        assertEquals("testheader", (String) headerNameEnumeration.next());
+        assertFalse(headerNameEnumeration.hasNext());
+
+        assertEquals(aMutableFileItemHeaders.getHeader("Content-Disposition"), "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
+        assertEquals(aMutableFileItemHeaders.getHeader("Content-Type"), "text/plain");
+        assertEquals(aMutableFileItemHeaders.getHeader("content-type"), "text/plain");
+        assertEquals(aMutableFileItemHeaders.getHeader("TestHeader"), "headerValue1");
+        assertNull(aMutableFileItemHeaders.getHeader("DummyHeader"));
+
+        Iterator<String> headerValueEnumeration;
+
+        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("Content-Type");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "text/plain");
+        assertFalse(headerValueEnumeration.hasNext());
+
+        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("content-type");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "text/plain");
+        assertFalse(headerValueEnumeration.hasNext());
+
+        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("TestHeader");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "headerValue1");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "headerValue2");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "headerValue3");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "headerValue4");
+        assertFalse(headerValueEnumeration.hasNext());
 
-    	headerValueEnumeration = aMutableFileItemHeaders.getHeaders("DummyHeader");
-    	assertFalse(headerValueEnumeration.hasNext());
+        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("DummyHeader");
+        assertFalse(headerValueEnumeration.hasNext());
     }
 
 }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileUploadTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileUploadTestCase.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileUploadTestCase.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileUploadTestCase.java Tue Mar  5 21:20:29 2013
@@ -31,24 +31,24 @@ import junit.framework.TestCase;
  * Base class for deriving test cases.
  */
 public abstract class FileUploadTestCase extends TestCase {
-	protected static final String CONTENT_TYPE = "multipart/form-data; boundary=---1234";
+    protected static final String CONTENT_TYPE = "multipart/form-data; boundary=---1234";
 
-	protected List<FileItem> parseUpload(byte[] bytes) throws FileUploadException {
+    protected List<FileItem> parseUpload(byte[] bytes) throws FileUploadException {
         return parseUpload(bytes, CONTENT_TYPE);
     }
 
-	protected List<FileItem> parseUpload(byte[] bytes, String contentType) throws FileUploadException {
-		ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
+    protected List<FileItem> parseUpload(byte[] bytes, String contentType) throws FileUploadException {
+        ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
         HttpServletRequest request = new MockHttpServletRequest(bytes, contentType);
 
         List<FileItem> fileItems = upload.parseRequest(request);
         return fileItems;
-	}
+    }
 
-	protected List<FileItem> parseUpload(String content)
-    	throws UnsupportedEncodingException, FileUploadException
+    protected List<FileItem> parseUpload(String content)
+        throws UnsupportedEncodingException, FileUploadException
     {
-		byte[] bytes = content.getBytes("US-ASCII");
-		return parseUpload(bytes, CONTENT_TYPE);
+        byte[] bytes = content.getBytes("US-ASCII");
+        return parseUpload(bytes, CONTENT_TYPE);
     }
 }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/HttpServletRequestFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/HttpServletRequestFactory.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/HttpServletRequestFactory.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/HttpServletRequestFactory.java Tue Mar  5 21:20:29 2013
@@ -28,39 +28,39 @@ import javax.servlet.http.HttpServletReq
  */
 final class HttpServletRequestFactory
 {
-	static public HttpServletRequest createHttpServletRequestWithNullContentType()
-	{
-		byte[] requestData = "foobar".getBytes();
-		return new MockHttpServletRequest(
-							requestData,
-							null);
-	}
-
-	static public HttpServletRequest createValidHttpServletRequest(
-			final String[] strFileNames)
-	{
-		// todo - provide a real implementation
-
-		StringBuffer sbRequestData = new StringBuffer();
-
-		for (int i = 0; i < strFileNames.length; i++)
-		{
-			sbRequestData.append(strFileNames[i]);
-		}
-
-		byte[] requestData = null;
-		requestData = sbRequestData.toString().getBytes();
-
-		return new MockHttpServletRequest(
-							requestData,
-							FileUploadBase.MULTIPART_FORM_DATA);
-	}
-
-	static public HttpServletRequest createInvalidHttpServletRequest()
-	{
-		byte[] requestData = "foobar".getBytes();
-		return new MockHttpServletRequest(
-							requestData,
-							FileUploadBase.MULTIPART_FORM_DATA);
-	}
+    static public HttpServletRequest createHttpServletRequestWithNullContentType()
+    {
+        byte[] requestData = "foobar".getBytes();
+        return new MockHttpServletRequest(
+                            requestData,
+                            null);
+    }
+
+    static public HttpServletRequest createValidHttpServletRequest(
+            final String[] strFileNames)
+    {
+        // todo - provide a real implementation
+
+        StringBuffer sbRequestData = new StringBuffer();
+
+        for (int i = 0; i < strFileNames.length; i++)
+        {
+            sbRequestData.append(strFileNames[i]);
+        }
+
+        byte[] requestData = null;
+        requestData = sbRequestData.toString().getBytes();
+
+        return new MockHttpServletRequest(
+                            requestData,
+                            FileUploadBase.MULTIPART_FORM_DATA);
+    }
+
+    static public HttpServletRequest createInvalidHttpServletRequest()
+    {
+        byte[] requestData = "foobar".getBytes();
+        return new MockHttpServletRequest(
+                            requestData,
+                            FileUploadBase.MULTIPART_FORM_DATA);
+    }
 }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java Tue Mar  5 21:20:29 2013
@@ -43,511 +43,511 @@ import javax.servlet.http.HttpSession;
 class MockHttpServletRequest implements HttpServletRequest
 {
 
-	private final InputStream m_requestData;
-	private final int length;
-	private String m_strContentType;
-	private Map<String, String> m_headers = new java.util.HashMap<String, String>();
-
-	/**
-	 * Creates a new instance with the given request data
-	 * and content type.
-	 */
-	public MockHttpServletRequest(
-			final byte[] requestData,
-			final String strContentType)
-	{
-		this(new ByteArrayInputStream(requestData),
-				requestData.length, strContentType);
-	}
-
-	/**
-	 * Creates a new instance with the given request data
-	 * and content type.
-	 */
-	public MockHttpServletRequest(
-			final InputStream requestData,
-			final int requestLength,
-			final String strContentType)
-	{
-		m_requestData = requestData;
-		length = requestLength;
-		m_strContentType = strContentType;
-		m_headers.put(FileUploadBase.CONTENT_TYPE, strContentType);
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getAuthType()
-	 */
-	public String getAuthType()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getCookies()
-	 */
-	public Cookie[] getCookies()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getDateHeader(String)
-	 */
-	public long getDateHeader(String arg0)
-	{
-		return 0;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getHeader(String)
-	 */
-	public String getHeader(String headerName)
-	{
-		return (String) m_headers.get(headerName);
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getHeaders(String)
-	 */
-	public Enumeration<String> getHeaders(String arg0)
-	{
-		// todo - implement
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
-	 */
-	public Enumeration<String> getHeaderNames()
-	{
-		// todo - implement
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getIntHeader(String)
-	 */
-	public int getIntHeader(String arg0)
-	{
-		return 0;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getMethod()
-	 */
-	public String getMethod()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getPathInfo()
-	 */
-	public String getPathInfo()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
-	 */
-	public String getPathTranslated()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getContextPath()
-	 */
-	public String getContextPath()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getQueryString()
-	 */
-	public String getQueryString()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
-	 */
-	public String getRemoteUser()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#isUserInRole(String)
-	 */
-	public boolean isUserInRole(String arg0)
-	{
-		return false;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
-	 */
-	public Principal getUserPrincipal()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
-	 */
-	public String getRequestedSessionId()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getRequestURI()
-	 */
-	public String getRequestURI()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getRequestURL()
-	 */
-	public StringBuffer getRequestURL()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getServletPath()
-	 */
-	public String getServletPath()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
-	 */
-	public HttpSession getSession(boolean arg0)
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#getSession()
-	 */
-	public HttpSession getSession()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
-	 */
-	public boolean isRequestedSessionIdValid()
-	{
-		return false;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
-	 */
-	public boolean isRequestedSessionIdFromCookie()
-	{
-		return false;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
-	 */
-	public boolean isRequestedSessionIdFromURL()
-	{
-		return false;
-	}
-
-	/**
-	 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
-	 * @deprecated
-	 */
-	public boolean isRequestedSessionIdFromUrl()
-	{
-		return false;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getAttribute(String)
-	 */
-	public Object getAttribute(String arg0)
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getAttributeNames()
-	 */
-	public Enumeration<String> getAttributeNames()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getCharacterEncoding()
-	 */
-	public String getCharacterEncoding()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#setCharacterEncoding(String)
-	 */
-	public void setCharacterEncoding(String arg0)
-		throws UnsupportedEncodingException
-	{
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getContentLength()
-	 */
-	public int getContentLength()
-	{
-		int iLength = 0;
-
-		if (null == m_requestData)
-		{
-			iLength = -1;
-		}
-		else
-		{
-			iLength = length;
-		}
-		return iLength;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getContentType()
-	 */
-	public String getContentType()
-	{
-		return m_strContentType;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getInputStream()
-	 */
-	public ServletInputStream getInputStream() throws IOException
-	{
-		ServletInputStream sis = new MyServletInputStream(m_requestData);
-		return sis;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getParameter(String)
-	 */
-	public String getParameter(String arg0)
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getParameterNames()
-	 */
-	public Enumeration<String> getParameterNames()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getParameterValues(String)
-	 */
-	public String[] getParameterValues(String arg0)
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getParameterMap()
-	 */
-	public Map<String, String[]> getParameterMap()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getProtocol()
-	 */
-	public String getProtocol()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getScheme()
-	 */
-	public String getScheme()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getServerName()
-	 */
-	public String getServerName()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getLocalName()
-	 */
-	public String getLocalName()
-	{
-	    return null;
-	}
-
-    /**
-	 * @see javax.servlet.ServletRequest#getServerPort()
-	 */
-	public int getServerPort()
-	{
-		return 0;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getLocalPort()
-	 */
-	public int getLocalPort()
-	{
-	    return 0;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getRemotePort()
-	 */
-	public int getRemotePort()
-	{
-	    return 0;
-	}
-
-    /**
-	 * @see javax.servlet.ServletRequest#getReader()
-	 */
-	public BufferedReader getReader() throws IOException
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getRemoteAddr()
-	 */
-	public String getRemoteAddr()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getLocalAddr()
-	 */
-	public String getLocalAddr()
-	{
-	    return null;
-	}
-
-    /**
-	 * @see javax.servlet.ServletRequest#getRemoteHost()
-	 */
-	public String getRemoteHost()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#setAttribute(String, Object)
-	 */
-	public void setAttribute(String arg0, Object arg1)
-	{
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#removeAttribute(String)
-	 */
-	public void removeAttribute(String arg0)
-	{
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getLocale()
-	 */
-	public Locale getLocale()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getLocales()
-	 */
-	public Enumeration<Locale> getLocales()
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#isSecure()
-	 */
-	public boolean isSecure()
-	{
-		return false;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getRequestDispatcher(String)
-	 */
-	public RequestDispatcher getRequestDispatcher(String arg0)
-	{
-		return null;
-	}
-
-	/**
-	 * @see javax.servlet.ServletRequest#getRealPath(String)
-	 * @deprecated
-	 */
-	public String getRealPath(String arg0)
-	{
-		return null;
-	}
-
-	/**
-	 *
-	 *
-	 *
-	 *
-	 */
-	private static class MyServletInputStream
-		extends javax.servlet.ServletInputStream
-	{
-		private final InputStream in;
-
-		/**
-		 * Creates a new instance, which returns the given
-		 * streams data.
-		 */
-		public MyServletInputStream(InputStream pStream)
-		{
-			in = pStream;
-		}
-
-		public int read() throws IOException
-		{
-			return in.read();
-		}
-
-		public int read(byte b[], int off, int len) throws IOException
-		{
-		    return in.read(b, off, len);
-		}
-	}
+    private final InputStream m_requestData;
+    private final int length;
+    private String m_strContentType;
+    private Map<String, String> m_headers = new java.util.HashMap<String, String>();
+
+    /**
+     * Creates a new instance with the given request data
+     * and content type.
+     */
+    public MockHttpServletRequest(
+            final byte[] requestData,
+            final String strContentType)
+    {
+        this(new ByteArrayInputStream(requestData),
+                requestData.length, strContentType);
+    }
+
+    /**
+     * Creates a new instance with the given request data
+     * and content type.
+     */
+    public MockHttpServletRequest(
+            final InputStream requestData,
+            final int requestLength,
+            final String strContentType)
+    {
+        m_requestData = requestData;
+        length = requestLength;
+        m_strContentType = strContentType;
+        m_headers.put(FileUploadBase.CONTENT_TYPE, strContentType);
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getAuthType()
+     */
+    public String getAuthType()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getCookies()
+     */
+    public Cookie[] getCookies()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getDateHeader(String)
+     */
+    public long getDateHeader(String arg0)
+    {
+        return 0;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getHeader(String)
+     */
+    public String getHeader(String headerName)
+    {
+        return (String) m_headers.get(headerName);
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getHeaders(String)
+     */
+    public Enumeration<String> getHeaders(String arg0)
+    {
+        // todo - implement
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
+     */
+    public Enumeration<String> getHeaderNames()
+    {
+        // todo - implement
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getIntHeader(String)
+     */
+    public int getIntHeader(String arg0)
+    {
+        return 0;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getMethod()
+     */
+    public String getMethod()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getPathInfo()
+     */
+    public String getPathInfo()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
+     */
+    public String getPathTranslated()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getContextPath()
+     */
+    public String getContextPath()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getQueryString()
+     */
+    public String getQueryString()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
+     */
+    public String getRemoteUser()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#isUserInRole(String)
+     */
+    public boolean isUserInRole(String arg0)
+    {
+        return false;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
+     */
+    public Principal getUserPrincipal()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
+     */
+    public String getRequestedSessionId()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getRequestURI()
+     */
+    public String getRequestURI()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getRequestURL()
+     */
+    public StringBuffer getRequestURL()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getServletPath()
+     */
+    public String getServletPath()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
+     */
+    public HttpSession getSession(boolean arg0)
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getSession()
+     */
+    public HttpSession getSession()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
+     */
+    public boolean isRequestedSessionIdValid()
+    {
+        return false;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
+     */
+    public boolean isRequestedSessionIdFromCookie()
+    {
+        return false;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
+     */
+    public boolean isRequestedSessionIdFromURL()
+    {
+        return false;
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
+     * @deprecated
+     */
+    public boolean isRequestedSessionIdFromUrl()
+    {
+        return false;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getAttribute(String)
+     */
+    public Object getAttribute(String arg0)
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getAttributeNames()
+     */
+    public Enumeration<String> getAttributeNames()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getCharacterEncoding()
+     */
+    public String getCharacterEncoding()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#setCharacterEncoding(String)
+     */
+    public void setCharacterEncoding(String arg0)
+        throws UnsupportedEncodingException
+    {
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getContentLength()
+     */
+    public int getContentLength()
+    {
+        int iLength = 0;
+
+        if (null == m_requestData)
+        {
+            iLength = -1;
+        }
+        else
+        {
+            iLength = length;
+        }
+        return iLength;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getContentType()
+     */
+    public String getContentType()
+    {
+        return m_strContentType;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getInputStream()
+     */
+    public ServletInputStream getInputStream() throws IOException
+    {
+        ServletInputStream sis = new MyServletInputStream(m_requestData);
+        return sis;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getParameter(String)
+     */
+    public String getParameter(String arg0)
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getParameterNames()
+     */
+    public Enumeration<String> getParameterNames()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getParameterValues(String)
+     */
+    public String[] getParameterValues(String arg0)
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getParameterMap()
+     */
+    public Map<String, String[]> getParameterMap()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getProtocol()
+     */
+    public String getProtocol()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getScheme()
+     */
+    public String getScheme()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getServerName()
+     */
+    public String getServerName()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getLocalName()
+     */
+    public String getLocalName()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getServerPort()
+     */
+    public int getServerPort()
+    {
+        return 0;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getLocalPort()
+     */
+    public int getLocalPort()
+    {
+        return 0;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getRemotePort()
+     */
+    public int getRemotePort()
+    {
+        return 0;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getReader()
+     */
+    public BufferedReader getReader() throws IOException
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getRemoteAddr()
+     */
+    public String getRemoteAddr()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getLocalAddr()
+     */
+    public String getLocalAddr()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getRemoteHost()
+     */
+    public String getRemoteHost()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#setAttribute(String, Object)
+     */
+    public void setAttribute(String arg0, Object arg1)
+    {
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#removeAttribute(String)
+     */
+    public void removeAttribute(String arg0)
+    {
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getLocale()
+     */
+    public Locale getLocale()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getLocales()
+     */
+    public Enumeration<Locale> getLocales()
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#isSecure()
+     */
+    public boolean isSecure()
+    {
+        return false;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getRequestDispatcher(String)
+     */
+    public RequestDispatcher getRequestDispatcher(String arg0)
+    {
+        return null;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getRealPath(String)
+     * @deprecated
+     */
+    public String getRealPath(String arg0)
+    {
+        return null;
+    }
+
+    /**
+     *
+     *
+     *
+     *
+     */
+    private static class MyServletInputStream
+        extends javax.servlet.ServletInputStream
+    {
+        private final InputStream in;
+
+        /**
+         * Creates a new instance, which returns the given
+         * streams data.
+         */
+        public MyServletInputStream(InputStream pStream)
+        {
+            in = pStream;
+        }
+
+        public int read() throws IOException
+        {
+            return in.read();
+        }
+
+        public int read(byte b[], int off, int len) throws IOException
+        {
+            return in.read(b, off, len);
+        }
+    }
 }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java Tue Mar  5 21:20:29 2013
@@ -29,29 +29,29 @@ import java.io.*;
  */
 public class MultipartStreamTest extends TestCase
 {
-	static private final String BOUNDARY_TEXT = "myboundary";
+    static private final String BOUNDARY_TEXT = "myboundary";
 
     public void testThreeParamConstructor() throws Exception {
-		final String strData = "foobar";
-		final byte[] contents = strData.getBytes();
-		InputStream input = new ByteArrayInputStream(contents);
-    	byte[] boundary = BOUNDARY_TEXT.getBytes();
-    	int iBufSize = boundary.length;
-    	MultipartStream ms = new MultipartStream(
-    			input,
-    			boundary,
-    			iBufSize,
-    			new MultipartStream.ProgressNotifier(null, contents.length));
+        final String strData = "foobar";
+        final byte[] contents = strData.getBytes();
+        InputStream input = new ByteArrayInputStream(contents);
+        byte[] boundary = BOUNDARY_TEXT.getBytes();
+        int iBufSize = boundary.length;
+        MultipartStream ms = new MultipartStream(
+                input,
+                boundary,
+                iBufSize,
+                new MultipartStream.ProgressNotifier(null, contents.length));
     }
 
-	public void testTwoParamConstructor() throws Exception {
-		final String strData = "foobar";
-		final byte[] contents = strData.getBytes();
-		InputStream input = new ByteArrayInputStream(contents);
-		byte[] boundary = BOUNDARY_TEXT.getBytes();
-		MultipartStream ms = new MultipartStream(
-				input,
-				boundary,
-				new MultipartStream.ProgressNotifier(null, contents.length));
-	}
+    public void testTwoParamConstructor() throws Exception {
+        final String strData = "foobar";
+        final byte[] contents = strData.getBytes();
+        InputStream input = new ByteArrayInputStream(contents);
+        byte[] boundary = BOUNDARY_TEXT.getBytes();
+        MultipartStream ms = new MultipartStream(
+                input,
+                boundary,
+                new MultipartStream.ProgressNotifier(null, contents.length));
+    }
 }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java Tue Mar  5 21:20:29 2013
@@ -27,36 +27,36 @@ import org.apache.commons.fileupload.ser
 /** Tests the progress listener.
  */
 public class ProgressListenerTest extends FileUploadTestCase {
-	private class ProgressListenerImpl implements ProgressListener {
-		private final long expectedContentLength;
-		private final int expectedItems;
-		private Long bytesRead;
-		private Integer items;
-		ProgressListenerImpl(long pContentLength, int pItems) {
-			expectedContentLength = pContentLength;
-			expectedItems = pItems;
-		}
-		public void update(long pBytesRead, long pContentLength, int pItems) {
-			assertTrue(pBytesRead >= 0  &&  pBytesRead <= expectedContentLength);
-			assertTrue(pContentLength == -1  ||  pContentLength == expectedContentLength);
-			assertTrue(pItems >= 0  &&  pItems <= expectedItems);
+    private class ProgressListenerImpl implements ProgressListener {
+        private final long expectedContentLength;
+        private final int expectedItems;
+        private Long bytesRead;
+        private Integer items;
+        ProgressListenerImpl(long pContentLength, int pItems) {
+            expectedContentLength = pContentLength;
+            expectedItems = pItems;
+        }
+        public void update(long pBytesRead, long pContentLength, int pItems) {
+            assertTrue(pBytesRead >= 0  &&  pBytesRead <= expectedContentLength);
+            assertTrue(pContentLength == -1  ||  pContentLength == expectedContentLength);
+            assertTrue(pItems >= 0  &&  pItems <= expectedItems);
 
-			assertTrue(bytesRead == null  ||  pBytesRead >= bytesRead.longValue());
-			bytesRead = new Long(pBytesRead);
-			assertTrue(items == null  ||  pItems >= items.intValue());
-			items = new Integer(pItems);
-		}
-		void checkFinished(){
-			assertEquals(expectedContentLength, bytesRead.longValue());
-			assertEquals(expectedItems, items.intValue());
-		}
-	}
+            assertTrue(bytesRead == null  ||  pBytesRead >= bytesRead.longValue());
+            bytesRead = new Long(pBytesRead);
+            assertTrue(items == null  ||  pItems >= items.intValue());
+            items = new Integer(pItems);
+        }
+        void checkFinished(){
+            assertEquals(expectedContentLength, bytesRead.longValue());
+            assertEquals(expectedItems, items.intValue());
+        }
+    }
 
-	/**
-	 * Parse a very long file upload by using a progress listener.
-	 */
-	public void testProgressListener() throws Exception {
-		final int NUM_ITEMS = 512;
+    /**
+     * Parse a very long file upload by using a progress listener.
+     */
+    public void testProgressListener() throws Exception {
+        final int NUM_ITEMS = 512;
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         for (int i = 0;  i < NUM_ITEMS;  i++) {
             String header = "-----1234\r\n"
@@ -74,37 +74,37 @@ public class ProgressListenerTest extend
         MockHttpServletRequest request = new MockHttpServletRequest(contents, "multipart/form-data; boundary=---1234");
         runTest(NUM_ITEMS, contents.length, request);
         request = new MockHttpServletRequest(contents, "multipart/form-data; boundary=---1234"){
-			public int getContentLength() {
-				return -1;
-			}        	
+            public int getContentLength() {
+                return -1;
+            }            
         };
         runTest(NUM_ITEMS, contents.length, request);
-	}
+    }
 
-	private void runTest(final int NUM_ITEMS, long pContentLength, MockHttpServletRequest request) throws FileUploadException, IOException {
-		ServletFileUpload upload = new ServletFileUpload();
+    private void runTest(final int NUM_ITEMS, long pContentLength, MockHttpServletRequest request) throws FileUploadException, IOException {
+        ServletFileUpload upload = new ServletFileUpload();
         ProgressListenerImpl listener = new ProgressListenerImpl(pContentLength, NUM_ITEMS);
         upload.setProgressListener(listener);
         FileItemIterator iter = upload.getItemIterator(request);
         for (int i = 0;  i < NUM_ITEMS;  i++) {
-        	FileItemStream stream = iter.next();
-        	InputStream istream = stream.openStream();
-        	for (int j = 0;  j < 16384+i;  j++) {
-        	    /**
+            FileItemStream stream = iter.next();
+            InputStream istream = stream.openStream();
+            for (int j = 0;  j < 16384+i;  j++) {
+                /**
                  * This used to be
                  *     assertEquals((byte) j, (byte) istream.read());
                  * but this seems to trigger a bug in JRockit, so
                  * we express the same like this:
-        	     */
+                 */
                 byte b1 = (byte) j;
                 byte b2 = (byte) istream.read();
                 if (b1 != b2) {
                     fail("Expected " + b1 + ", got " + b2);
                 }
-        	}
-        	assertEquals(-1, istream.read());
+            }
+            assertEquals(-1, istream.read());
         }
         assertTrue(!iter.hasNext());
         listener.checkFinished();
-	}
+    }
 }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ServletFileUploadTest.java Tue Mar  5 21:20:29 2013
@@ -31,46 +31,46 @@ import javax.servlet.http.HttpServletReq
  */
 public class ServletFileUploadTest extends FileUploadTestCase
 {
-	public void testWithInvalidRequest()
+    public void testWithInvalidRequest()
     {
-    	FileUploadBase fu = null;
+        FileUploadBase fu = null;
 
-    	fu = new DiskFileUpload();
+        fu = new DiskFileUpload();
 
-    	HttpServletRequest req = HttpServletRequestFactory.createInvalidHttpServletRequest();
+        HttpServletRequest req = HttpServletRequestFactory.createInvalidHttpServletRequest();
 
 
-    	try
-    	{
-    		fu.parseRequest(req);
-    		fail("testWithInvalidRequest: expected exception was not thrown");
-    	}
-    	catch (FileUploadException expected)
-    	{
-    		// this exception is expected
-    	}
+        try
+        {
+            fu.parseRequest(req);
+            fail("testWithInvalidRequest: expected exception was not thrown");
+        }
+        catch (FileUploadException expected)
+        {
+            // this exception is expected
+        }
 
     }
 
 
-	public void testWithNullContentType()
+    public void testWithNullContentType()
     {
-    	FileUploadBase fu = new DiskFileUpload();
+        FileUploadBase fu = new DiskFileUpload();
 
-    	HttpServletRequest req = HttpServletRequestFactory.createHttpServletRequestWithNullContentType();
+        HttpServletRequest req = HttpServletRequestFactory.createHttpServletRequestWithNullContentType();
 
-    	try
-    	{
-    		fu.parseRequest(req);
-    		fail("testWithNullContentType: expected exception was not thrown");
-    	}
-    	catch (DiskFileUpload.InvalidContentTypeException expected)
-    	{
-    		// this exception is expected
-    	}
+        try
+        {
+            fu.parseRequest(req);
+            fail("testWithNullContentType: expected exception was not thrown");
+        }
+        catch (DiskFileUpload.InvalidContentTypeException expected)
+        {
+            // this exception is expected
+        }
         catch (FileUploadException unexpected)
         {
-    		fail("testWithNullContentType: unexpected exception was thrown");
+            fail("testWithNullContentType: unexpected exception was thrown");
         }
 
     }
@@ -212,30 +212,30 @@ public class ServletFileUploadTest exten
      * Test for <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-62">FILEUPLOAD-62</a>
      */
     public void testFILEUPLOAD62() throws Exception {
-    	final String contentType = "multipart/form-data; boundary=AaB03x";
-    	final String request =
-    		"--AaB03x\r\n" +
-    		"content-disposition: form-data; name=\"field1\"\r\n" +
-    		"\r\n" +
-    		"Joe Blow\r\n" +
-    		"--AaB03x\r\n" +
-    		"content-disposition: form-data; name=\"pics\"\r\n" +
-    		"Content-type: multipart/mixed; boundary=BbC04y\r\n" +
-    		"\r\n" +
-    		"--BbC04y\r\n" +
-    		"Content-disposition: attachment; filename=\"file1.txt\"\r\n" +
-    		"Content-Type: text/plain\r\n" +
-    		"\r\n" +
-    		"... contents of file1.txt ...\r\n" +
-    		"--BbC04y\r\n" +
-    		"Content-disposition: attachment; filename=\"file2.gif\"\r\n" +
-    		"Content-type: image/gif\r\n" +
-    		"Content-Transfer-Encoding: binary\r\n" +
-    		"\r\n" +
-    		"...contents of file2.gif...\r\n" +
-    		"--BbC04y--\r\n" +
-    		"--AaB03x--";
-    	List<FileItem> fileItems = parseUpload(request.getBytes("US-ASCII"), contentType);
+        final String contentType = "multipart/form-data; boundary=AaB03x";
+        final String request =
+            "--AaB03x\r\n" +
+            "content-disposition: form-data; name=\"field1\"\r\n" +
+            "\r\n" +
+            "Joe Blow\r\n" +
+            "--AaB03x\r\n" +
+            "content-disposition: form-data; name=\"pics\"\r\n" +
+            "Content-type: multipart/mixed; boundary=BbC04y\r\n" +
+            "\r\n" +
+            "--BbC04y\r\n" +
+            "Content-disposition: attachment; filename=\"file1.txt\"\r\n" +
+            "Content-Type: text/plain\r\n" +
+            "\r\n" +
+            "... contents of file1.txt ...\r\n" +
+            "--BbC04y\r\n" +
+            "Content-disposition: attachment; filename=\"file2.gif\"\r\n" +
+            "Content-type: image/gif\r\n" +
+            "Content-Transfer-Encoding: binary\r\n" +
+            "\r\n" +
+            "...contents of file2.gif...\r\n" +
+            "--BbC04y--\r\n" +
+            "--AaB03x--";
+        List<FileItem> fileItems = parseUpload(request.getBytes("US-ASCII"), contentType);
         assertEquals(3, fileItems.size());
         FileItem item0 = (FileItem) fileItems.get(0);
         assertEquals("field1", item0.getFieldName());
@@ -255,51 +255,51 @@ public class ServletFileUploadTest exten
      * Test for <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-111">FILEUPLOAD-111</a>
      */
     public void testFoldedHeaders()
-    		throws IOException, FileUploadException {
-    	List<FileItem> fileItems = parseUpload("-----1234\r\n" +
-    			"Content-Disposition: form-data; name=\"file\"; filename=\"foo.tab\"\r\n" +
-    			"Content-Type: text/whatever\r\n" +
-    			"\r\n" +
-    			"This is the content of the file\n" +
-    			"\r\n" +
-    			"-----1234\r\n" +
-    			"Content-Disposition: form-data; \r\n" +
-    			"\tname=\"field\"\r\n" +
-    			"\r\n" +
-    			"fieldValue\r\n" +
-    			"-----1234\r\n" +
-    			"Content-Disposition: form-data;\r\n" +
-    			"     name=\"multi\"\r\n" +
-    			"\r\n" +
-    			"value1\r\n" +
-    			"-----1234\r\n" +
-    			"Content-Disposition: form-data; name=\"multi\"\r\n" +
-    			"\r\n" +
-    			"value2\r\n" +
-    			"-----1234--\r\n");
-    	assertEquals(4, fileItems.size());
-
-    	FileItem file = (FileItem) fileItems.get(0);
-    	assertEquals("file", file.getFieldName());
-    	assertFalse(file.isFormField());
-    	assertEquals("This is the content of the file\n", file.getString());
-    	assertEquals("text/whatever", file.getContentType());
-    	assertEquals("foo.tab", file.getName());
-
-    	FileItem field = (FileItem) fileItems.get(1);
-    	assertEquals("field", field.getFieldName());
-    	assertTrue(field.isFormField());
-    	assertEquals("fieldValue", field.getString());
-
-    	FileItem multi0 = (FileItem) fileItems.get(2);
-    	assertEquals("multi", multi0.getFieldName());
-    	assertTrue(multi0.isFormField());
-    	assertEquals("value1", multi0.getString());
-
-    	FileItem multi1 = (FileItem) fileItems.get(3);
-    	assertEquals("multi", multi1.getFieldName());
-    	assertTrue(multi1.isFormField());
-    	assertEquals("value2", multi1.getString());
+            throws IOException, FileUploadException {
+        List<FileItem> fileItems = parseUpload("-----1234\r\n" +
+                "Content-Disposition: form-data; name=\"file\"; filename=\"foo.tab\"\r\n" +
+                "Content-Type: text/whatever\r\n" +
+                "\r\n" +
+                "This is the content of the file\n" +
+                "\r\n" +
+                "-----1234\r\n" +
+                "Content-Disposition: form-data; \r\n" +
+                "\tname=\"field\"\r\n" +
+                "\r\n" +
+                "fieldValue\r\n" +
+                "-----1234\r\n" +
+                "Content-Disposition: form-data;\r\n" +
+                "     name=\"multi\"\r\n" +
+                "\r\n" +
+                "value1\r\n" +
+                "-----1234\r\n" +
+                "Content-Disposition: form-data; name=\"multi\"\r\n" +
+                "\r\n" +
+                "value2\r\n" +
+                "-----1234--\r\n");
+        assertEquals(4, fileItems.size());
+
+        FileItem file = (FileItem) fileItems.get(0);
+        assertEquals("file", file.getFieldName());
+        assertFalse(file.isFormField());
+        assertEquals("This is the content of the file\n", file.getString());
+        assertEquals("text/whatever", file.getContentType());
+        assertEquals("foo.tab", file.getName());
+
+        FileItem field = (FileItem) fileItems.get(1);
+        assertEquals("field", field.getFieldName());
+        assertTrue(field.isFormField());
+        assertEquals("fieldValue", field.getString());
+
+        FileItem multi0 = (FileItem) fileItems.get(2);
+        assertEquals("multi", multi0.getFieldName());
+        assertTrue(multi0.isFormField());
+        assertEquals("value1", multi0.getString());
+
+        FileItem multi1 = (FileItem) fileItems.get(3);
+        assertEquals("multi", multi1.getFieldName());
+        assertTrue(multi1.isFormField());
+        assertEquals("value2", multi1.getString());
     }
 
 

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/SizesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/SizesTest.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/SizesTest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/SizesTest.java Tue Mar  5 21:20:29 2013
@@ -32,9 +32,9 @@ import org.apache.commons.fileupload.ser
  */
 public class SizesTest extends FileUploadTestCase
 {
-	/** Runs a test with varying file sizes.
-	 */
-	public void testFileUpload()
+    /** Runs a test with varying file sizes.
+     */
+    public void testFileUpload()
             throws IOException, FileUploadException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -74,44 +74,44 @@ public class SizesTest extends FileUploa
         assertTrue(!fileIter.hasNext());
     }
 
-	/** Checks, whether limiting the file size works.
-	 */
-	public void testFileSizeLimit()
+    /** Checks, whether limiting the file size works.
+     */
+    public void testFileSizeLimit()
             throws IOException, FileUploadException
     {
-		final String request =
-			"-----1234\r\n" +
-			"Content-Disposition: form-data; name=\"file\"; filename=\"foo.tab\"\r\n" +
-			"Content-Type: text/whatever\r\n" +
-			"\r\n" +
-			"This is the content of the file\n" +
-			"\r\n" +
-			"-----1234--\r\n";
+        final String request =
+            "-----1234\r\n" +
+            "Content-Disposition: form-data; name=\"file\"; filename=\"foo.tab\"\r\n" +
+            "Content-Type: text/whatever\r\n" +
+            "\r\n" +
+            "This is the content of the file\n" +
+            "\r\n" +
+            "-----1234--\r\n";
 
-		ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
-		upload.setFileSizeMax(-1);
+        ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
+        upload.setFileSizeMax(-1);
         HttpServletRequest req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
         List<FileItem> fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
         FileItem item = (FileItem) fileItems.get(0);
         assertEquals("This is the content of the file\n", new String(item.get()));
 
-		upload = new ServletFileUpload(new DiskFileItemFactory());
-		upload.setFileSizeMax(40);
+        upload = new ServletFileUpload(new DiskFileItemFactory());
+        upload.setFileSizeMax(40);
         req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
         fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
         item = (FileItem) fileItems.get(0);
         assertEquals("This is the content of the file\n", new String(item.get()));
 
-		upload = new ServletFileUpload(new DiskFileItemFactory());
-		upload.setFileSizeMax(30);
+        upload = new ServletFileUpload(new DiskFileItemFactory());
+        upload.setFileSizeMax(30);
         req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
         try {
-        	upload.parseRequest(req);
-        	fail("Expected exception.");
+            upload.parseRequest(req);
+            fail("Expected exception.");
         } catch (FileUploadBase.FileSizeLimitExceededException e) {
-        	assertEquals(30, e.getPermittedSize());
+            assertEquals(30, e.getPermittedSize());
         }
     }
 }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/StreamingTest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/StreamingTest.java?rev=1453002&r1=1453001&r2=1453002&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/StreamingTest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/StreamingTest.java Tue Mar  5 21:20:29 2013
@@ -45,7 +45,7 @@ public class StreamingTest extends TestC
     public void testFileUpload()
             throws IOException, FileUploadException
     {
-    	byte[] request = newRequest();
+        byte[] request = newRequest();
         List<FileItem> fileItems = parseUpload(request);
         Iterator<FileItem> fileIter = fileItems.iterator();
         int add = 16;
@@ -71,50 +71,50 @@ public class StreamingTest extends TestC
      * exception.
      */
     public void testFileUploadException()
-    		throws IOException, FileUploadException {
-    	byte[] request = newRequest();
-    	byte[] invalidRequest = new byte[request.length-11];
-    	System.arraycopy(request, 0, invalidRequest, 0, request.length-11);
-    	try {
-    		parseUpload(invalidRequest);
-	        fail("Expected EndOfStreamException");
-    	} catch (IOFileUploadException e) {
-    		assertTrue(e.getCause() instanceof MultipartStream.MalformedStreamException);
-    	}
+            throws IOException, FileUploadException {
+        byte[] request = newRequest();
+        byte[] invalidRequest = new byte[request.length-11];
+        System.arraycopy(request, 0, invalidRequest, 0, request.length-11);
+        try {
+            parseUpload(invalidRequest);
+            fail("Expected EndOfStreamException");
+        } catch (IOFileUploadException e) {
+            assertTrue(e.getCause() instanceof MultipartStream.MalformedStreamException);
+        }
     }
 
     /**
      * Tests, whether an IOException is properly delegated.
      */
     public void testIOException()
-    		throws IOException {
-    	byte[] request = newRequest();
-    	InputStream stream = new FilterInputStream(new ByteArrayInputStream(request)){
-    		private int num;
-    		public int read() throws IOException {
-    			if (++num > 123) {
-    				throw new IOException("123");
-    			}
-    			return super.read();
-    		}
-			public int read(byte[] pB, int pOff, int pLen)
-					throws IOException {
-				for (int i = 0;  i < pLen;  i++) {
-					int res = read();
-					if (res == -1) {
-						return i == 0 ? -1 : i;
-					}
-					pB[pOff+i] = (byte) res;
-				}
-				return pLen;
-			}
-    	};
-    	try {
-    		parseUpload(stream, request.length);
-    		fail("Expected IOException");
-    	} catch (FileUploadException e) {
-    		assertTrue(e.getCause() instanceof IOException);
-    		assertEquals("123", e.getCause().getMessage());
+            throws IOException {
+        byte[] request = newRequest();
+        InputStream stream = new FilterInputStream(new ByteArrayInputStream(request)){
+            private int num;
+            public int read() throws IOException {
+                if (++num > 123) {
+                    throw new IOException("123");
+                }
+                return super.read();
+            }
+            public int read(byte[] pB, int pOff, int pLen)
+                    throws IOException {
+                for (int i = 0;  i < pLen;  i++) {
+                    int res = read();
+                    if (res == -1) {
+                        return i == 0 ? -1 : i;
+                    }
+                    pB[pOff+i] = (byte) res;
+                }
+                return pLen;
+            }
+        };
+        try {
+            parseUpload(stream, request.length);
+            fail("Expected IOException");
+        } catch (FileUploadException e) {
+            assertTrue(e.getCause() instanceof IOException);
+            assertEquals("123", e.getCause().getMessage());
         }
     }
 
@@ -151,7 +151,7 @@ public class StreamingTest extends TestC
     }
 
     private List<FileItem> parseUpload(byte[] bytes) throws FileUploadException {
-    	return parseUpload(new ByteArrayInputStream(bytes), bytes.length);
+        return parseUpload(new ByteArrayInputStream(bytes), bytes.length);
     }
 
     private FileItemIterator parseUpload(int pLength, InputStream pStream)
@@ -167,13 +167,13 @@ public class StreamingTest extends TestC
     }
 
     private List<FileItem> parseUpload(InputStream pStream, int pLength)
-    		throws FileUploadException {
+            throws FileUploadException {
         String contentType = "multipart/form-data; boundary=---1234";
 
         FileUploadBase upload = new ServletFileUpload();
         upload.setFileItemFactory(new DiskFileItemFactory());
         HttpServletRequest request = new MockHttpServletRequest(pStream,
-        		pLength, contentType);
+                pLength, contentType);
 
         List<FileItem> fileItems = upload.parseRequest(new ServletRequestContext(request));
         return fileItems;