You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ni...@apache.org on 2015/08/20 11:42:41 UTC

svn commit: r1696743 - in /tika/trunk/tika-core/src/test/java/org/apache/tika: detect/ io/ language/ mime/ parser/mock/ sax/

Author: nick
Date: Thu Aug 20 09:42:40 2015
New Revision: 1696743

URL: http://svn.apache.org/r1696743
Log:
TIKA-1710 patch from Yaniv Kunda - Use java.nio.charset.StandardCharsets

Modified:
    tika/trunk/tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/detect/TextDetectorTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/io/TailStreamTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/io/TikaInputStreamTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageIdentifierTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageProfilerBuilderTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeTypesReaderTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTestWithTika.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BasicContentHandlerFactoryTest.java
    tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java Thu Aug 20 09:42:40 2015
@@ -24,6 +24,9 @@ import org.apache.tika.metadata.Metadata
 import org.apache.tika.mime.MediaType;
 import org.junit.Test;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static java.nio.charset.StandardCharsets.UTF_16BE;
+import static java.nio.charset.StandardCharsets.UTF_16LE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -35,7 +38,7 @@ public class MagicDetectorTest {
     @Test
     public void testDetectNull() throws Exception {
         MediaType html = new MediaType("text", "html");
-        Detector detector = new MagicDetector(html, "<html".getBytes("ASCII"));
+        Detector detector = new MagicDetector(html, "<html".getBytes(US_ASCII));
         assertEquals(
                 MediaType.OCTET_STREAM,
                 detector.detect(null, new Metadata()));
@@ -44,7 +47,7 @@ public class MagicDetectorTest {
     @Test
     public void testDetectSimple() throws Exception {
         MediaType html = new MediaType("text", "html");
-        Detector detector = new MagicDetector(html, "<html".getBytes("ASCII"));
+        Detector detector = new MagicDetector(html, "<html".getBytes(US_ASCII));
 
         assertDetect(detector, html, "<html");
         assertDetect(detector, html, "<html><head/><body/></html>");
@@ -58,7 +61,7 @@ public class MagicDetectorTest {
     public void testDetectOffsetRange() throws Exception {
         MediaType html = new MediaType("text", "html");
         Detector detector = new MagicDetector(
-                html, "<html".getBytes("ASCII"), null, 0, 64);
+                html, "<html".getBytes(US_ASCII), null, 0, 64);
 
         assertDetect(detector, html, "<html");
         assertDetect(detector, html, "<html><head/><body/></html>");
@@ -111,7 +114,7 @@ public class MagicDetectorTest {
     public void testDetectRegExPDF() throws Exception {
         MediaType pdf = new MediaType("application", "pdf");
         Detector detector = new MagicDetector(
-                pdf, "(?s)\\A.{0,144}%PDF-".getBytes("ASCII"), null, true, 0, 0);
+                pdf, "(?s)\\A.{0,144}%PDF-".getBytes(US_ASCII), null, true, 0, 0);
 
         assertDetect(detector, pdf, "%PDF-1.0");
         assertDetect(
@@ -136,7 +139,7 @@ public class MagicDetectorTest {
                 + "\".*\\x3ctitle\\x3e.*\\x3c/title\\x3e";
         MediaType xhtml = new MediaType("application", "xhtml+xml");
         Detector detector = new MagicDetector(xhtml,
-                pattern.getBytes("ASCII"), null,
+                pattern.getBytes(US_ASCII), null,
                 true, 0, 8192);
 
         assertDetect(detector, xhtml,
@@ -171,7 +174,7 @@ public class MagicDetectorTest {
 
         MediaType html = new MediaType("text", "html");
         Detector detector = new MagicDetector(
-                html, pattern.getBytes("ASCII"), null, true, 0, 0);
+                html, pattern.getBytes(US_ASCII), null, true, 0, 0);
 
         assertDetect(detector, html, data);
         assertDetect(detector, html, data1);
@@ -180,7 +183,7 @@ public class MagicDetectorTest {
 
     @Test
     public void testDetectStreamReadProblems() throws Exception {
-        byte[] data = "abcdefghijklmnopqrstuvwxyz0123456789".getBytes("ASCII");
+        byte[] data = "abcdefghijklmnopqrstuvwxyz0123456789".getBytes(US_ASCII);
         MediaType testMT = new MediaType("application", "test");
         Detector detector = new MagicDetector(testMT, data, null, false, 0, 0);
         // Deliberately prevent InputStream.read(...) from reading the entire
@@ -197,28 +200,24 @@ public class MagicDetectorTest {
         
         // Check regular String matching
         detector = MagicDetector.parse(testMT, "string", "0:20", "abcd", null); 
-        assertDetect(detector, testMT, data.getBytes("ASCII"));
+        assertDetect(detector, testMT, data.getBytes(US_ASCII));
         detector = MagicDetector.parse(testMT, "string", "0:20", "cdEFGh", null); 
-        assertDetect(detector, testMT, data.getBytes("ASCII"));
+        assertDetect(detector, testMT, data.getBytes(US_ASCII));
         
         // Check Little Endian and Big Endian utf-16 strings
         detector = MagicDetector.parse(testMT, "unicodeLE", "0:20", "cdEFGh", null); 
-        assertDetect(detector, testMT, data.getBytes("UTF-16LE"));
+        assertDetect(detector, testMT, data.getBytes(UTF_16LE));
         detector = MagicDetector.parse(testMT, "unicodeBE", "0:20", "cdEFGh", null); 
-        assertDetect(detector, testMT, data.getBytes("UTF-16BE"));
+        assertDetect(detector, testMT, data.getBytes(UTF_16BE));
         
         // Check case ignoring String matching
         detector = MagicDetector.parse(testMT, "stringignorecase", "0:20", "BcDeFgHiJKlm", null); 
-        assertDetect(detector, testMT, data.getBytes("ASCII"));
+        assertDetect(detector, testMT, data.getBytes(US_ASCII));
     }
 
     private void assertDetect(Detector detector, MediaType type, String data) {
-        try {
-            byte[] bytes = data.getBytes("ASCII");
-            assertDetect(detector, type, bytes);
-        } catch (IOException e) {
-            fail("Unexpected exception from MagicDetector");
-        }
+        byte[] bytes = data.getBytes(US_ASCII);
+        assertDetect(detector, type, bytes);
     }
     private void assertDetect(Detector detector, MediaType type, byte[] bytes) {
         try {

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/detect/TextDetectorTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/detect/TextDetectorTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/detect/TextDetectorTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/detect/TextDetectorTest.java Thu Aug 20 09:42:40 2015
@@ -21,11 +21,11 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
 
-import org.apache.tika.io.IOUtils;
 import org.apache.tika.metadata.Metadata;
 import org.apache.tika.mime.MediaType;
 import org.junit.Test;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -55,8 +55,8 @@ public class TextDetectorTest {
 
     @Test
     public void testDetectText() throws Exception {
-        assertText("Hello, World!".getBytes(IOUtils.UTF_8));
-        assertText(" \t\r\n".getBytes(IOUtils.UTF_8));
+        assertText("Hello, World!".getBytes(UTF_8));
+        assertText(" \t\r\n".getBytes(UTF_8));
         assertNotText(new byte[] { -1, -2, -3, 0x09, 0x0A, 0x0C, 0x0D, 0x1B });
         assertNotText(new byte[] { 0 });
         assertNotText(new byte[] { 'H', 'e', 'l', 'l', 'o', 0 });

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/io/TailStreamTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/io/TailStreamTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/io/TailStreamTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/io/TailStreamTest.java Thu Aug 20 09:42:40 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.tika.io;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -68,7 +69,7 @@ public class TailStreamTest
      */
     private static InputStream generateStream(int from, int length)
     {
-        return new ByteArrayInputStream(generateText(from, length).getBytes(IOUtils.UTF_8));
+        return new ByteArrayInputStream(generateText(from, length).getBytes(UTF_8));
     }
 
     /**
@@ -123,7 +124,7 @@ public class TailStreamTest
         TailStream stream = new TailStream(generateStream(0, 2 * count), count);
         readStream(stream);
         assertEquals("Wrong buffer", generateText(count, count), new String(
-                stream.getTail(), IOUtils.UTF_8));
+                stream.getTail(), UTF_8));
     }
 
     /**
@@ -144,7 +145,7 @@ public class TailStreamTest
             read = stream.read(buf);
         }
         assertEquals("Wrong buffer", generateText(count - tailSize, tailSize),
-                new String(stream.getTail(), IOUtils.UTF_8));
+                new String(stream.getTail(), UTF_8));
         stream.close();
     }
 
@@ -164,7 +165,7 @@ public class TailStreamTest
         stream.reset();
         readStream(stream);
         assertEquals("Wrong buffer", generateText(tailSize, tailSize),
-                new String(stream.getTail(), IOUtils.UTF_8));
+                new String(stream.getTail(), UTF_8));
     }
 
     /**
@@ -180,7 +181,7 @@ public class TailStreamTest
         byte[] buf = new byte[count];
         stream.read(buf);
         assertEquals("Wrong buffer", generateText(count - tailSize, tailSize),
-                new String(stream.getTail(), IOUtils.UTF_8));
+                new String(stream.getTail(), UTF_8));
         stream.close();
     }
 
@@ -197,7 +198,7 @@ public class TailStreamTest
         assertEquals("Wrong skip result", skipCount, stream.skip(skipCount));
         assertEquals("Wrong buffer",
                 generateText(skipCount - tailSize, tailSize),
-                new String(stream.getTail(), IOUtils.UTF_8));
+                new String(stream.getTail(), UTF_8));
         stream.close();
     }
 
@@ -211,7 +212,7 @@ public class TailStreamTest
         TailStream stream = new TailStream(generateStream(0, count), 2 * count);
         assertEquals("Wrong skip result", count, stream.skip(2 * count));
         assertEquals("Wrong buffer", generateText(0, count),
-                new String(stream.getTail(), IOUtils.UTF_8));
+                new String(stream.getTail(), UTF_8));
         stream.close();
     }
 

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/io/TikaInputStreamTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/io/TikaInputStreamTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/io/TikaInputStreamTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/io/TikaInputStreamTest.java Thu Aug 20 09:42:40 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.tika.io;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -62,7 +63,7 @@ public class TikaInputStreamTest {
     @Test
     public void testStreamBased() throws IOException {
         InputStream input =
-            new ByteArrayInputStream("Hello, World!".getBytes(IOUtils.UTF_8));
+            new ByteArrayInputStream("Hello, World!".getBytes(UTF_8));
         InputStream stream = TikaInputStream.get(input);
 
         File file = TikaInputStream.get(stream).getFile();
@@ -89,7 +90,7 @@ public class TikaInputStreamTest {
         File file = File.createTempFile("tika-", ".tmp");
         OutputStream stream = new FileOutputStream(file);
         try {
-            stream.write(data.getBytes(IOUtils.UTF_8));
+            stream.write(data.getBytes(UTF_8));
         } finally {
             stream.close();
         }
@@ -108,7 +109,7 @@ public class TikaInputStreamTest {
     private String readStream(InputStream stream) throws IOException {
         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         IOUtils.copy(stream, buffer);
-        return buffer.toString(IOUtils.UTF_8.name());
+        return buffer.toString(UTF_8.name());
     }
 
     @Test

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageIdentifierTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageIdentifierTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageIdentifierTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageIdentifierTest.java Thu Aug 20 09:42:40 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.tika.language;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -175,7 +176,7 @@ public class LanguageIdentifierTest {
         InputStream stream =
             LanguageIdentifierTest.class.getResourceAsStream(language + ".test");
         try {
-            IOUtils.copy(new InputStreamReader(stream, IOUtils.UTF_8), writer);
+            IOUtils.copy(new InputStreamReader(stream, UTF_8), writer);
         } finally {
             stream.close();
         }

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageProfilerBuilderTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageProfilerBuilderTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageProfilerBuilderTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/language/LanguageProfilerBuilderTest.java Thu Aug 20 09:42:40 2015
@@ -17,6 +17,7 @@
 
 package org.apache.tika.language;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -30,7 +31,6 @@ import java.io.InputStreamReader;
 import java.net.URISyntaxException;
 
 import org.apache.tika.exception.TikaException;
-import org.apache.tika.io.IOUtils;
 import org.junit.After;
 import org.junit.Test;
 
@@ -50,7 +50,7 @@ public class LanguageProfilerBuilderTest
         InputStream is =
                 LanguageProfilerBuilderTest.class.getResourceAsStream(corpusName);
         try {
-            ngramProfile = LanguageProfilerBuilder.create(profileName, is , IOUtils.UTF_8.name());
+            ngramProfile = LanguageProfilerBuilder.create(profileName, is , UTF_8.name());
         } finally {
             is.close();
         }
@@ -82,7 +82,7 @@ public class LanguageProfilerBuilderTest
                 + FILE_EXTENSION));
         try {
             BufferedReader reader = new BufferedReader(new InputStreamReader(
-                    stream, IOUtils.UTF_8));
+                    stream, UTF_8));
             String line = reader.readLine();
             while (line != null) {
                 if (line.length() > 0 && !line.startsWith("#")) {// skips the

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java Thu Aug 20 09:42:40 2015
@@ -16,6 +16,9 @@
  */
 package org.apache.tika.mime;
 
+import static java.nio.charset.StandardCharsets.UTF_16BE;
+import static java.nio.charset.StandardCharsets.UTF_16LE;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -25,7 +28,6 @@ import java.io.InputStream;
 import java.net.URL;
 
 import org.apache.tika.config.TikaConfig;
-import org.apache.tika.io.IOUtils;
 import org.apache.tika.metadata.Metadata;
 import org.junit.Before;
 import org.junit.Test;
@@ -82,13 +84,13 @@ public class MimeDetectionTest {
     @Test
     public void testByteOrderMark() throws Exception {
         assertEquals(MediaType.TEXT_PLAIN, mimeTypes.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes("UTF-16LE")),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_16LE)),
                 new Metadata()));
         assertEquals(MediaType.TEXT_PLAIN, mimeTypes.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes("UTF-16BE")),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_16BE)),
                 new Metadata()));
         assertEquals(MediaType.TEXT_PLAIN, mimeTypes.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes(IOUtils.UTF_8)),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_8)),
                 new Metadata()));
     }
 
@@ -198,7 +200,7 @@ public class MimeDetectionTest {
     @Test
     public void testNotXML() throws IOException {
         assertEquals(MediaType.TEXT_PLAIN, mimeTypes.detect(
-                new ByteArrayInputStream("<!-- test -->".getBytes(IOUtils.UTF_8)),
+                new ByteArrayInputStream("<!-- test -->".getBytes(UTF_8)),
                 new Metadata()));
     }
 
@@ -222,7 +224,7 @@ public class MimeDetectionTest {
      */
     @Test    
     public void testMimeMagicClashSamePriority() throws IOException {
-        byte[] helloWorld = "Hello, World!".getBytes(IOUtils.UTF_8);
+        byte[] helloWorld = "Hello, World!".getBytes(UTF_8);
         MediaType helloType = MediaType.parse("hello/world-file");
         MediaType helloXType = MediaType.parse("hello/x-world-hello");
         Metadata metadata;

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeTypesReaderTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeTypesReaderTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeTypesReaderTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeTypesReaderTest.java Thu Aug 20 09:42:40 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.tika.mime;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -225,7 +226,7 @@ public class MimeTypesReaderTest {
           // By contents - picks the x one as that sorts later
           m = new Metadata();
           ByteArrayInputStream s = new ByteArrayInputStream(
-                "Hello, World!".getBytes("ASCII"));
+                "Hello, World!".getBytes(US_ASCII));
           assertEquals(hxw.toString(), this.mimeTypes.detect(s, m).toString());
        } catch (Exception e) {
           fail(e.getMessage());

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTest.java Thu Aug 20 09:42:40 2015
@@ -16,6 +16,9 @@
  */
 package org.apache.tika.mime;
 
+import static java.nio.charset.StandardCharsets.UTF_16BE;
+import static java.nio.charset.StandardCharsets.UTF_16LE;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -23,14 +26,13 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.nio.charset.Charset;
 
 import org.apache.tika.metadata.Metadata;
 import org.junit.Before;
 import org.junit.Test;
 
 public class ProbabilisticMimeDetectionTest {
-    private static final Charset UTF8 = Charset.forName("UTF-8");
+
     private ProbabilisticMimeDetectionSelector proDetector;
 
     private MediaTypeRegistry registry;
@@ -76,14 +78,14 @@ public class ProbabilisticMimeDetectionT
     @Test
     public void testByteOrderMark() throws Exception {
         assertEquals(MediaType.TEXT_PLAIN, proDetector.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes("UTF-16LE")),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_16LE)),
                 new Metadata()));
         assertEquals(MediaType.TEXT_PLAIN, proDetector.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes("UTF-16BE")),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_16BE)),
                 new Metadata()));
 
         assertEquals(MediaType.TEXT_PLAIN, proDetector.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes(UTF8)),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_8)),
                 new Metadata()));
     }
 
@@ -199,7 +201,7 @@ public class ProbabilisticMimeDetectionT
     @Test
     public void testNotXML() throws IOException {
         assertEquals(MediaType.TEXT_PLAIN, proDetector.detect(
-                new ByteArrayInputStream("<!-- test -->".getBytes(UTF8)),
+                new ByteArrayInputStream("<!-- test -->".getBytes(UTF_8)),
                 new Metadata()));
     }
 
@@ -222,7 +224,7 @@ public class ProbabilisticMimeDetectionT
      */
     @Test
     public void testMimeMagicClashSamePriority() throws IOException {
-        byte[] helloWorld = "Hello, World!".getBytes(UTF8);
+        byte[] helloWorld = "Hello, World!".getBytes(UTF_8);
         MediaType helloType = MediaType.parse("hello/world-file");
         MediaType helloXType = MediaType.parse("hello/x-world-hello");
         Metadata metadata;

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTestWithTika.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTestWithTika.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTestWithTika.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/mime/ProbabilisticMimeDetectionTestWithTika.java Thu Aug 20 09:42:40 2015
@@ -1,4 +1,3 @@
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -17,6 +16,9 @@
  */
 package org.apache.tika.mime;
 
+import static java.nio.charset.StandardCharsets.UTF_16BE;
+import static java.nio.charset.StandardCharsets.UTF_16LE;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -25,7 +27,6 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.nio.charset.Charset;
 
 import org.apache.tika.Tika;
 import org.apache.tika.config.ServiceLoader;
@@ -36,8 +37,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class ProbabilisticMimeDetectionTestWithTika {
-    private static final Charset UTF8 = Charset.forName("UTF-8");
-    
+
     private ProbabilisticMimeDetectionSelector proSelector;
     private MediaTypeRegistry registry;
     private Tika tika;
@@ -98,14 +98,14 @@ public class ProbabilisticMimeDetectionT
     @Test
     public void testByteOrderMark() throws Exception {
         assertEquals(MediaType.TEXT_PLAIN.toString(), tika.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes("UTF-16LE")),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_16LE)),
                 new Metadata()));
         assertEquals(MediaType.TEXT_PLAIN.toString(), tika.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes("UTF-16BE")),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_16BE)),
                 new Metadata()));
 
         assertEquals(MediaType.TEXT_PLAIN.toString(), tika.detect(
-                new ByteArrayInputStream("\ufefftest".getBytes(UTF8)),
+                new ByteArrayInputStream("\ufefftest".getBytes(UTF_8)),
                 new Metadata()));
     }
 
@@ -219,7 +219,7 @@ public class ProbabilisticMimeDetectionT
     @Test
     public void testNotXML() throws IOException {
         assertEquals(MediaType.TEXT_PLAIN.toString(), tika.detect(
-                new ByteArrayInputStream("<!-- test -->".getBytes(UTF8)),
+                new ByteArrayInputStream("<!-- test -->".getBytes(UTF_8)),
                 new Metadata()));
     }
 
@@ -242,7 +242,7 @@ public class ProbabilisticMimeDetectionT
      */
     @Test
     public void testMimeMagicClashSamePriority() throws IOException {
-        byte[] helloWorld = "Hello, World!".getBytes(UTF8);
+        byte[] helloWorld = "Hello, World!".getBytes(UTF_8);
         MediaType helloType = MediaType.parse("hello/world-file");
         MediaType helloXType = MediaType.parse("hello/x-world-hello");
         Metadata metadata;

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/parser/mock/MockParser.java Thu Aug 20 09:42:40 2015
@@ -34,7 +34,6 @@ import java.util.Set;
 import org.apache.tika.exception.TikaException;
 import org.apache.tika.extractor.EmbeddedDocumentExtractor;
 import org.apache.tika.extractor.ParsingEmbeddedDocumentExtractor;
-import org.apache.tika.io.IOUtils;
 import org.apache.tika.metadata.Metadata;
 import org.apache.tika.metadata.TikaMetadataKeys;
 import org.apache.tika.mime.MediaType;
@@ -50,6 +49,8 @@ import org.w3c.dom.NodeList;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 /**
  * This class enables mocking of parser behavior for use in testing
  * wrappers and drivers of parsers.
@@ -150,7 +151,7 @@ public class MockParser extends Abstract
         if (! "".equals(contentType)) {
             m.set(Metadata.CONTENT_TYPE, contentType);
         }
-        InputStream is = new ByteArrayInputStream(embeddedText.getBytes(IOUtils.UTF_8));
+        InputStream is = new ByteArrayInputStream(embeddedText.getBytes(UTF_8));
 
         extractor.parseEmbedded(
                 is,

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BasicContentHandlerFactoryTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BasicContentHandlerFactoryTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BasicContentHandlerFactoryTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BasicContentHandlerFactoryTest.java Thu Aug 20 09:42:40 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.tika.sax;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -27,7 +28,6 @@ import java.io.UnsupportedEncodingExcept
 import java.util.Set;
 
 import org.apache.tika.exception.TikaException;
-import org.apache.tika.io.IOUtils;
 import org.apache.tika.metadata.Metadata;
 import org.apache.tika.mime.MediaType;
 import org.apache.tika.parser.ParseContext;
@@ -44,7 +44,7 @@ import org.xml.sax.helpers.DefaultHandle
  */
 public class BasicContentHandlerFactoryTest {
 
-    private static final String ENCODING = IOUtils.UTF_8.name();
+    private static final String ENCODING = UTF_8.name();
     //default max char len (at least in WriteOutContentHandler is 100k)
     private static final int OVER_DEFAULT = 120000;
 

Modified: tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java?rev=1696743&r1=1696742&r2=1696743&view=diff
==============================================================================
--- tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java (original)
+++ tika/trunk/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java Thu Aug 20 09:42:40 2015
@@ -16,12 +16,12 @@
  */
 package org.apache.tika.sax;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 
-import org.apache.tika.io.IOUtils;
 import org.apache.tika.metadata.Metadata;
 import org.junit.Test;
 
@@ -46,7 +46,7 @@ public class BodyContentHandlerTest {
         xhtml.element("p", "Test text");
         xhtml.endDocument();
 
-        assertEquals("Test text\n", buffer.toString(IOUtils.UTF_8.name()));
+        assertEquals("Test text\n", buffer.toString(UTF_8.name()));
     }
 
 }