This is an automated email from the ASF dual-hosted git repository.
tballison pushed a commit to branch docs/4.0.x
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/docs/4.0.x by this push:
new a8f4475ac1 TIKA-4984 fix for 4.0.x (#3389)
a8f4475ac1 is described below
commit a8f4475ac11ca1f4e72aebb8896318413377d79a
Author: Tim Allison <[email protected]>
AuthorDate: Wed Oct 21 19:46:27 2026 -0400
TIKA-4984 fix for 4.0.x (#3389)
---
.../tika/pipes/core/DocsExampleConfigsTest.java | 67 ++++++++++++++++++++++
.../test/resources/configs/tika-config-basic.json | 4 +-
.../resources/configs/tika-config-passback.json | 4 +-
.../configs/tika-config-shared-server.json | 4 +-
.../resources/configs/tika-config-truncate.json | 4 +-
.../resources/configs/tika-config-uppercasing.json | 4 +-
6 files changed, 82 insertions(+), 5 deletions(-)
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
new file mode 100644
index 0000000000..fd9cf0804d
--- /dev/null
+++
b/tika-pipes/tika-pipes-integration-tests/src/test/java/org/apache/tika/pipes/core/DocsExampleConfigsTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.pipes.core;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+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).
+ */
+public class DocsExampleConfigsTest {
+
+ private static final String EXAMPLES_RELATIVE_PATH =
"docs/modules/ROOT/examples";
+
+ private static final Pattern MOCK_COMPONENT =
Pattern.compile("\"(mock-[a-z0-9-]+)\"\\s*:");
+
+ @Test
+ public void testNoMockComponentsInDocExamples() throws Exception {
+ List<String> offenders = new ArrayList<>();
+ try (Stream<Path> files = Files.list(findExamplesDir())) {
+ for (Path p : (Iterable<Path>) files.filter(f ->
f.toString().endsWith(".json"))::iterator) {
+ Matcher m = MOCK_COMPONENT.matcher(Files.readString(p,
StandardCharsets.UTF_8));
+ while (m.find()) {
+ offenders.add(p.getFileName() + ": " + m.group(1));
+ }
+ }
+ }
+ assertTrue(offenders.isEmpty(), "test-only components in doc examples:
" + offenders);
+ }
+
+ private static Path findExamplesDir() {
+ Path dir = Path.of("").toAbsolutePath();
+ for (int i = 0; i < 6 && dir != null; i++, dir = dir.getParent()) {
+ Path candidate = dir.resolve(EXAMPLES_RELATIVE_PATH);
+ if (Files.isDirectory(candidate)) {
+ return candidate;
+ }
+ }
+ throw new IllegalStateException(
+ "could not locate " + EXAMPLES_RELATIVE_PATH + " above " +
Path.of("").toAbsolutePath());
+ }
+}
diff --git
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-basic.json
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-basic.json
index 4696e1d0f6..900f1b883c 100644
---
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-basic.json
+++
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-basic.json
@@ -46,7 +46,9 @@
"throwOnZeroBytes": false
},
"parse-context": {
- "mock-digester-factory": {},
+ "commons-digester-factory": {
+ "digests": [{ "algorithm": "SHA256" }]
+ },
"timeout-limits": {
"progressTimeoutMillis": 5000
}
diff --git
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-passback.json
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-passback.json
index 3857d65e30..d752c0fa80 100644
---
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-passback.json
+++
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-passback.json
@@ -45,7 +45,9 @@
"throwOnZeroBytes": false
},
"parse-context": {
- "mock-digester-factory": {},
+ "commons-digester-factory": {
+ "digests": [{ "algorithm": "SHA256" }]
+ },
"timeout-limits": {
"progressTimeoutMillis": 5000
}
diff --git
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-shared-server.json
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-shared-server.json
index 320133e6c9..211ee58f23 100644
---
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-shared-server.json
+++
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-shared-server.json
@@ -47,7 +47,9 @@
"throwOnZeroBytes": false
},
"parse-context": {
- "mock-digester-factory": {},
+ "commons-digester-factory": {
+ "digests": [{ "algorithm": "SHA256" }]
+ },
"timeout-limits": {
"progressTimeoutMillis": 5000
}
diff --git
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-truncate.json
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-truncate.json
index 9bc7efa5e8..c98a1bdae8 100644
---
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-truncate.json
+++
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-truncate.json
@@ -46,7 +46,9 @@
"throwOnZeroBytes": false
},
"parse-context": {
- "mock-digester-factory": {},
+ "commons-digester-factory": {
+ "digests": [{ "algorithm": "SHA256" }]
+ },
"sax-output-config": {
"writeFileNameToContent": false
},
diff --git
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-uppercasing.json
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-uppercasing.json
index 7732becfc8..c8005ae25b 100644
---
a/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-uppercasing.json
+++
b/tika-pipes/tika-pipes-integration-tests/src/test/resources/configs/tika-config-uppercasing.json
@@ -42,7 +42,9 @@
"throwOnZeroBytes": false
},
"parse-context": {
- "mock-digester-factory": {},
+ "commons-digester-factory": {
+ "digests": [{ "algorithm": "SHA256" }]
+ },
"timeout-limits": {
"progressTimeoutMillis": 5000
}