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

[jspwiki] 02/08: remove @BeforeAll method, not necessary; use constants from StandardCharsets

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit b9055cb397260857c492755129790ab094211498
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Nov 11 14:21:48 2018 +0100

    remove @BeforeAll method, not necessary; use constants from StandardCharsets
---
 .../java/org/apache/wiki/util/FileUtilTest.java    | 32 +++++++---------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/util/FileUtilTest.java b/jspwiki-main/src/test/java/org/apache/wiki/util/FileUtilTest.java
index feba889..b00c87e 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/util/FileUtilTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/util/FileUtilTest.java
@@ -23,24 +23,14 @@ import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.Properties;
+import java.nio.charset.StandardCharsets;
 
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.wiki.TestEngine;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
 public class FileUtilTest
 {
 
-    @BeforeAll
-    public static void setUp()
-    {
-        Properties props = TestEngine.getTestProperties();
-        PropertyConfigurator.configure(props);
-    }
-
     /**
      *  This test actually checks if your JDK is misbehaving.  On my own Debian
      *  machine, changing the system to use UTF-8 suddenly broke Java, and I put
@@ -54,7 +44,7 @@ public class FileUtilTest
     {
         String src = "abc\u00e4\u00e5\u00a6";
 
-        String res = new String( src.getBytes("ISO-8859-1"), "ISO-8859-1" );
+        String res = new String( src.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.ISO_8859_1 );
 
         Assertions.assertEquals( src, res );
     }
@@ -65,8 +55,8 @@ public class FileUtilTest
     {
         String src = "abc\u00e4\u00e5\u00a6";
 
-        String res = FileUtil.readContents( new ByteArrayInputStream( src.getBytes("ISO-8859-1") ),
-                                            "ISO-8859-1" );
+        String res = FileUtil.readContents( new ByteArrayInputStream( src.getBytes(StandardCharsets.ISO_8859_1) ),
+                                            StandardCharsets.ISO_8859_1.name() );
 
         Assertions.assertEquals( src, res );
     }
@@ -80,17 +70,15 @@ public class FileUtilTest
     {
         String src = "abc\u00e4\u00e5\u00a6def";
 
-        String res = FileUtil.readContents( new ByteArrayInputStream( src.getBytes("ISO-8859-1") ),
-                                            "UTF-8" );
+        String res = FileUtil.readContents( new ByteArrayInputStream( src.getBytes(StandardCharsets.ISO_8859_1) ),
+                                            StandardCharsets.UTF_8.name() );
 
         Assertions.assertEquals( src, res );
     }
 
     /**
-       ISO Latin 1 from a pipe.
-
-       FIXME: Works only on UNIX systems now.
-    */
+     * ISO Latin 1 from a pipe.
+     */
     @Test
     public void testReadContentsFromPipe()
         throws Exception
@@ -105,7 +93,7 @@ public class FileUtilTest
 
         src += "\u00e4\u00e5\u00a6";
 
-        File f = FileUtil.newTmpFile( src, "ISO-8859-1" );
+        File f = FileUtil.newTmpFile( src, StandardCharsets.ISO_8859_1.name() );
 
         String[] envp = {};
 
@@ -113,7 +101,7 @@ public class FileUtilTest
         {
             Process process = Runtime.getRuntime().exec( "cat "+f.getAbsolutePath(), envp, f.getParentFile() );
 
-            String result = FileUtil.readContents( process.getInputStream(), "UTF-8" );
+            String result = FileUtil.readContents( process.getInputStream(), StandardCharsets.UTF_8.name() );
 
             f.delete();