@Test
public void testCharsetDetection() throws URISyntaxException, IOException {

    Collection<Tuple3<String, Encoding.ByteOrderMark, String>> testEntries = new LinkedList<>();
    testEntries.add(new Tuple3<>("/test.utf8-bom.csv",
            Encoding.ByteOrderMark.UTF_8, "UTF-8"));
    testEntries.add(new Tuple3<>("/test.utf8.csv",
            Encoding.ByteOrderMark.NONE, "UTF-8"));
    testEntries.add(new Tuple3<>("/test.utf16le-bom.csv",
            Encoding.ByteOrderMark.UTF_16_LE, "UTF-16LE"));
    testEntries.add(new Tuple3<>("/test.utf16be-bom.csv",
            Encoding.ByteOrderMark.UTF_16_BE, "UTF-16BE"));
    // Known bug: The UTF16LE/BE encoding is not properly recognized by juniversalchardet.
    // TODO: On larger test files, this might be different.
      testEntries.add(new Tuple3<String, Encoding.ByteOrderMark, String>("/test.utf16le.csv",
              Encoding.ByteOrderMark.UTF_16_LE, "UTF-16LE"));
      testEntries.add(new Tuple3<String, Encoding.ByteOrderMark, String>("/test.utf16be.csv",
              Encoding.ByteOrderMark.UTF_16_BE, "UTF-16BE"));
    testEntries.add(new Tuple3<>("/test.ucs2le.csv",
            Encoding.ByteOrderMark.UTF_16_LE, "UTF-16LE"));
    testEntries.add(new Tuple3<>("/test.ucs2be.csv",
            Encoding.ByteOrderMark.UTF_16_BE, "UTF-16BE"));
    testEntries.add(new Tuple3<>("/test.ansi.csv",
            Encoding.ByteOrderMark.NONE, "UTF-8"));
    testEntries.add(new Tuple3<>("/empty.csv",
            Encoding.DEFAULT_ENCODING.getByteOrderMark(), Encoding.DEFAULT_ENCODING.getCharset().toString()));
    for (Tuple3<String, Encoding.ByteOrderMark, String> testEntry : testEntries) {
        Path path = new Path(getClass().getResource(testEntry.f0).toURI().toString());
        Encoding encoding = FileUtils.detectEncoding(path, null, Encoding.DEFAULT_ENCODING, null);
        Assert.assertEquals(String.format("in %s", testEntry.f0),
                testEntry.f1 == null ? null : new Encoding(testEntry.f1, testEntry.f2), encoding);
    }
}