File file = getResourceAsFile("/test-documents/testRTFJapanese.rtf");
Metadata metadata = new Metadata();
InputStream stream = TikaInputStream.get(file, metadata);
// Test w/ default limit:
Tika localTika = new Tika();
String content = localTika.parseToString(stream, metadata);
// parseToString closes for convenience:
//stream.close();
assertTrue(content.length() > 500);
// Test setting max length on the instance:
localTika.setMaxStringLength(200);
stream = TikaInputStream.get(file, metadata);
content = localTika.parseToString(stream, metadata);
// parseToString closes for convenience:
//stream.close();
assertTrue(content.length() <= 200);
// Test setting max length per-call:
stream = TikaInputStream.get(file, metadata);
content = localTika.parseToString(stream, metadata, 100);
// parseToString closes for convenience:
//stream.close();
assertTrue(content.length() <= 100);
}