commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ki...@apache.org
Subject commons-fileupload git commit: FILEUPLOAD-283: replace StandardCharsets (java7) by string values
Date Fri, 04 Aug 2017 23:37:59 GMT
Repository: commons-fileupload
Updated Branches:
  refs/heads/master fc2d541d3 -> 422caf46e


FILEUPLOAD-283: replace StandardCharsets (java7) by string values


Project: http://git-wip-us.apache.org/repos/asf/commons-fileupload/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-fileupload/commit/422caf46
Tree: http://git-wip-us.apache.org/repos/asf/commons-fileupload/tree/422caf46
Diff: http://git-wip-us.apache.org/repos/asf/commons-fileupload/diff/422caf46

Branch: refs/heads/master
Commit: 422caf46e5b7a950c639b8ba9fe41e16279b3aa9
Parents: fc2d541
Author: Bruno P. Kinoshita <brunodepaulak@yahoo.com.br>
Authored: Sat Aug 5 11:37:36 2017 +1200
Committer: Bruno P. Kinoshita <brunodepaulak@yahoo.com.br>
Committed: Sat Aug 5 11:37:36 2017 +1200

----------------------------------------------------------------------
 .../commons/fileupload/ProgressListenerTest.java |  7 +++----
 .../org/apache/commons/fileupload/SizesTest.java | 19 +++++++++----------
 .../java/org/apache/commons/fileupload/Util.java |  3 +--
 .../portlet/PortletFileUploadTest.java           |  3 +--
 .../servlet/ServletFileUploadTest.java           |  3 +--
 5 files changed, 15 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/422caf46/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java b/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
index 721498f..1de976d 100644
--- a/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
+++ b/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.fail;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.junit.Test;
@@ -77,13 +76,13 @@ public class ProgressListenerTest {
             String header = "-----1234\r\n"
                 + "Content-Disposition: form-data; name=\"field" + (i+1) + "\"\r\n"
                 + "\r\n";
-            baos.write(header.getBytes(StandardCharsets.US_ASCII.name()));
+            baos.write(header.getBytes("US-ASCII"));
             for (int j = 0;  j < 16384+i;  j++) {
                 baos.write((byte) j);
             }
-            baos.write("\r\n".getBytes(StandardCharsets.US_ASCII.name()));
+            baos.write("\r\n".getBytes("US-ASCII"));
         }
-        baos.write("-----1234--\r\n".getBytes(StandardCharsets.US_ASCII.name()));
+        baos.write("-----1234--\r\n".getBytes("US-ASCII"));
         byte[] contents = baos.toByteArray();
 
         MockHttpServletRequest request = new MockHttpServletRequest(contents, Constants.CONTENT_TYPE);

http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/422caf46/src/test/java/org/apache/commons/fileupload/SizesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/fileupload/SizesTest.java b/src/test/java/org/apache/commons/fileupload/SizesTest.java
index f328d41..a0c90d2 100644
--- a/src/test/java/org/apache/commons/fileupload/SizesTest.java
+++ b/src/test/java/org/apache/commons/fileupload/SizesTest.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.fail;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
 import java.util.Iterator;
 import java.util.List;
 
@@ -103,7 +102,7 @@ public class SizesTest {
         ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
         upload.setFileSizeMax(-1);
         HttpServletRequest req = new MockHttpServletRequest(
-                request.getBytes(StandardCharsets.US_ASCII.name()), Constants.CONTENT_TYPE);
+                request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         List<FileItem> fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
         FileItem item = fileItems.get(0);
@@ -111,7 +110,7 @@ public class SizesTest {
 
         upload = new ServletFileUpload(new DiskFileItemFactory());
         upload.setFileSizeMax(40);
-        req = new MockHttpServletRequest(request.getBytes(StandardCharsets.US_ASCII.name()),
Constants.CONTENT_TYPE);
+        req = new MockHttpServletRequest(request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
         item = fileItems.get(0);
@@ -119,7 +118,7 @@ public class SizesTest {
 
         upload = new ServletFileUpload(new DiskFileItemFactory());
         upload.setFileSizeMax(30);
-        req = new MockHttpServletRequest(request.getBytes(StandardCharsets.US_ASCII.name()),
Constants.CONTENT_TYPE);
+        req = new MockHttpServletRequest(request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         try {
             upload.parseRequest(req);
             fail("Expected exception.");
@@ -146,7 +145,7 @@ public class SizesTest {
         ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
         upload.setFileSizeMax(-1);
         HttpServletRequest req = new MockHttpServletRequest(
-                request.getBytes(StandardCharsets.US_ASCII.name()), Constants.CONTENT_TYPE);
+                request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         List<FileItem> fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
         FileItem item = fileItems.get(0);
@@ -154,7 +153,7 @@ public class SizesTest {
 
         upload = new ServletFileUpload(new DiskFileItemFactory());
         upload.setFileSizeMax(40);
-        req = new MockHttpServletRequest(request.getBytes(StandardCharsets.US_ASCII.name()),
Constants.CONTENT_TYPE);
+        req = new MockHttpServletRequest(request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
         item = fileItems.get(0);
@@ -163,7 +162,7 @@ public class SizesTest {
         // provided Content-Length is larger than the FileSizeMax -> handled by ctor
         upload = new ServletFileUpload(new DiskFileItemFactory());
         upload.setFileSizeMax(5);
-        req = new MockHttpServletRequest(request.getBytes(StandardCharsets.US_ASCII.name()),
Constants.CONTENT_TYPE);
+        req = new MockHttpServletRequest(request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         try {
             upload.parseRequest(req);
             fail("Expected exception.");
@@ -174,7 +173,7 @@ public class SizesTest {
         // provided Content-Length is wrong, actual content is larger -> handled by LimitedInputStream
         upload = new ServletFileUpload(new DiskFileItemFactory());
         upload.setFileSizeMax(15);
-        req = new MockHttpServletRequest(request.getBytes(StandardCharsets.US_ASCII.name()),
Constants.CONTENT_TYPE);
+        req = new MockHttpServletRequest(request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         try {
             upload.parseRequest(req);
             fail("Expected exception.");
@@ -209,7 +208,7 @@ public class SizesTest {
         upload.setSizeMax(200);
 
         MockHttpServletRequest req = new MockHttpServletRequest(
-                request.getBytes(StandardCharsets.US_ASCII.name()), Constants.CONTENT_TYPE);
+                request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         try {
             upload.parseRequest(req);
             fail("Expected exception.");
@@ -246,7 +245,7 @@ public class SizesTest {
         // otherwise the buffer would be immediately filled
 
         MockHttpServletRequest req = new MockHttpServletRequest(
-                request.getBytes(StandardCharsets.US_ASCII.name()), Constants.CONTENT_TYPE);
+                request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
         req.setContentLength(-1);
         req.setReadLimit(10);
 

http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/422caf46/src/test/java/org/apache/commons/fileupload/Util.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/fileupload/Util.java b/src/test/java/org/apache/commons/fileupload/Util.java
index 42041e3..692fb6e 100644
--- a/src/test/java/org/apache/commons/fileupload/Util.java
+++ b/src/test/java/org/apache/commons/fileupload/Util.java
@@ -17,7 +17,6 @@
 package org.apache.commons.fileupload;
 
 import java.io.UnsupportedEncodingException;
-import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
 
@@ -47,7 +46,7 @@ public class Util {
 
     public static List<FileItem> parseUpload(FileUpload upload, String content)
         throws UnsupportedEncodingException, FileUploadException {
-        byte[] bytes = content.getBytes(StandardCharsets.US_ASCII.name());
+        byte[] bytes = content.getBytes("US-ASCII");
         return parseUpload(upload, bytes, Constants.CONTENT_TYPE);
     }
 

http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/422caf46/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
b/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
index 7b2aa80..b56444f 100644
--- a/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
+++ b/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
@@ -19,7 +19,6 @@ package org.apache.commons.fileupload.portlet;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 
@@ -69,7 +68,7 @@ public class PortletFileUploadTest {
                       "\r\n" +
                       "value2\r\n" +
                       "-----1234--\r\n";
-        byte[] bytes = text.getBytes(StandardCharsets.US_ASCII.name());
+        byte[] bytes = text.getBytes("US-ASCII");
         ActionRequest request = new MockPortletActionRequest(bytes, Constants.CONTENT_TYPE);
 
         Map<String, List<FileItem>> mappedParameters = upload.parseParameterMap(request);

http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/422caf46/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
b/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
index 69480d7..3519a2f 100644
--- a/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
+++ b/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
@@ -19,7 +19,6 @@ package org.apache.commons.fileupload.servlet;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 
@@ -72,7 +71,7 @@ public class ServletFileUploadTest {
                       "\r\n" +
                       "value2\r\n" +
                       "-----1234--\r\n";
-        byte[] bytes = text.getBytes(StandardCharsets.US_ASCII.name());
+        byte[] bytes = text.getBytes("US-ASCII");
         HttpServletRequest request = new MockHttpServletRequest(bytes, Constants.CONTENT_TYPE);
 
         Map<String, List<FileItem>> mappedParameters = upload.parseParameterMap(request);


Mime
View raw message