You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2020/12/22 11:27:22 UTC

svn commit: r1884693 - in /pdfbox/trunk: fontbox/src/test/java/org/apache/fontbox/ttf/BufferedRandomAccessFileTest.java pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSStream.java pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java

Author: tilman
Date: Tue Dec 22 11:27:21 2020
New Revision: 1884693

URL: http://svn.apache.org/viewvc?rev=1884693&view=rev
Log:
PDFBOX-5055: use charset constants, as suggested by Arturo Bernal

Modified:
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/BufferedRandomAccessFileTest.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSStream.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java

Modified: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/BufferedRandomAccessFileTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/BufferedRandomAccessFileTest.java?rev=1884693&r1=1884692&r2=1884693&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/BufferedRandomAccessFileTest.java (original)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/BufferedRandomAccessFileTest.java Tue Dec 22 11:27:21 2020
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -44,7 +45,7 @@ class BufferedRandomAccessFileTest
         try (OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file)))
         {
             final String content = "1234567890";
-            outputStream.write(content.getBytes("UTF-8"));
+            outputStream.write(content.getBytes(StandardCharsets.UTF_8));
             outputStream.flush();
         }
 
@@ -75,7 +76,7 @@ class BufferedRandomAccessFileTest
         try (OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file)))
         {
             final String content = "012345678A012345678B012345678C012345678D";
-            outputStream.write(content.getBytes("UTF-8"));
+            outputStream.write(content.getBytes(StandardCharsets.UTF_8));
             outputStream.flush();
         }
 

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSStream.java?rev=1884693&r1=1884692&r2=1884693&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSStream.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSStream.java Tue Dec 22 11:27:21 2020
@@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 
 import org.apache.pdfbox.filter.Filter;
@@ -41,7 +42,7 @@ class TestCOSStream
     @Test
     void testUncompressedStreamEncode() throws IOException
     {
-        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes("ASCII");
+        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes(StandardCharsets.US_ASCII);
         COSStream stream = createStream(testString, null);
         validateEncoded(stream, testString);
     }
@@ -54,7 +55,7 @@ class TestCOSStream
     @Test
     void testUncompressedStreamDecode() throws IOException
     {
-        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes("ASCII");
+        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes(StandardCharsets.US_ASCII);
         COSStream stream = createStream(testString, null);
         validateDecoded(stream, testString);
     }
@@ -67,7 +68,7 @@ class TestCOSStream
     @Test
     void testCompressedStream1Encode() throws IOException
     {
-        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes("ASCII");
+        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes(StandardCharsets.US_ASCII);
         byte[] testStringEncoded = encodeData(testString, COSName.FLATE_DECODE);
         COSStream stream = createStream(testString, COSName.FLATE_DECODE);
         validateEncoded(stream, testStringEncoded);
@@ -81,7 +82,7 @@ class TestCOSStream
     @Test
     void testCompressedStream1Decode() throws IOException
     {
-        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes("ASCII");
+        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes(StandardCharsets.US_ASCII);
         byte[] testStringEncoded = encodeData(testString, COSName.FLATE_DECODE);
         COSStream stream = new COSStream();
         
@@ -102,7 +103,7 @@ class TestCOSStream
     @Test
     void testCompressedStream2Encode() throws IOException
     {
-        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes("ASCII");
+        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes(StandardCharsets.US_ASCII);
         byte[] testStringEncoded = encodeData(testString, COSName.FLATE_DECODE);
         testStringEncoded = encodeData(testStringEncoded, COSName.ASCII85_DECODE);
         
@@ -122,7 +123,7 @@ class TestCOSStream
     @Test
     void testCompressedStream2Decode() throws IOException
     {
-        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes("ASCII");
+        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes(StandardCharsets.US_ASCII);
         byte[] testStringEncoded = encodeData(testString, COSName.FLATE_DECODE);
         testStringEncoded = encodeData(testStringEncoded, COSName.ASCII85_DECODE);
         COSStream stream = new COSStream();
@@ -150,7 +151,7 @@ class TestCOSStream
     @Test
     void testCompressedStreamDoubleClose() throws IOException
     {
-        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes("ASCII");
+        byte[] testString = "This is a test string to be used as input for TestCOSStream".getBytes(StandardCharsets.US_ASCII);
         byte[] testStringEncoded = encodeData(testString, COSName.FLATE_DECODE);
         COSStream stream = new COSStream();
         OutputStream output = stream.createOutputStream(COSName.FLATE_DECODE);
@@ -176,7 +177,7 @@ class TestCOSStream
         }
 
         byte[] testString = "This is a test string to be used as input for TestCOSStream"
-                .getBytes("ASCII");
+                .getBytes(StandardCharsets.US_ASCII);
         OutputStream output = stream.createOutputStream();
         output.write(testString);
         output.close();

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java?rev=1884693&r1=1884692&r2=1884693&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java Tue Dec 22 11:27:21 2020
@@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Asse
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -54,7 +55,7 @@ class FDFFieldTest
     void testTextAsCOSStreamValue() throws IOException
     {
         String testString = "Test value";
-        byte[] testBytes = testString.getBytes("ASCII");
+        byte[] testBytes = testString.getBytes(StandardCharsets.US_ASCII);
         COSStream stream = createStream(testBytes, null);
         
         FDFField field = new FDFField();