@Test
    public void testShortText() throws IOException {
        LanguageDetector detector = new OptimaizeLangDetector().setShortText(true).loadModels();

        // First verify that we get no result with empty or very short text.
        LanguageWriter writer = new LanguageWriter(detector);
        writer.append("");
        assertEquals(LanguageConfidence.NONE, detector.detect().getConfidence());

        writer.reset();
        writer.append("  ");
        assertEquals(LanguageConfidence.NONE, detector.detect().getConfidence());

        for (String language : getTestLanguages()) {
            // Short pieces of Japanese are detected as Chinese
            if (language.equals("ja")) {
                continue;
            }

            // We need at least 300 characters to detect Chinese reliably.
            writer.reset();
            writeTo(language, writer, 300);

            LanguageResult result = detector.detect();
            assertNotNull(result, String.format(Locale.US, "Language '%s' wasn't detected",
                            language));

            assertTrue(result.isLanguage(language), String.format(Locale.US, "Language '%s' was " +
                            "detected as '%s'", language,
                    result.getLanguage()));
            assertTrue(result.isReasonablyCertain(),
                    String.format(Locale.US, "Language '%s' isn't reasonably certain: %s", language,
                            result.getConfidence()));
        }

        writer.close();
    }
Test correct detection for the many (short) translations of the
"Universal Declaration of Human Rights (Article 1)", at
http://www.omniglot.com/udhr
<p>
Also make sure we get uncertain results for some set of unsupported
languages.

@throws Exception
tika-langdetect/tika-langdetect-optimaize/src/test/java/org/apache/tika/langdetect/optimaize/OptimaizeLangDetectorTest.java