You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jo...@apache.org on 2010/06/06 23:19:57 UTC
svn commit: r951978 [4/5] - in /commons/sandbox/commons-fileupload2: ./
.settings/ src/ src/changes/ src/checkstyle/ src/conf/ src/java/
src/java/org/ src/java/org/apache/ src/java/org/apache/commons/
src/java/org/apache/commons/fileupload2/ src/java/o...
Added: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockHttpServletRequest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockHttpServletRequest.java?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockHttpServletRequest.java (added)
+++ commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockHttpServletRequest.java Sun Jun 6 21:19:54 2010
@@ -0,0 +1,560 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+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("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 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
+ */
+ @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
+ {
+ // Nothing to do
+ }
+
+ /**
+ * @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)
+ {
+ // Not implemented
+ }
+
+ /**
+ * @see javax.servlet.ServletRequest#removeAttribute(String)
+ */
+ public void removeAttribute(String arg0)
+ {
+ // Not implemented
+ }
+
+ /**
+ * @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
+ */
+ @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;
+ }
+
+ @Override
+ public int read() throws IOException
+ {
+ return in.read();
+ }
+
+ @Override
+ public int read(byte b[], int off, int len) throws IOException
+ {
+ return in.read(b, off, len);
+ }
+ }
+}
Propchange: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockHttpServletRequest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletRequest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletRequest.java?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletRequest.java (added)
+++ commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletRequest.java Sun Jun 6 21:19:54 2010
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2;
+
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.PortalContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.WindowState;
+
+/**
+ * A mock portlet request, useful for unit testing and offline utilities
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class MockPortletRequest implements PortletRequest
+{
+ MockPortletSession session = null;
+
+ /**
+ * Creates a new instance.
+ */
+ public MockPortletRequest()
+ {
+ session = new MockPortletSession();
+ }
+
+ public boolean isWindowStateAllowed(WindowState state)
+ {
+ return false;
+ }
+
+ public boolean isPortletModeAllowed(PortletMode mode)
+ {
+ return false;
+ }
+
+ public PortletMode getPortletMode()
+ {
+ return null;
+ }
+
+ public WindowState getWindowState()
+ {
+ return null;
+ }
+
+ public PortletPreferences getPreferences()
+ {
+ return null;
+ }
+
+ public PortletSession getPortletSession()
+ {
+ return session;
+ }
+
+ public PortletSession getPortletSession(boolean create)
+ {
+ if (session == null)
+ {
+ session = new MockPortletSession();
+ }
+ return session;
+ }
+
+ public String getProperty(String name)
+ {
+ return null;
+ }
+
+ public Enumeration<String> getProperties(String name)
+ {
+ return null;
+ }
+
+ public Enumeration<String> getPropertyNames()
+ {
+ return null;
+ }
+
+ public PortalContext getPortalContext()
+ {
+ return null;
+ }
+
+ public String getAuthType()
+ {
+ return null;
+ }
+
+ public String getContextPath()
+ {
+ return null;
+ }
+
+ public String getRemoteUser()
+ {
+ return null;
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return null;
+ }
+
+ public boolean isUserInRole(String role)
+ {
+ return false;
+ }
+
+ public Object getAttribute(String name)
+ {
+ return null;
+ }
+
+ public Enumeration<String> getAttributeNames()
+ {
+ return null;
+ }
+
+ public String getParameter(String name)
+ {
+ return null;
+ }
+
+ public Enumeration<String> getParameterNames()
+ {
+ return null;
+ }
+
+ public String[] getParameterValues(String name)
+ {
+ return null;
+ }
+
+ public Map<String,String> getParameterMap()
+ {
+ return null;
+ }
+
+ public boolean isSecure()
+ {
+ return false;
+ }
+
+ public void setAttribute(String name, Object o)
+ {
+ // Not implemented
+ }
+
+ public void removeAttribute(String name)
+ {
+ // Not implemented
+ }
+
+ public String getRequestedSessionId()
+ {
+ return null;
+ }
+
+ public boolean isRequestedSessionIdValid()
+ {
+ return false;
+ }
+
+ public String getResponseContentType()
+ {
+ return null;
+ }
+
+ public Enumeration<String> getResponseContentTypes()
+ {
+ return null;
+ }
+
+ public Locale getLocale()
+ {
+ return null;
+ }
+
+ public String getScheme()
+ {
+ return null;
+ }
+
+ public String getServerName()
+ {
+ return null;
+ }
+
+ public int getServerPort()
+ {
+ return 0;
+ }
+
+ public Enumeration<Locale> getLocales()
+ {
+ return null;
+ }
+
+}
Propchange: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletRequest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletSession.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletSession.java?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletSession.java (added)
+++ commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletSession.java Sun Jun 6 21:19:54 2010
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletSession;
+
+/**
+ * A mock portlet session, useful for unit testing and offline utilities
+ * Note: currently doesn't support scoping
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class MockPortletSession implements PortletSession
+{
+ // Hashtable (not HashMap) makes enumerations easier to work with
+ Hashtable<String,Object> attributes = new Hashtable<String,Object>();
+
+ public Object getAttribute(String name)
+ {
+ return attributes.get(name);
+ }
+
+ public Object getAttribute(String name, int scope)
+ {
+ return attributes.get(name);
+ }
+
+ public Enumeration<String> getAttributeNames(int scope)
+ {
+ return attributes.keys();
+ }
+
+ public long getCreationTime()
+ {
+ return 0;
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public long getLastAccessedTime()
+ {
+ return 0;
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ return 0;
+ }
+
+ public void invalidate()
+ {
+ // Nothing to do
+ }
+
+ public boolean isNew()
+ {
+ return false;
+ }
+
+ public void removeAttribute(String name)
+ {
+ attributes.remove(name);
+ }
+
+ public void removeAttribute(String name, int scope)
+ {
+ attributes.remove(name);
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ attributes.put(name, value);
+ }
+
+ public Enumeration<String> getAttributeNames()
+ {
+ return this.getAttributeNames(PortletSession.PORTLET_SCOPE);
+ }
+
+
+ public void setAttribute(String name, Object value, int scope)
+ {
+ attributes.put(name, value);
+ }
+
+ public void setMaxInactiveInterval(int interval)
+ {
+ // Nothing to do
+ }
+
+ public PortletContext getPortletContext()
+ {
+ return null;
+ }
+}
Propchange: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/MockPortletSession.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ProgressListenerTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ProgressListenerTest.java?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ProgressListenerTest.java (added)
+++ commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ProgressListenerTest.java Sun Jun 6 21:19:54 2010
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.fileupload2.servlet.HttpServletUploadRequest;
+import org.junit.Test;
+
+
+/** Tests the progress listener.
+ */
+public class ProgressListenerTest extends FileUploadTestCase {
+ private static class EventListenerImpl implements EventListener {
+ private final long expectedContentLength;
+ private final int expectedItems;
+ private boolean startRequestSeen, endRequestSeen;
+ private int startItemsSeen, endItemsSeen;
+ private FileItem previousFileItem;
+ private long bytesRead;
+
+ EventListenerImpl(long pExpectedContentLength, int pExpectedItems) {
+ expectedContentLength = pExpectedContentLength;
+ expectedItems = pExpectedItems;
+ }
+
+ public void startRequest(FileUpload pFileUpload, UploadRequest pRequest) throws IOException {
+ startRequestSeen = true;
+ }
+
+ public void endRequest(FileUpload pFileUpload, UploadRequest pRequest) throws IOException {
+ endRequestSeen = true;
+ }
+
+ public void requestSizeMaxExceeded(FileUpload pFileUpload,
+ UploadRequest pRequest, long pRequestSize) throws IOException {
+ throw new IllegalStateException("This wasn't supposed to happen!");
+ }
+
+ public void error(FileUpload pFileUpload, UploadRequest pRequest,
+ Throwable pError) throws IOException {
+ throw new IllegalStateException("This wasn't supposed to happen!");
+ }
+
+ public long startItem(FileUpload pFileUpload, UploadRequest pRequest,
+ FileItem pItem) throws IOException {
+ assertEquals(endItemsSeen, startItemsSeen);
+ ++startItemsSeen;
+ assertTrue(previousFileItem == null || previousFileItem != pItem);
+ previousFileItem = pItem;
+ bytesRead = 0;
+ return 1;
+ }
+
+ public void fileSizeMaxExceeded(FileUpload pFileUpload,
+ UploadRequest pRequest, FileItem pItem, long pFileSize)
+ throws IOException {
+ throw new IllegalStateException("This wasn't supposed to happen!");
+ }
+
+ public void endItem(FileUpload pFileUpload, UploadRequest pRequest,
+ FileItem pItem, long pContentLength) throws IOException {
+ assertSame(previousFileItem, pItem);
+ ++endItemsSeen;
+ assertEquals(startItemsSeen, endItemsSeen);
+ }
+
+ public long parsingItem(FileUpload pFileUpload, UploadRequest pRequest,
+ FileItem pItem, long pCurrentLength) throws IOException {
+ assertSame(previousFileItem, pItem);
+ assertTrue(pCurrentLength >= 0 && pCurrentLength <= expectedContentLength);
+ assertTrue(pItem.getContentLength() == -1 || pItem.getContentLength() == expectedContentLength);
+ assertTrue(startItemsSeen >= 0 && startItemsSeen <= expectedItems);
+ assertTrue(pCurrentLength >= bytesRead);
+ bytesRead = pCurrentLength;
+ return 1;
+ }
+
+ void validate() {
+ assertEquals(bytesRead, expectedContentLength);
+ assertEquals(startItemsSeen, expectedItems);
+ assertEquals(endItemsSeen, expectedItems);
+ assertTrue(startRequestSeen);
+ assertTrue(endRequestSeen);
+ }
+ }
+
+ /**
+ * Parse a very long file upload by using a progress listener.
+ */
+ @Test 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"
+ + "Content-Disposition: form-data; name=\"field" + (i+1) + "\"\r\n"
+ + "\r\n";
+ baos.write(header.getBytes("US-ASCII"));
+ for (int j = 0; j < 16384+i; j++) {
+ baos.write((byte) j);
+ }
+ baos.write("\r\n".getBytes("US-ASCII"));
+ }
+ baos.write("-----1234--\r\n".getBytes("US-ASCII"));
+ byte[] contents = baos.toByteArray();
+
+ 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"){
+ @Override
+ 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 {
+ EventListenerImpl listener = new EventListenerImpl(pContentLength, NUM_ITEMS);
+ final FileUpload upload = new FileUpload();
+ upload.setEventListener(listener);
+ final FileItemIterator<FileItem> iter = upload.parse(new HttpServletUploadRequest(request));
+ for (int i = 0; i < NUM_ITEMS; i++) {
+ assertTrue(iter.hasNext());
+ final FileItem item = iter.next();
+ InputStream istream = item.getInputStream();
+ 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());
+ }
+ assertTrue(!iter.hasNext());
+ listener.validate();
+ }
+}
Propchange: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ProgressListenerTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ServletFileUploadTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ServletFileUploadTest.java?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ServletFileUploadTest.java (added)
+++ commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ServletFileUploadTest.java Sun Jun 6 21:19:54 2010
@@ -0,0 +1,296 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.fileupload2.servlet.HttpServletUploadRequest;
+import org.apache.commons.fileupload2.util.FileUploadUtils;
+import org.junit.Test;
+
+
+/**
+ * Unit tests for {@link HttpServletUploadRequest}.
+ */
+public class ServletFileUploadTest extends FileUploadTestCase {
+ /**
+ * Tests, whether an invalid request is causing a {@link FileUploadException}.
+ */
+ @Test public void testWithInvalidRequest() throws Exception {
+ HttpServletRequest req = HttpServletRequestFactory.createInvalidHttpServletRequest();
+ parseUpload(req);
+ }
+
+ /**
+ * Tests, whether the content type null causes a {@link InvalidContentTypeException}.
+ */
+ @Test public void testWithNullContentType() throws Exception {
+ HttpServletRequest req = HttpServletRequestFactory.createHttpServletRequestWithNullContentType();
+ try {
+ parseUpload(req);
+ fail("testWithNullContentType: expected exception was not thrown");
+ } catch (InvalidContentTypeException expected) {
+ // this exception is expected
+ }
+ }
+
+ /**
+ * First test of a successful parsing operation.
+ */
+ @Test public void testFileUpload() throws Exception {
+ List<StoredFileItem> 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; name=\"field\"\r\n" +
+ "\r\n" +
+ "fieldValue\r\n" +
+ "-----1234\r\n" +
+ "Content-Disposition: form-data; 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());
+
+ StoredFileItem file = fileItems.get(0);
+ assertEquals("file", file.getFieldName());
+ assertFalse(file.isFormField());
+ assertEquals("This is the content of the file\n", FileUploadUtils.asString(file));
+ assertEquals("text/whatever", file.getContentType());
+ assertEquals("foo.tab", file.getFileName());
+
+ StoredFileItem field = fileItems.get(1);
+ assertEquals("field", field.getFieldName());
+ assertTrue(field.isFormField());
+ assertEquals("fieldValue", FileUploadUtils.asString(field));
+
+ StoredFileItem multi0 = fileItems.get(2);
+ assertEquals("multi", multi0.getFieldName());
+ assertTrue(multi0.isFormField());
+ assertEquals("value1", FileUploadUtils.asString(multi0));
+
+ StoredFileItem multi1 = fileItems.get(3);
+ assertEquals("multi", multi1.getFieldName());
+ assertTrue(multi1.isFormField());
+ assertEquals("value2", FileUploadUtils.asString(multi1));
+ }
+
+ /**
+ * Tests, whether file names are case sensitive.
+ */
+ @Test public void testFilenameCaseSensitivity() throws Exception {
+ List<StoredFileItem> 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");
+ assertEquals(1, fileItems.size());
+
+ StoredFileItem file = fileItems.get(0);
+ assertEquals("FiLe", file.getFieldName());
+ assertEquals("FOO.tab", file.getFileName());
+ }
+
+ /**
+ * This is what the browser does if you submit the form without choosing a file.
+ */
+ @Test public void testEmptyFile() throws Exception {
+ List<StoredFileItem> fileItems = parseUpload ("-----1234\r\n" +
+ "Content-Disposition: form-data; name=\"file\"; filename=\"\"\r\n" +
+ "\r\n" +
+ "\r\n" +
+ "-----1234--\r\n");
+ assertEquals(1, fileItems.size());
+
+ StoredFileItem file = fileItems.get(0);
+ assertFalse(file.isFormField());
+ assertEquals("", FileUploadUtils.asString(file));
+ assertEquals("", file.getFileName());
+ }
+
+ /**
+ * Internet Explorer 5 for the Mac has a bug where the carriage
+ * return is missing on any boundary line immediately preceding
+ * an input with type=image. (type=submit does not have the bug.)
+ */
+ @Test public void testIE5MacBug() throws Exception {
+ List<StoredFileItem> fileItems = parseUpload("-----1234\r\n" +
+ "Content-Disposition: form-data; name=\"field1\"\r\n" +
+ "\r\n" +
+ "fieldValue\r\n" +
+ "-----1234\n" + // NOTE \r missing
+ "Content-Disposition: form-data; name=\"submitName.x\"\r\n" +
+ "\r\n" +
+ "42\r\n" +
+ "-----1234\n" + // NOTE \r missing
+ "Content-Disposition: form-data; name=\"submitName.y\"\r\n" +
+ "\r\n" +
+ "21\r\n" +
+ "-----1234\r\n" +
+ "Content-Disposition: form-data; name=\"field2\"\r\n" +
+ "\r\n" +
+ "fieldValue2\r\n" +
+ "-----1234--\r\n");
+
+ assertEquals(4, fileItems.size());
+
+ FileItem field1 = fileItems.get(0);
+ assertEquals("field1", field1.getFieldName());
+ assertTrue(field1.isFormField());
+ assertEquals("fieldValue", FileUploadUtils.asString(field1));
+
+ FileItem submitX = fileItems.get(1);
+ assertEquals("submitName.x", submitX.getFieldName());
+ assertTrue(submitX.isFormField());
+ assertEquals("42", FileUploadUtils.asString(submitX));
+
+ FileItem submitY = fileItems.get(2);
+ assertEquals("submitName.y", submitY.getFieldName());
+ assertTrue(submitY.isFormField());
+ assertEquals("21", FileUploadUtils.asString(submitY));
+
+ FileItem field2 = fileItems.get(3);
+ assertEquals("field2", field2.getFieldName());
+ assertTrue(field2.isFormField());
+ assertEquals("fieldValue2", FileUploadUtils.asString(field2));
+ }
+
+ /**
+ * Test for <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-62">FILEUPLOAD-62</a>
+ */
+ @Test public void testFILEUPLOAD62() throws Exception {
+ final String contentType = "multipart/form-data; boundary=AaB03x";
+
+ /* T_END_HEADER
+ * T_START_MULTIPART
+ * T_PREAMBLE
+ * T_START_BODYPART
+ * T_START_HEADER
+ * T_FIELD
+ * T_END_HEADER
+ * T_START_MULTIPART
+ * T_PREAMBLE
+ * T_START_BODYPART
+ * T_START_HEADER
+ * T_FIELD
+ */
+
+ 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<StoredFileItem> fileItems = parseUpload(request.getBytes("US-ASCII"), contentType);
+ assertEquals(3, fileItems.size());
+ FileItem item0 = fileItems.get(0);
+ assertEquals("field1", item0.getFieldName());
+ assertNull(item0.getFileName());
+ assertEquals("Joe Blow", FileUploadUtils.asString(item0));
+ FileItem item1 = fileItems.get(1);
+ assertEquals("pics", item1.getFieldName());
+ assertEquals("file1.txt", item1.getFileName());
+ assertEquals("... contents of file1.txt ...", FileUploadUtils.asString(item1));
+ FileItem item2 = fileItems.get(2);
+ assertEquals("pics", item2.getFieldName());
+ assertEquals("file2.gif", item2.getFileName());
+ assertEquals("...contents of file2.gif...", FileUploadUtils.asString(item2));
+ }
+
+ /**
+ * Test for <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-111">FILEUPLOAD-111</a>
+ */
+ @Test public void testFoldedHeaders() throws Exception {
+ List<StoredFileItem> 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 = fileItems.get(0);
+ assertEquals("file", file.getFieldName());
+ assertFalse(file.isFormField());
+ assertEquals("This is the content of the file\n", FileUploadUtils.asString(file));
+ assertEquals("text/whatever", file.getContentType());
+ assertEquals("foo.tab", file.getFileName());
+
+ FileItem field = fileItems.get(1);
+ assertEquals("field", field.getFieldName());
+ assertTrue(field.isFormField());
+ assertEquals("fieldValue", FileUploadUtils.asString(field));
+
+ FileItem multi0 = fileItems.get(2);
+ assertEquals("multi", multi0.getFieldName());
+ assertTrue(multi0.isFormField());
+ assertEquals("value1", FileUploadUtils.asString(multi0));
+
+ FileItem multi1 = fileItems.get(3);
+ assertEquals("multi", multi1.getFieldName());
+ assertTrue(multi1.isFormField());
+ assertEquals("value2", FileUploadUtils.asString(multi1));
+ }
+}
Propchange: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/ServletFileUploadTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/SizesTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/SizesTest.java?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/SizesTest.java (added)
+++ commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/SizesTest.java Sun Jun 6 21:19:54 2010
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.Assert;
+
+import org.apache.commons.fileupload2.disk.DiskFileItemStore;
+import org.apache.commons.fileupload2.servlet.HttpServletUploadRequest;
+import org.apache.commons.fileupload2.util.FileUploadUtils;
+import org.apache.commons.fileupload2.util.Streams;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Unit test for items with varying sizes.
+ */
+public class SizesTest extends FileUploadTestCase {
+ /** Runs a test with varying file sizes.
+ */
+ @Test public void testFileUpload()
+ throws IOException, FileUploadException
+ {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ int add = 16;
+ int num = 0;
+ for (int i = 0; i < 16384; i += add) {
+ if (++add == 32) {
+ add = 16;
+ }
+ String header = "-----1234\r\n"
+ + "Content-Disposition: form-data; name=\"field" + (num++) + "\"\r\n"
+ + "\r\n";
+ baos.write(header.getBytes("US-ASCII"));
+ for (int j = 0; j < i; j++) {
+ baos.write((byte) j);
+ }
+ baos.write("\r\n".getBytes("US-ASCII"));
+ }
+ baos.write("-----1234--\r\n".getBytes("US-ASCII"));
+
+ final List<StoredFileItem> fileItems = parseUpload(baos.toByteArray());
+ final Iterator<StoredFileItem> fileIter = fileItems.iterator();
+ add = 16;
+ num = 0;
+ for (int i = 0; i < 16384; i += add) {
+ if (++add == 32) {
+ add = 16;
+ }
+ StoredFileItem item = fileIter.next();
+ assertEquals("field" + (num++), item.getFieldName());
+ byte[] bytes = Streams.asByteArray(item.getInputStream());
+ assertEquals(i, bytes.length);
+ for (int j = 0; j < i; j++) {
+ assertEquals((byte) j, bytes[j]);
+ }
+ }
+ assertTrue(!fileIter.hasNext());
+ }
+
+ /** Checks, whether limiting the file size works.
+ */
+ @Test 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 FileUpload upload = new FileUpload();
+ upload.setFileSizeMax(-1);
+ final HttpServletRequest req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
+ final DiskFileItemStore store = new DiskFileItemStore();
+ final List<StoredFileItem> fileItems = FileUploadUtils.asList(store.parse(upload, new HttpServletUploadRequest(req)));
+ assertEquals(1, fileItems.size());
+ final StoredFileItem item = fileItems.get(0);
+ assertEquals("This is the content of the file\n", Streams.asString(item.getInputStream(), "US-ASCII"));
+ }
+
+ {
+ final FileUpload upload = new FileUpload();
+ upload.setFileSizeMax(40);
+ final HttpServletRequest req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
+ final DiskFileItemStore store = new DiskFileItemStore();
+ final List<StoredFileItem> fileItems = FileUploadUtils.asList(store.parse(upload, new HttpServletUploadRequest(req)));
+ assertEquals(1, fileItems.size());
+ final StoredFileItem item = fileItems.get(0);
+ assertEquals("This is the content of the file\n", Streams.asString(item.getInputStream(), "US-ASCII"));
+ }
+
+ {
+ final FileUpload upload = new FileUpload();
+ upload.setFileSizeMax(30);
+ final HttpServletRequest req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
+ final DiskFileItemStore store = new DiskFileItemStore();
+ try {
+ FileUploadUtils.asList(store.parse(upload, new HttpServletUploadRequest(req)));
+ fail("Expected exception.");
+ } catch (IOException e) {
+ Assert.assertTrue(e.getClass().getName(), e instanceof FileSizeMaxException);
+ final FileSizeMaxException fse = (FileSizeMaxException) e;
+ Assert.assertEquals(fse.getConfiguredMaxSize(), 30);
+ Assert.assertEquals("file", fse.getFieldName());
+ Assert.assertEquals("foo.tab", fse.getFileName());
+ }
+ }
+ }
+}
Propchange: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/SizesTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/StreamingTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/StreamingTest.java?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/StreamingTest.java (added)
+++ commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/StreamingTest.java Sun Jun 6 21:19:54 2010
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.Assert;
+
+import org.apache.commons.fileupload2.servlet.HttpServletUploadRequest;
+import org.apache.commons.fileupload2.util.FileUploadUtils;
+import org.apache.james.mime4j.parser.Event;
+import org.apache.james.mime4j.parser.MimeParseEventException;
+import org.junit.Test;
+
+
+/**
+ * Unit test for items with varying sizes.
+ */
+public class StreamingTest {
+ /**
+ * Tests a file upload with varying file sizes.
+ */
+ @Test public void testFileUpload() throws Exception {
+ byte[] request = newRequest();
+ FileItemIterator<FileItem> fileIter = parseUpload(request);
+ int add = 16;
+ int num = 0;
+ for (int i = 0; i < 16384; i += add) {
+ if (++add == 32) {
+ add = 16;
+ }
+ assertTrue(fileIter.hasNext());
+ FileItem item = fileIter.next();
+ assertEquals("field" + (num++), item.getFieldName());
+ byte[] bytes = FileUploadUtils.asByteArray(item);
+ assertEquals(i, bytes.length);
+ for (int j = 0; j < i; j++) {
+ assertEquals((byte) j, bytes[j]);
+ }
+ }
+ assertTrue(!fileIter.hasNext());
+ }
+
+
+ /**
+ * Tests, whether an invalid request throws a proper
+ * exception.
+ */
+ @Test public void testFileUploadException() throws Exception {
+ byte[] request = newRequest();
+ byte[] invalidRequest = new byte[request.length-11];
+ System.arraycopy(request, 0, invalidRequest, 0, request.length-11);
+ try {
+ for (FileItemIterator<FileItem> iter = parseUpload(invalidRequest); iter.hasNext(); ) {
+ iter.next();
+ }
+ fail("Expected EndOfStreamException");
+ } catch (FileUploadException e) {
+ Assert.assertNotNull(e.getCause());
+ Assert.assertTrue(e.getCause() instanceof MimeParseEventException);
+ final Event event = ((MimeParseEventException) e.getCause()).getEvent();
+ Assert.assertEquals(Event.MIME_BODY_PREMATURE_END, event);
+ }
+ }
+
+ /**
+ * Tests, whether an IOException is properly delegated.
+ */
+ @Test public void testIOException() throws Exception {
+ byte[] request = newRequest();
+ InputStream stream = new FilterInputStream(new ByteArrayInputStream(request)){
+ private int num;
+ @Override
+ public int read() throws IOException {
+ if (++num > 123) {
+ throw new IOException("123");
+ }
+ return super.read();
+ }
+ @Override
+ public int read(byte[] pB, int pOff, int pLen) throws IOException {
+ num += pLen;
+ if (pLen > 123) {
+ throw new IOException("123");
+ }
+ 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 {
+ for (FileItemIterator<FileItem> iter = parseUpload(stream, request.length); iter.hasNext(); ) {
+ iter.next();
+ }
+ fail("Expected IOException");
+ } catch (IOException e) {
+ Assert.assertEquals("123", e.getMessage());
+ }
+ }
+
+ /**
+ * Test for <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-135">FILEUPLOAD-135</a>
+ */
+ @Test public void testFILEUPLOAD135() throws Exception {
+ byte[] request = newShortRequest();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(request);
+ final FileItemIterator<FileItem> fileIter = parseUpload(new InputStream() {
+ @Override
+ public int read() throws IOException {
+ return bais.read();
+ }
+ @Override
+ public int read(byte b[], int off, int len) throws IOException {
+ return bais.read(b, off, Math.min(len, 3));
+ }
+
+ }, request.length);
+ assertTrue(fileIter.hasNext());
+ FileItem item = fileIter.next();
+ assertEquals("field", item.getFieldName());
+ byte[] bytes = FileUploadUtils.asByteArray(item);
+ assertEquals(3, bytes.length);
+ assertEquals((byte)'1', bytes[0]);
+ assertEquals((byte)'2', bytes[1]);
+ assertEquals((byte)'3', bytes[2]);
+ assertTrue(!fileIter.hasNext());
+ }
+
+ private FileItemIterator<FileItem> parseUpload(byte[] bytes) throws FileUploadException, IOException {
+ return parseUpload(new ByteArrayInputStream(bytes), bytes.length);
+ }
+
+ private FileItemIterator<FileItem> parseUpload(InputStream pStream, int pLength)
+ throws FileUploadException, IOException {
+ final String contentType = "multipart/form-data; boundary=---1234";
+ final HttpServletRequest request = new MockHttpServletRequest(pStream, pLength, contentType);
+ final HttpServletUploadRequest uploadRequest = new HttpServletUploadRequest(request);
+ final FileUpload fileUpload = new FileUpload();
+ return fileUpload.parse(uploadRequest);
+ }
+
+ private String getHeader(String pField) {
+ return "-----1234\r\n"
+ + "Content-Disposition: form-data; name=\"" + pField + "\"\r\n"
+ + "\r\n";
+
+ }
+
+ private String getFooter() {
+ return "-----1234--\r\n";
+ }
+
+ private byte[] newShortRequest() throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final OutputStreamWriter osw = new OutputStreamWriter(baos, "US-ASCII");
+ osw.write(getHeader("field"));
+ osw.write("123");
+ osw.write("\r\n");
+ osw.write(getFooter());
+ osw.close();
+ return baos.toByteArray();
+ }
+
+ private byte[] newSimpleRequest() throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final OutputStreamWriter osw = new OutputStreamWriter(baos, "US-ASCII");
+ osw.write(getHeader("field0"));
+ osw.write("abcdefghijklmnopqrstuvwxyz");
+ osw.write("\r\n");
+ osw.write(getFooter());
+ osw.close();
+ return baos.toByteArray();
+ }
+
+ private byte[] newRequest() throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final OutputStreamWriter osw = new OutputStreamWriter(baos, "US-ASCII");
+ int add = 16;
+ int num = 0;
+ for (int i = 0; i < 16384; i += add) {
+ if (++add == 32) {
+ add = 16;
+ }
+ osw.write(getHeader("field" + (num++)));
+ osw.flush();
+ for (int j = 0; j < i; j++) {
+ baos.write((byte) j);
+ }
+ osw.write("\r\n");
+ }
+ osw.write(getFooter());
+ osw.close();
+ return baos.toByteArray();
+ }
+}
Propchange: commons/sandbox/commons-fileupload2/src/test/org/apache/commons/fileupload2/StreamingTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/xdocs/customizing.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/customizing.xml?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/xdocs/customizing.xml (added)
+++ commons/sandbox/commons-fileupload2/xdocs/customizing.xml Sun Jun 6 21:19:54 2010
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<document>
+
+ <properties>
+ <title>Customizing FileUpload</title>
+ <author email="martinc@apache.org">Martin Cooper</author>
+ </properties>
+
+<body>
+
+ <section name="Customizing FileUpload">
+ <p>
+ TODO: Document usage of factories and subclassing for customization.
+ </p>
+ </section>
+
+</body>
+</document>
Propchange: commons/sandbox/commons-fileupload2/xdocs/customizing.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/xdocs/cvs-usage.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/cvs-usage.xml?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/xdocs/cvs-usage.xml (added)
+++ commons/sandbox/commons-fileupload2/xdocs/cvs-usage.xml Sun Jun 6 21:19:54 2010
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<document>
+ <properties>
+ <title>Source Repository</title>
+ <author email="dev@commons.apache.org">Commons Documentation Team</author>
+ </properties>
+ <body>
+<!-- ================================================== -->
+<section name="Source repository">
+<p>
+ Apache Commons FileUpload is hosted on the Apache
+ <a href="http://subversion.tigris.org/">Subversion</a> repository.
+</p>
+<p>
+ The project URL is:<br />
+ <code>http://svn.apache.org/repos/asf/commons/proper/fileupload/trunk</code>
+</p>
+<p>
+ The best way to view the repository in a browser is via the
+ <a href="http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/">Subversion viewer</a>.
+</p>
+<p>
+ The alternative is to use the
+ <a href="http://svn.apache.org/repos/asf/commons/proper/fileupload/trunk/">native Subversion</a> display.
+</p>
+</section>
+<!-- ================================================== -->
+</body>
+</document>
Propchange: commons/sandbox/commons-fileupload2/xdocs/cvs-usage.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/xdocs/download_fileupload.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/download_fileupload.xml?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/xdocs/download_fileupload.xml (added)
+++ commons/sandbox/commons-fileupload2/xdocs/download_fileupload.xml Sun Jun 6 21:19:54 2010
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<!--
+ +======================================================================+
+ |**** ****|
+ |**** THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN ****|
+ |**** DO NOT EDIT DIRECTLY ****|
+ |**** ****|
+ +======================================================================+
+ | TEMPLATE FILE: download-page-template.xml |
+ | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+ +======================================================================+
+ | |
+ | 1) Re-generate using: mvn commons:download-page |
+ | |
+ | 2) Set the following properties in the component's pom: |
+ | - commons.componentid (required, alphabetic, lower case) |
+ | - commons.release.version (required) |
+ | - commons.binary.suffix (optional) |
+ | (defaults to "-bin", set to "" for pre-maven2 releases) |
+ | |
+ | 3) Example Properties |
+ | |
+ | <properties> |
+ | <commons.componentid>math</commons.componentid> |
+ | <commons.release.version>1.2</commons.release.version> |
+ | </properties> |
+ | |
+ +======================================================================+
+-->
+<document>
+ <properties>
+ <title>Download Commons FileUpload</title>
+ <author email="dev@commons.apache.org">Commons Documentation Team</author>
+ </properties>
+ <body>
+ <section name="Download Commons FileUpload">
+ <p>
+ We recommend you use a mirror to download our release
+ builds, but you <strong>must</strong> verify the integrity of
+ the downloaded files using signatures downloaded from our main
+ distribution directories. Recent releases (48 hours) may not yet
+ be available from the mirrors.
+ </p>
+
+ <p>
+ You are currently using <b>[preferred]</b>. If you
+ encounter a problem with this mirror, please select another
+ mirror. If all mirrors are failing, there are <i>backup</i>
+ mirrors (at the end of the mirrors list) that should be
+ available.
+ <br></br>
+ [if-any logo]<a href="[link]"><img align="right" src="[logo]" border="0"></img></a>[end]
+ </p>
+
+ <form action="[location]" method="get" id="SelectMirror">
+ <p>
+ Other mirrors:
+ <select name="Preferred">
+ [if-any http]
+ [for http]<option value="[http]">[http]</option>[end]
+ [end]
+ [if-any ftp]
+ [for ftp]<option value="[ftp]">[ftp]</option>[end]
+ [end]
+ [if-any backup]
+ [for backup]<option value="[backup]">[backup] (backup)</option>[end]
+ [end]
+ </select>
+ <input type="submit" value="Change"></input>
+ </p>
+ </form>
+
+ <p>
+ The <code>KEYS</code> link links to the code signing keys used to sign the product.
+ The <code>PGP</code> link downloads the OpenPGP compatible signature from our main site.
+ The <code>MD5</code> link downloads the checksum from the main site.
+ </p>
+
+ <p>
+ For more information concerning Commons FileUpload, see the
+ <a href="index.html" class="name">Commons FileUpload</a> web site.
+ </p>
+
+ <p>
+ <div class="links"><span class="link"><a href="http://www.apache.org/dist/commons/KEYS">KEYS</a></span></div>
+ <ul class="downloads">
+ <li class="group"><div class="links"><span class="label">Binary</span></div>
+ <ul>
+ <li class="download"><a href="[preferred]/commons/fileupload/binaries/commons-fileupload-1.2.1-bin.tar.gz">1.2.1.tar.gz</a>
+ <ul class="attributes">
+ <li><span class="md5">[<a href="http://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.2.1-bin.tar.gz.md5">md5</a>]</span>
+ <span class="pgp">[<a href="http://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.2.1-bin.tar.gz.asc">pgp</a>]</span>
+ </li>
+ </ul>
+ </li>
+ <li class="download"><a href="[preferred]/commons/fileupload/binaries/commons-fileupload-1.2.1-bin.zip">1.2.1.zip</a>
+ <ul class="attributes">
+ <li><span class="md5">[<a href="http://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.2.1-bin.zip.md5">md5</a>]</span>
+ <span class="pgp">[<a href="http://www.apache.org/dist/commons/fileupload/binaries/commons-fileupload-1.2.1-bin.zip.asc">pgp</a>]</span>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li class="group"><div class="links"><span class="label">Source</span></div>
+ <ul>
+ <li class="download"><a href="[preferred]/commons/fileupload/source/commons-fileupload-1.2.1-src.tar.gz">1.2.1.tar.gz</a>
+ <ul class="attributes">
+ <li><span class="md5">[<a href="http://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.2.1-src.tar.gz.md5">md5</a>]</span>
+ <span class="pgp">[<a href="http://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.2.1-src.tar.gz.asc">pgp</a>]</span>
+ </li>
+ </ul>
+ </li>
+ <li class="download"><a href="[preferred]/commons/fileupload/source/commons-fileupload-1.2.1-src.zip">1.2.1.zip</a>
+ <ul class="attributes">
+ <li><span class="md5">[<a href="http://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.2.1-src.zip.md5">md5</a>]</span>
+ <span class="pgp">[<a href="http://www.apache.org/dist/commons/fileupload/source/commons-fileupload-1.2.1-src.zip.asc">pgp</a>]</span>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li class="download"><a href="[preferred]/commons/fileupload/">browse download area</a></li>
+ <li><a href="http://archive.apache.org/dist/commons/fileupload/">archives...</a></li>
+ </ul>
+ </p>
+ </section>
+ </body>
+</document>
Propchange: commons/sandbox/commons-fileupload2/xdocs/download_fileupload.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/xdocs/faq.fml
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/faq.fml?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/xdocs/faq.fml (added)
+++ commons/sandbox/commons-fileupload2/xdocs/faq.fml Sun Jun 6 21:19:54 2010
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<faqs title="FileUpload FAQ">
+
+ <part id="general">
+ <title>General</title>
+
+ <faq id="empty-parse">
+ <question>
+ Why is parseRequest() returning no items?
+ </question>
+ <answer>
+ This most commonly happens when the request has already been parsed, or
+ processed in some other way. Since the input stream has aleady been
+ consumed by that earlier process, it is no longer available for parsing
+ by Commons FileUpload.
+ </answer>
+ </faq>
+
+ <faq id="read-timeout">
+ <question>
+ Why am I getting "Read timed out" exceptions while parsing?
+ </question>
+ <answer>
+ The most common cause of these exceptions is when FileUpload is being
+ used on a site that is using the Tomcat ISAPI redirector. There was a
+ bug in earlier versions of that component that caused problems with
+ multipart requests. The bug was fixed some time ago, so you probably
+ just need to pick up a newer version. See the
+ <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=15278">Tomcat bug report</a>
+ for full details.
+ </answer>
+ </faq>
+
+ <faq id="class-not-found">
+ <question>
+ Why is NoClassDefFoundError being thrown?
+ </question>
+ <answer>
+ <p>There are two common causes for this error. </p>
+
+ <p>Firstly, it might simply mean that you do not have the Commons IO
+ jar in your classpath. FileUpload depends on IO (see
+ <a href="dependencies.html">dependencies</a>) - you can tell if
+ this is the case if the missing class is within the
+ <code>org.apache.commons.io</code> package. </p>
+
+ <p>Secondly this happens when attempting to rely on a shared copy of
+ the Commons FileUpload jar file provided by your web container. The
+ solution is to include the FileUpload jar file as part of your own
+ web application, instead of relying on the container. The same may
+ hold for FileUpload's IO dependency. </p>
+ </answer>
+ </faq>
+
+ <faq id="whole-path-from-IE">
+ <question>
+ Why does FileItem.getName() return the whole path, and not just the file name?
+ </question>
+ <answer>
+ Internet Explorer provides the entire path to the uploaded file and not
+ just the base file name. Since FileUpload provides exactly what was
+ supplied by the client (browser), you may want to remove this path
+ information in your application. You can do that using the following
+ method from Commons IO (which you already have, since it is used by
+ FileUpload).
+ <pre>
+ String fileName = item.getName();
+ if (fileName != null) {
+ filename = FilenameUtils.getName(filename);
+ }
+ </pre>
+ </answer>
+ </faq>
+ </part>
+
+ <part id="struts">
+ <title>FileUpload and Struts</title>
+
+ <faq id="parse-in-action-fails">
+ <question>
+ I'm using FileUpload in an Action, but it's not working. Why?
+ </question>
+ <answer>
+ Struts recognises multipart requests, and parses them automatically,
+ presenting the request parameters to your code in the same manner as
+ if they were regular request parameters. Since Struts has already
+ processed the request, and made it available in your form bean, the
+ input stream is no longer available for parsing, so attempting to do
+ so with FileUpload will fail.
+ </answer>
+ </faq>
+
+ <faq id="howto-parse-in-action">
+ <question>
+ But I need to parse the request myself. How can I do that?
+ </question>
+ <answer>
+ Struts parses multipart a request as a part of the process of populating
+ your form bean from that request. If, for some reason, you need to have
+ full control over the multipart parsing, you can do so by configuring
+ your action mapping without an associated form bean. (A better way of
+ doing this, however, is to replace the default multipart handler with
+ your own. See the Struts documentation for details.)
+ </answer>
+ </faq>
+ </part>
+
+</faqs>
Added: commons/sandbox/commons-fileupload2/xdocs/images/jakarta-logo-blue.gif
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/images/jakarta-logo-blue.gif?rev=951978&view=auto
==============================================================================
Binary file - no diff available.
Propchange: commons/sandbox/commons-fileupload2/xdocs/images/jakarta-logo-blue.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/sandbox/commons-fileupload2/xdocs/images/logo.gif
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/images/logo.gif?rev=951978&view=auto
==============================================================================
Binary file - no diff available.
Propchange: commons/sandbox/commons-fileupload2/xdocs/images/logo.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/sandbox/commons-fileupload2/xdocs/images/logo.png
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/images/logo.png?rev=951978&view=auto
==============================================================================
Binary file - no diff available.
Propchange: commons/sandbox/commons-fileupload2/xdocs/images/logo.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/sandbox/commons-fileupload2/xdocs/index.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/index.xml?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/xdocs/index.xml (added)
+++ commons/sandbox/commons-fileupload2/xdocs/index.xml Sun Jun 6 21:19:54 2010
@@ -0,0 +1,132 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<document>
+
+ <properties>
+ <title>Home</title>
+ <author email="martinc@apache.org">Martin Cooper</author>
+ </properties>
+
+ <body>
+
+ <section name="Commons FileUpload">
+ <p>
+ The Commons <strong>FileUpload</strong> package makes it easy to add
+ robust, high-performance, file upload capability to your servlets and
+ web applications.
+ </p>
+ <p>
+ FileUpload parses HTTP requests which conform to
+ <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>,
+ "Form-based File Upload in HTML". That is, if an HTTP request is
+ submitted using the POST method, and with a content type of
+ "multipart/form-data", then FileUpload can parse that request, and
+ make the results available in a manner easily used by the caller.
+ </p>
+ </section>
+
+ <section name="Documentation">
+ <p>
+ The following documentation is available:
+ <ul>
+ <li><a href="using.html">User Guide</a></li>
+ <li><a href="streaming.html">Streaming API</a></li>
+ <li><a href="faq.html">Frequently Asked Questions</a></li>
+ <li><a href="apidocs/index.html">JavaDoc API</a></li>
+ <li><a href="project-reports.html">Project Reports</a></li>
+ </ul>
+ You can also <a href="cvs-usage.html">browse</a> the Subversion repository.
+ </p>
+ </section>
+
+ <section name="Downloading">
+ <subsection name='Full Releases'>
+ <p>
+ <strong>FileUpload 1.2.1</strong> - 18 January 2008
+ <ul>
+ <li>Download the binary and source distributions from a mirror site
+ <a href='http://commons.apache.org/downloads/download_fileupload.cgi'>here</a>
+ </li>
+ </ul>
+ </p>
+ <p>
+ <strong>FileUpload 1.2</strong> - 13 February 2007
+ <ul>
+ <li>Download the binary and source distributions from a mirror site
+ <a href='http://commons.apache.org/downloads/download_fileupload.cgi'>here</a>
+ </li>
+ </ul>
+ </p>
+ <p>
+ <strong>FileUpload 1.1.1</strong> - 08 June 2006
+ <ul>
+ <li>Download the binary and source distributions from a mirror site
+ <a href='http://commons.apache.org/downloads/download_fileupload.cgi'>here</a>
+ </li>
+ </ul>
+ </p>
+ <p>
+ <strong>FileUpload 1.1</strong> - 22 Dec 2005
+ <ul>
+ <li>Download the binary and source distributions from a mirror site
+ <a href='http://commons.apache.org/downloads/download_fileupload.cgi'>here</a>
+ </li>
+ </ul>
+ </p>
+ <p>
+ <strong>FileUpload 1.0</strong> - 24 Jun 2003
+ <ul>
+ <li>Download the binary and source distributions from a mirror site
+ <a href='http://commons.apache.org/downloads/download_fileupload.cgi'>here</a>
+ </li>
+ </ul>
+ </p>
+ </subsection>
+ <subsection name='Releases Candidates'>
+ <p>
+ None available.
+ </p>
+ </subsection>
+ <subsection name='Nightly Builds'>
+ <p>
+ Nightly builds are built every day from the current SVN HEAD. This is
+ the latest code and so should be treated with caution!
+ </p>
+ <p>
+ Download nightly builds from
+ <a href='http://people.apache.org/builds/commons/nightly/commons-fileupload/'>here</a>.
+ </p>
+ </subsection>
+ </section>
+
+ <section name="Support">
+ <p>
+ The <a href="mail-lists.html">Apache Commons mailing lists</a> act as
+ the main support forum. The <em>user</em> list is suitable for most library
+ usage queries. The <em>dev</em> list is intended for development discussion.
+ Please remember that the lists are shared between all commons components,
+ so prefix your e-mail subject line with <em>[fileupload]</em>.
+ </p>
+ <p>
+ Issues may be reported via <a href="issue-tracking.html">ASF JIRA</a>.
+ </p>
+ </section>
+ </body>
+
+</document>
Propchange: commons/sandbox/commons-fileupload2/xdocs/index.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/commons-fileupload2/xdocs/issue-tracking.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-fileupload2/xdocs/issue-tracking.xml?rev=951978&view=auto
==============================================================================
--- commons/sandbox/commons-fileupload2/xdocs/issue-tracking.xml (added)
+++ commons/sandbox/commons-fileupload2/xdocs/issue-tracking.xml Sun Jun 6 21:19:54 2010
@@ -0,0 +1,102 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<!--
+ +======================================================================+
+ |**** ****|
+ |**** THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN ****|
+ |**** DO NOT EDIT DIRECTLY ****|
+ |**** ****|
+ +======================================================================+
+ | TEMPLATE FILE: issue-tracking-template.xml |
+ | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+ +======================================================================+
+ | |
+ | 1) Re-generate using: mvn commons:jira-page |
+ | |
+ | 2) Set the following properties in the component's pom: |
+ | - commons.jira.id (required, alphabetic, upper case) |
+ | - commons.jira.pid (required, numeric) |
+ | |
+ | 3) Example Properties |
+ | |
+ | <properties> |
+ | <commons.jira.id>MATH</commons.jira.id> |
+ | <commons.jira.pid>12310485</commons.jira.pid> |
+ | </properties> |
+ | |
+ +======================================================================+
+-->
+<document>
+ <properties>
+ <title>Commons FileUpload Issue tracking</title>
+ <author email="dev@commons.apache.org">Commons Documentation Team</author>
+ </properties>
+ <body>
+
+ <section name="Commons FileUpload Issue tracking">
+ <p>
+ Commons FileUpload uses <a href="http://issues.apache.org/jira/">ASF JIRA</a> for tracking issues.
+ See the <a href="http://issues.apache.org/jira/browse/FILEUPLOAD">Commons FileUpload JIRA project page</a>.
+ </p>
+
+ <p>
+ To use JIRA you may need to <a href="http://issues.apache.org/jira/secure/Signup!default.jspa">create an account</a>
+ (if you have previously created/updated Commons issues using Bugzilla an account will have been automatically
+ created and you can use the <a href="http://issues.apache.org/jira/secure/ForgotPassword!default.jspa">Forgot Password</a>
+ page to get a new password).
+ </p>
+
+ <p>
+ If you would like to report a bug, or raise an enhancement request with
+ Commons FileUpload please do the following:
+ <ol>
+ <li><a href="http://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&pid=12310476&sorter/field=issuekey&sorter/order=DESC&status=1&status=3&status=4">Search existing open bugs</a>.
+ If you find your issue listed then please add a comment with your details.</li>
+ <li><a href="mail-lists.html">Search the mailing list archive(s)</a>.
+ You may find your issue or idea has already been discussed.</li>
+ <li>Decide if your issue is a bug or an enhancement.</li>
+ <li>Submit either a <a href="http://issues.apache.org/jira/secure/CreateIssueDetails!init.jspa?pid=12310476&issuetype=1&priority=4&assignee=-1">bug report</a>
+ or <a href="http://issues.apache.org/jira/secure/CreateIssueDetails!init.jspa?pid=12310476&issuetype=4&priority=4&assignee=-1">enhancement request</a>.</li>
+ </ol>
+ </p>
+
+ <p>
+ Please also remember these points:
+ <ul>
+ <li>the more information you provide, the better we can help you</li>
+ <li>test cases are vital, particularly for any proposed enhancements</li>
+ <li>the developers of Commons FileUpload are all unpaid volunteers</li>
+ </ul>
+ </p>
+
+ <p>
+ For more information on subversion and creating patches see the
+ <a href="http://www.apache.org/dev/contributors.html">Apache Contributors Guide</a>.
+ </p>
+
+ <p>
+ You may also find these links useful:
+ <ul>
+ <li><a href="http://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&pid=12310476&sorter/field=issuekey&sorter/order=DESC&status=1&status=3&status=4">All Open Commons FileUpload bugs</a></li>
+ <li><a href="http://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&pid=12310476&sorter/field=issuekey&sorter/order=DESC&status=5&status=6">All Resolved Commons FileUpload bugs</a></li>
+ <li><a href="http://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&pid=12310476&sorter/field=issuekey&sorter/order=DESC">All Commons FileUpload bugs</a></li>
+ </ul>
+ </p>
+ </section>
+ </body>
+</document>
Propchange: commons/sandbox/commons-fileupload2/xdocs/issue-tracking.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain