diff --git a/features/src/main/feature/camel-features.xml b/features/src/main/feature/camel-features.xml index e3389ec6e..dddf5bdb4 100644 --- a/features/src/main/feature/camel-features.xml +++ b/features/src/main/feature/camel-features.xml @@ -3473,6 +3473,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 d0e8b8d8c..d736beb4f 100644 --- a/pom.xml +++ b/pom.xml @@ -373,7 +373,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..806179cd8 --- /dev/null +++ b/tests/features/camel-tika/src/main/java/org/apache/karaf/camel/test/CamelTikaRouteSupplier.java @@ -0,0 +1,48 @@ +/* + * 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) { + // 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) + .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..5d0df9833 --- /dev/null +++ b/tests/features/camel-tika/src/test/java/org/apache/karaf/camel/itest/CamelTikaITest.java @@ -0,0 +1,57 @@ +/* + * 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 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; + +/** + * 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 { + + 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) { + // The feature resolves and the route processes exactly one exchange without error. + mock.expectedMessageCount(1); + } + + @Test + public void testResultMock() throws Exception { + assertMockEndpointsSatisfied(); + } +} diff --git a/tests/features/pom.xml b/tests/features/pom.xml index eb6100515..a931eb2ea 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