This is an automated email from the ASF dual-hosted git repository.
tballison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new e4adb6a2a3 TIKA-4985: Docs examples: symlink jina-ocr-basic.json;
tolerate symlink-less checkouts (#3393)
e4adb6a2a3 is described below
commit e4adb6a2a3c49b84044926cd289d300f382c0b17
Author: Tim Allison <[email protected]>
AuthorDate: Thu Oct 22 08:43:12 2026 -0400
TIKA-4985: Docs examples: symlink jina-ocr-basic.json; tolerate
symlink-less checkouts (#3393)
---
docs/modules/ROOT/examples/jina-ocr-basic.json | 17 +--------------
.../tika/parser/vlm/VLMConfigExamplesTest.java | 21 ++-----------------
.../tika/pipes/core/DocsExampleConfigsTest.java | 24 ++++++++++++++++++++--
3 files changed, 25 insertions(+), 37 deletions(-)
diff --git a/docs/modules/ROOT/examples/jina-ocr-basic.json
b/docs/modules/ROOT/examples/jina-ocr-basic.json
deleted file mode 100644
index bffd967321..0000000000
--- a/docs/modules/ROOT/examples/jina-ocr-basic.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "engines": {
- "vlm": {
- "openai-vlm-parser": {
- "baseUrl": "https://api.jina.ai",
- "model": "jina-ocr-v1",
- "apiKey": "${env:JINA_API_KEY}"
- }
- }
- },
- "text-recognizers": [
- {
- "engine": "vlm"
- }
- ]
-}
diff --git a/docs/modules/ROOT/examples/jina-ocr-basic.json
b/docs/modules/ROOT/examples/jina-ocr-basic.json
new file mode 120000
index 0000000000..dd092b4e23
--- /dev/null
+++ b/docs/modules/ROOT/examples/jina-ocr-basic.json
@@ -0,0 +1 @@
+../../../../tika-parsers/tika-parsers-ml/tika-vlm/src/test/resources/config-examples/jina-ocr-basic.json
\ No newline at end of file
diff --git
a/tika-parsers/tika-parsers-ml/tika-vlm/src/test/java/org/apache/tika/parser/vlm/VLMConfigExamplesTest.java
b/tika-parsers/tika-parsers-ml/tika-vlm/src/test/java/org/apache/tika/parser/vlm/VLMConfigExamplesTest.java
index 6e1d27b92d..ae30b97602 100644
---
a/tika-parsers/tika-parsers-ml/tika-vlm/src/test/java/org/apache/tika/parser/vlm/VLMConfigExamplesTest.java
+++
b/tika-parsers/tika-parsers-ml/tika-vlm/src/test/java/org/apache/tika/parser/vlm/VLMConfigExamplesTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.tika.parser.vlm;
-import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
@@ -24,8 +23,6 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -39,9 +36,8 @@ import org.apache.tika.parser.Parser;
* in the docs.
*
* <p>The JSON files under {@code src/test/resources/config-examples/} are
- * copies of those in {@code docs/modules/ROOT/examples/}, kept identical by
- * {@link #testExamplesMatchTheDocs()}, so any change that keeps these tests
- * passing also keeps the published docs correct.
+ * symlinked from {@code docs/modules/ROOT/examples/}, so any change that
+ * keeps these tests passing also keeps the published docs correct.
*
* <p>The tests only validate that the JSON deserializes and the parser
* constructs — no HTTP call is made to any model endpoint, so they're safe
@@ -117,17 +113,4 @@ public class VLMConfigExamplesTest {
public void testJinaOCRBasic() throws Exception {
loadAndValidate("jina-ocr-basic.json");
}
-
- @Test
- public void testExamplesMatchTheDocs() throws Exception {
- Path docs = Paths.get("../../../docs/modules/ROOT/examples");
- assumeTrue(Files.isDirectory(docs), "docs not checked out");
- try (Stream<Path> examples =
Files.list(Paths.get("src/test/resources/config-examples"))) {
- for (Path example : (Iterable<Path>) examples::iterator) {
- Path doc = docs.resolve(example.getFileName());
- assertEquals(Files.readString(doc), Files.readString(example),
- example.getFileName() + " differs from its docs copy");
- }
- }
- }
}
diff --git
a/tika-pipes/tika-pipes-integration-tests/src/test/java/org/apache/tika/pipes/core/DocsExampleConfigsTest.java
b/tika-pipes/tika-pipes-integration-tests/src/test/java/org/apache/tika/pipes/core/DocsExampleConfigsTest.java
index fd9cf0804d..8718be48d3 100644
---
a/tika-pipes/tika-pipes-integration-tests/src/test/java/org/apache/tika/pipes/core/DocsExampleConfigsTest.java
+++
b/tika-pipes/tika-pipes-integration-tests/src/test/java/org/apache/tika/pipes/core/DocsExampleConfigsTest.java
@@ -17,6 +17,7 @@
package org.apache.tika.pipes.core;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -30,8 +31,8 @@ import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
/**
- * Doc examples are symlinks to test configs; a test-only component in one
fails at startup for
- * users who copy it (TIKA-4984).
+ * Doc examples are symlinks to test configs, so they cannot drift from what
is tested; a test-only
+ * component in one fails at startup for users who copy it (TIKA-4984).
*/
public class DocsExampleConfigsTest {
@@ -53,6 +54,25 @@ public class DocsExampleConfigsTest {
assertTrue(offenders.isEmpty(), "test-only components in doc examples:
" + offenders);
}
+ @Test
+ public void testDocExamplesAreLiveSymlinks() throws Exception {
+ List<Path> examples;
+ try (Stream<Path> files = Files.list(findExamplesDir())) {
+ examples = files.toList();
+ }
+ assumeTrue(examples.stream().anyMatch(Files::isSymbolicLink),
+ "symlinks checked out as plain files (core.symlinks=false)");
+ List<String> offenders = new ArrayList<>();
+ for (Path p : examples) {
+ if (!Files.isSymbolicLink(p)) {
+ offenders.add(p.getFileName() + ": not a symlink");
+ } else if (!Files.isRegularFile(p)) {
+ offenders.add(p.getFileName() + ": dangling");
+ }
+ }
+ assertTrue(offenders.isEmpty(), "doc examples must be symlinks into
the source tree: " + offenders);
+ }
+
private static Path findExamplesDir() {
Path dir = Path.of("").toAbsolutePath();
for (int i = 0; i < 6 && dir != null; i++, dir = dir.getParent()) {