From 72d73771bfa2969a694530d0df12124b9edbbae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JB=20Onofr=C3=A9?= Date: Tue, 28 Jul 2026 16:53:13 +0200 Subject: [PATCH 1/3] fix(#713): add missing transitive dependencies to camel-tika feature The camel-tika feature was missing the transitive runtime dependencies of tika-parser-html-module (jsoup, commons-codec) and tika-parser-text-module (commons-csv, juniversalchardet). Without them, tika operations such as tika:detect/tika:parse fail at runtime with NoClassDefFoundError (e.g. org.apache.tika.parser.txt.UniversalEncodingListener needs org.mozilla.universalchardet.*). jsoup, commons-codec and commons-csv are already proper OSGi bundles and are added as plain mvn: bundles. com.github.albfernandez:juniversalchardet 2.5.0 ships without OSGi metadata, so it is installed via wrap:. The stale, unused juniversalchardet-version property (1.0.3, the old com.googlecode groupId) is bumped to 2.5.0 to match the version Tika 3.2.3 pulls in. Adds a Pax Exam integration test (tests/features/camel-tika) that parses a plain-text body through tika:parse, exercising the text parser and its juniversalchardet dependency at runtime. --- features/src/main/feature/camel-features.xml | 4 ++ pom.xml | 2 +- tests/features/camel-tika/pom.xml | 48 ++++++++++++++ .../camel/test/CamelTikaRouteSupplier.java | 47 ++++++++++++++ .../karaf/camel/itest/CamelTikaITest.java | 62 +++++++++++++++++++ tests/features/pom.xml | 1 + 6 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 tests/features/camel-tika/pom.xml create mode 100644 tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java create mode 100644 tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java diff --git a/features/src/main/feature/camel-features.xml b/features/src/main/feature/camel-features.xml index 4796fedf5..74a15bb07 100644 --- a/features/src/main/feature/camel-features.xml +++ b/features/src/main/feature/camel-features.xml @@ -3472,6 +3472,10 @@ Chain 2: mvn:org.apache.tika/tika-parser-html-module/${tika-version} mvn:org.apache.tika/tika-parser-text-module/${tika-version} mvn:commons-io/commons-io/${commons-io-version} + mvn:org.jsoup/jsoup/${jsoup-version} + mvn:commons-codec/commons-codec/${commons-codec-version} + mvn:org.apache.commons/commons-csv/${commons-csv-version} + wrap:mvn:com.github.albfernandez/juniversalchardet/${juniversalchardet-version} mvn:org.apache.camel.karaf/camel-tika/${project.version} diff --git a/pom.xml b/pom.xml index d608d2404..a64ecbc78 100644 --- a/pom.xml +++ b/pom.xml @@ -374,7 +374,7 @@ 5.13.4 6.0.1 2.3.0 - 1.0.3 + 2.5.0 1.1.0 2.7.4 1.1.3 diff --git a/tests/features/camel-tika/pom.xml b/tests/features/camel-tika/pom.xml new file mode 100644 index 000000000..c824193b4 --- /dev/null +++ b/tests/features/camel-tika/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + org.apache.camel.karaf + camel-karaf-features-test + 4.18.2-SNAPSHOT + + + camel-tika-test + Apache Camel :: Karaf :: Tests :: Features :: Tika + + + + org.apache.camel + camel-core + ${camel-version} + provided + + + + + + + ../../../src/main/resources + false + + + + diff --git a/tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java b/tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java new file mode 100644 index 000000000..b311c5ce2 --- /dev/null +++ b/tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java @@ -0,0 +1,47 @@ +/* + * 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.karaf.camel.test; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.RouteDefinition; +import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier; +import org.apache.karaf.camel.itests.CamelRouteSupplier; +import org.osgi.service.component.annotations.Component; + +@Component( + name = "karaf-camel-tika-test", + immediate = true, + service = CamelRouteSupplier.class +) +public class CamelTikaRouteSupplier extends AbstractCamelSingleFeatureResultMockBasedRouteSupplier { + + @Override + protected boolean consumerEnabled() { + return false; + } + + @Override + protected void configureProducer(RouteBuilder builder, RouteDefinition producerRoute) { + // Parse the plain-text body as text. This exercises the tika-parser-text-module and + // its transitive juniversalchardet dependency (charset detection), which are the + // bundles that were missing from the camel-tika feature (issue #713). + producerRoute.log("Will parse: ${body}") + .to("tika:parse?tikaParseOutputFormat=text") + .convertBodyTo(String.class) + .log("Parsed: ${body}") + .toF("mock:%s", getResultMockName()); + } +} diff --git a/tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java b/tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java new file mode 100644 index 000000000..112ab39b3 --- /dev/null +++ b/tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java @@ -0,0 +1,62 @@ +/* + * Licensed 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.karaf.camel.itest; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.apache.camel.Exchange; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) +public class CamelTikaITest extends AbstractCamelSingleFeatureResultMockBasedRouteITest { + + private static final String TEXT_SAMPLE = "The quick brown fox jumps over the lazy dog"; + + @Override + public String getBodyToSend() { + return TEXT_SAMPLE; + } + + @Override + public void configureMock(MockEndpoint mock) { + mock.expectedMessageCount(1); + } + + @Test + public void testResultMock() throws Exception { + MockEndpoint endpoint = getMockEndpoint(); + List exchanges = endpoint.getExchanges(); + assertNotNull(exchanges); + + String parsed = exchanges.get(0).getIn().getBody(String.class); + assertNotNull(parsed); + // The text parser (backed by juniversalchardet for charset detection) must extract + // the original text content. Without the missing feature bundles this route would + // fail to resolve/parse at all. + assertTrue("Parsed content should contain the original text but was: " + parsed, + parsed.contains("quick brown fox")); + + assertMockEndpointsSatisfied(); + } +} diff --git a/tests/features/pom.xml b/tests/features/pom.xml index 03bce3137..9edef3078 100644 --- a/tests/features/pom.xml +++ b/tests/features/pom.xml @@ -110,6 +110,7 @@ camel-quartz camel-saxon camel-spring-rabbitmq + camel-tika camel-velocity camel-weather camel-xslt-saxon From 06e10aab08942848bef6f8af7874f85e785a5f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JB=20Onofr=C3=A9?= Date: Mon, 3 Aug 2026 05:36:54 +0200 Subject: [PATCH 2/3] fix(#713): correct parent version to 4.18.3-SNAPSHOT in camel-tika test module The backported camel-tika test module referenced its parent camel-karaf-features-test as 4.18.2-SNAPSHOT, but the branch is on the 4.18.3-SNAPSHOT development iteration, causing a non-resolvable parent POM error that failed the CI build. --- tests/features/camel-tika/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/features/camel-tika/pom.xml b/tests/features/camel-tika/pom.xml index c824193b4..69a7a7443 100644 --- a/tests/features/camel-tika/pom.xml +++ b/tests/features/camel-tika/pom.xml @@ -22,7 +22,7 @@ org.apache.camel.karaf camel-karaf-features-test - 4.18.2-SNAPSHOT + 4.18.3-SNAPSHOT camel-tika-test From be2569e76b7d359c5224f9290252da47f7be33b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JB=20Onofr=C3=A9?= Date: Fri, 28 Aug 2026 14:25:12 +0200 Subject: [PATCH 3/3] test(#713): scope camel-tika itest to feature resolution Align the backported itest with the version merged to main in #716. The test asserted that tika:parse extracts text, but in Karaf tika:parse returns empty content: Tika's AutoDetectParser discovers parsers through the JDK ServiceLoader, which does not cross OSGi bundle boundaries. Wiring Tika's parser SPI for OSGi is out of scope for issue #713, whose fix is the missing juniversalchardet bundle so tika-parser-text-module resolves. Scope the test to what #713 fixes: the feature installs and the tika:parse route processes one exchange end-to-end (expectedMessageCount(1)). Before the fix the tika-parser-text-module bundle could not wire (missing org.mozilla.universalchardet), so the route never started and no message reached the mock. --- .../camel/test/CamelTikaRouteSupplier.java | 7 +++-- .../karaf/camel/itest/CamelTikaITest.java | 31 ++++++++----------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java b/tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java index b311c5ce2..806179cd8 100644 --- a/tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java +++ b/tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java @@ -35,9 +35,10 @@ protected boolean consumerEnabled() { @Override protected void configureProducer(RouteBuilder builder, RouteDefinition producerRoute) { - // Parse the plain-text body as text. This exercises the tika-parser-text-module and - // its transitive juniversalchardet dependency (charset detection), which are the - // bundles that were missing from the camel-tika feature (issue #713). + // Route the body through tika:parse. The value of this route is that it forces the + // camel-tika feature (including tika-parser-text-module and its juniversalchardet + // dependency, which were missing before issue #713) to resolve and run; a message + // reaching the mock proves the feature is now wired correctly. producerRoute.log("Will parse: ${body}") .to("tika:parse?tikaParseOutputFormat=text") .convertBodyTo(String.class) diff --git a/tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java b/tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java index 112ab39b3..5d0df9833 100644 --- a/tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java +++ b/tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java @@ -13,12 +13,6 @@ */ package org.apache.karaf.camel.itest; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.apache.camel.Exchange; import org.apache.camel.component.mock.MockEndpoint; import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest; import org.junit.Test; @@ -27,6 +21,18 @@ import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; +/** + * Verifies the {@code camel-tika} feature installs and a {@code tika:parse} route runs end-to-end + * (issue #713). The point of the test is that the feature now resolves: before the fix the + * {@code tika-parser-text-module} bundle failed to wire because its {@code juniversalchardet} + * dependency (package {@code org.mozilla.universalchardet}) was missing from the feature, so the + * route could never be created and no message would reach the mock. + *

+ * The test deliberately does not assert on the extracted text: Tika's {@code AutoDetectParser} + * discovers parsers through the JDK {@link java.util.ServiceLoader}, which does not cross OSGi + * bundle boundaries, so {@code tika:parse} yields empty content in Karaf. Wiring Tika's parser SPI + * for OSGi is a separate concern beyond the scope of issue #713. + */ @RunWith(PaxExam.class) @ExamReactorStrategy(PerClass.class) public class CamelTikaITest extends AbstractCamelSingleFeatureResultMockBasedRouteITest { @@ -40,23 +46,12 @@ public String getBodyToSend() { @Override public void configureMock(MockEndpoint mock) { + // The feature resolves and the route processes exactly one exchange without error. mock.expectedMessageCount(1); } @Test public void testResultMock() throws Exception { - MockEndpoint endpoint = getMockEndpoint(); - List exchanges = endpoint.getExchanges(); - assertNotNull(exchanges); - - String parsed = exchanges.get(0).getIn().getBody(String.class); - assertNotNull(parsed); - // The text parser (backed by juniversalchardet for charset detection) must extract - // the original text content. Without the missing feature bundles this route would - // fail to resolve/parse at all. - assertTrue("Parsed content should contain the original text but was: " + parsed, - parsed.contains("quick brown fox")); - assertMockEndpointsSatisfied(); } }