tballison commented on code in PR #2843:
URL: https://github.com/apache/tika/pull/2843#discussion_r3316821970
##########
tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java:
##########
@@ -760,6 +760,25 @@ public void testListParserDetailApt() throws Exception {
assertTrue(content.contains("application/vnd.oasis.opendocument.text-web"));
}
+ /**
+ * Tests --convert-config-xml-to-json with no separate config file.
+ * Regression test for TIKA-4734: the flag used to be misrouted to async
+ * mode (the input arg ended in ".json"), failing with a
TikaConfigException
+ * unless a --config was also passed. It must now run standalone and write
+ * the converted JSON to stdout.
+ */
+ @Test
+ public void testConvertConfigXmlToJson() throws Exception {
+ String xmlPath =
Paths.get(getClass().getResource("/xml-configs/tika-config-simple.xml").toURI()).toString();
+ String content = getParamOutContent("--convert-config-xml-to-json=" +
xmlPath);
+
+ // stdout should contain the converted JSON (and only the JSON)
+ assertTrue(content.contains("\"parsers\""), "Expected JSON parsers
section, got: " + content);
+ assertTrue(content.contains("pdf-parser"), "Expected pdf-parser in
output, got: " + content);
+ assertTrue(content.contains("\"sortByPosition\" : true"), "Expected
converted param, got: " + content);
+ assertTrue(content.trim().startsWith("{"), "Output should be pure
JSON, got: " + content);
Review Comment:
Agreed — rewrote the assertions to parse with `ObjectMapper` and check
structure rather than pretty-printed substrings: parsers must be a non-empty
array; the array must contain an entry with a `pdf-parser` key; that entry's
`sortByPosition` (resolved via `findValue`) must be `true`. No
formatter-spacing dependency.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]