commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1453120 - in /commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload: FileItemHeadersTest.java MockHttpServletRequest.java ServletFileUploadTest.java SizesTest.java StreamingTest.java
Date Wed, 06 Mar 2013 01:41:57 GMT
Author: sebb
Date: Wed Mar  6 01:41:57 2013
New Revision: 1453120

URL: http://svn.apache.org/r1453120
Log:
Unnecessary casts and missing annotations in test classes

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/MockHttpServletRequest.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=1453120&r1=1453119&r2=1453120&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
Wed Mar  6 01:41:57 2013
@@ -48,9 +48,9 @@ public class FileItemHeadersTest {
         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());
+        assertEquals("content-disposition", headerNameEnumeration.next());
+        assertEquals("content-type", headerNameEnumeration.next());
+        assertEquals("testheader", headerNameEnumeration.next());
         assertFalse(headerNameEnumeration.hasNext());
 
         assertEquals(aMutableFileItemHeaders.getHeader("Content-Disposition"), "form-data;
name=\"FileItem\"; filename=\"file1.txt\"");

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=1453120&r1=1453119&r2=1453120&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
Wed Mar  6 01:41:57 2013
@@ -104,7 +104,7 @@ class MockHttpServletRequest implements 
      */
     public String getHeader(String headerName)
     {
-        return (String) m_headers.get(headerName);
+        return m_headers.get(headerName);
     }
 
     /**
@@ -273,6 +273,7 @@ class MockHttpServletRequest implements 
      * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
      * @deprecated
      */
+    @Deprecated
     public boolean isRequestedSessionIdFromUrl()
     {
         return false;
@@ -515,6 +516,7 @@ class MockHttpServletRequest implements 
      * @see javax.servlet.ServletRequest#getRealPath(String)
      * @deprecated
      */
+    @Deprecated
     public String getRealPath(String arg0)
     {
         return null;
@@ -540,11 +542,13 @@ class MockHttpServletRequest implements 
             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);

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=1453120&r1=1453119&r2=1453120&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
Wed Mar  6 01:41:57 2013
@@ -109,24 +109,24 @@ public class ServletFileUploadTest exten
                                                "-----1234--\r\n");
         assertEquals(4, fileItems.size());
 
-        FileItem file = (FileItem) fileItems.get(0);
+        FileItem file = 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);
+        FileItem field = fileItems.get(1);
         assertEquals("field", field.getFieldName());
         assertTrue(field.isFormField());
         assertEquals("fieldValue", field.getString());
 
-        FileItem multi0 = (FileItem) fileItems.get(2);
+        FileItem multi0 = fileItems.get(2);
         assertEquals("multi", multi0.getFieldName());
         assertTrue(multi0.isFormField());
         assertEquals("value1", multi0.getString());
 
-        FileItem multi1 = (FileItem) fileItems.get(3);
+        FileItem multi1 = fileItems.get(3);
         assertEquals("multi", multi1.getFieldName());
         assertTrue(multi1.isFormField());
         assertEquals("value2", multi1.getString());
@@ -145,7 +145,7 @@ public class ServletFileUploadTest exten
                                                "-----1234--\r\n");
         assertEquals(1, fileItems.size());
 
-        FileItem file = (FileItem) fileItems.get(0);
+        FileItem file = fileItems.get(0);
         assertEquals("FiLe", file.getFieldName());
         assertEquals("FOO.tab", file.getName());
     }
@@ -164,7 +164,7 @@ public class ServletFileUploadTest exten
                                                 "-----1234--\r\n");
         assertEquals(1, fileItems.size());
 
-        FileItem file = (FileItem) fileItems.get(0);
+        FileItem file = fileItems.get(0);
         assertFalse(file.isFormField());
         assertEquals("", file.getString());
         assertEquals("", file.getName());
@@ -199,22 +199,22 @@ public class ServletFileUploadTest exten
 
         assertEquals(4, fileItems.size());
 
-        FileItem field1 = (FileItem) fileItems.get(0);
+        FileItem field1 = fileItems.get(0);
         assertEquals("field1", field1.getFieldName());
         assertTrue(field1.isFormField());
         assertEquals("fieldValue", field1.getString());
 
-        FileItem submitX = (FileItem) fileItems.get(1);
+        FileItem submitX = fileItems.get(1);
         assertEquals("submitName.x", submitX.getFieldName());
         assertTrue(submitX.isFormField());
         assertEquals("42", submitX.getString());
 
-        FileItem submitY = (FileItem) fileItems.get(2);
+        FileItem submitY = fileItems.get(2);
         assertEquals("submitName.y", submitY.getFieldName());
         assertTrue(submitY.isFormField());
         assertEquals("21", submitY.getString());
 
-        FileItem field2 = (FileItem) fileItems.get(3);
+        FileItem field2 = fileItems.get(3);
         assertEquals("field2", field2.getFieldName());
         assertTrue(field2.isFormField());
         assertEquals("fieldValue2", field2.getString());
@@ -250,15 +250,15 @@ public class ServletFileUploadTest exten
             "--AaB03x--";
         List<FileItem> fileItems = parseUpload(request.getBytes("US-ASCII"), contentType);
         assertEquals(3, fileItems.size());
-        FileItem item0 = (FileItem) fileItems.get(0);
+        FileItem item0 = fileItems.get(0);
         assertEquals("field1", item0.getFieldName());
         assertNull(item0.getName());
         assertEquals("Joe Blow", new String(item0.get()));
-        FileItem item1 = (FileItem) fileItems.get(1);
+        FileItem item1 = fileItems.get(1);
         assertEquals("pics", item1.getFieldName());
         assertEquals("file1.txt", item1.getName());
         assertEquals("... contents of file1.txt ...", new String(item1.get()));
-        FileItem item2 = (FileItem) fileItems.get(2);
+        FileItem item2 = fileItems.get(2);
         assertEquals("pics", item2.getFieldName());
         assertEquals("file2.gif", item2.getName());
         assertEquals("...contents of file2.gif...", new String(item2.get()));
@@ -293,24 +293,24 @@ public class ServletFileUploadTest exten
                 "-----1234--\r\n");
         assertEquals(4, fileItems.size());
 
-        FileItem file = (FileItem) fileItems.get(0);
+        FileItem file = 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);
+        FileItem field = fileItems.get(1);
         assertEquals("field", field.getFieldName());
         assertTrue(field.isFormField());
         assertEquals("fieldValue", field.getString());
 
-        FileItem multi0 = (FileItem) fileItems.get(2);
+        FileItem multi0 = fileItems.get(2);
         assertEquals("multi", multi0.getFieldName());
         assertTrue(multi0.isFormField());
         assertEquals("value1", multi0.getString());
 
-        FileItem multi1 = (FileItem) fileItems.get(3);
+        FileItem multi1 = fileItems.get(3);
         assertEquals("multi", multi1.getFieldName());
         assertTrue(multi1.isFormField());
         assertEquals("value2", multi1.getString());
@@ -359,16 +359,16 @@ public class ServletFileUploadTest exten
                                                "-----1234--\r\n");
         assertEquals(4, fileItems.size());
 
-        FileItem file = (FileItem) fileItems.get(0);
+        FileItem file = fileItems.get(0);
         assertHeaders(headerNames, headerValues, file, 0);
 
-        FileItem field = (FileItem) fileItems.get(1);
+        FileItem field = fileItems.get(1);
         assertHeaders(headerNames, headerValues, field, 1);
 
-        FileItem multi0 = (FileItem) fileItems.get(2);
+        FileItem multi0 = fileItems.get(2);
         assertHeaders(headerNames, headerValues, multi0, 2);
 
-        FileItem multi1 = (FileItem) fileItems.get(3);
+        FileItem multi1 = fileItems.get(3);
         assertHeaders(headerNames, headerValues, multi1, 3);
     }
 

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=1453120&r1=1453119&r2=1453120&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
Wed Mar  6 01:41:57 2013
@@ -69,7 +69,7 @@ public class SizesTest extends FileUploa
             if (++add == 32) {
                 add = 16;
             }
-            FileItem item = (FileItem) fileIter.next();
+            FileItem item = fileIter.next();
             assertEquals("field" + (num++), item.getFieldName());
             byte[] bytes = item.get();
             assertEquals(i, bytes.length);
@@ -100,7 +100,7 @@ public class SizesTest extends FileUploa
         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);
+        FileItem item = fileItems.get(0);
         assertEquals("This is the content of the file\n", new String(item.get()));
 
         upload = new ServletFileUpload(new DiskFileItemFactory());
@@ -108,7 +108,7 @@ public class SizesTest extends FileUploa
         req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
         fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
-        item = (FileItem) fileItems.get(0);
+        item = fileItems.get(0);
         assertEquals("This is the content of the file\n", new String(item.get()));
 
         upload = new ServletFileUpload(new DiskFileItemFactory());

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=1453120&r1=1453119&r2=1453120&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
Wed Mar  6 01:41:57 2013
@@ -54,7 +54,7 @@ public class StreamingTest extends TestC
             if (++add == 32) {
                 add = 16;
             }
-            FileItem item = (FileItem) fileIter.next();
+            FileItem item = fileIter.next();
             assertEquals("field" + (num++), item.getFieldName());
             byte[] bytes = item.get();
             assertEquals(i, bytes.length);
@@ -91,12 +91,14 @@ public class StreamingTest extends TestC
         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 {
                 for (int i = 0;  i < pLen;  i++) {
@@ -127,11 +129,13 @@ public class StreamingTest extends TestC
         byte[] request = newShortRequest();
         final ByteArrayInputStream bais = new ByteArrayInputStream(request);
         List<FileItem> fileItems = 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));
@@ -140,7 +144,7 @@ public class StreamingTest extends TestC
         }, request.length);
         Iterator<FileItem> fileIter = fileItems.iterator();
         assertTrue(fileIter.hasNext());
-        FileItem item = (FileItem) fileIter.next();
+        FileItem item = fileIter.next();
         assertEquals("field", item.getFieldName());
         byte[] bytes = item.get();
         assertEquals(3, bytes.length);
@@ -261,7 +265,7 @@ public class StreamingTest extends TestC
         }
 
         List<FileItem> fileItems = parseUpload(reqBytes);
-        final FileItem fileItem = (FileItem) fileItems.get(0);
+        final FileItem fileItem = fileItems.get(0);
         try {
             fileItem.getName();
             fail("Expected exception");



Mime
View raw message