Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features/src/main/feature/camel-features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3472,6 +3472,10 @@ Chain 2:
<bundle dependency='true'>mvn:org.apache.tika/tika-parser-html-module/${tika-version}</bundle>
<bundle dependency='true'>mvn:org.apache.tika/tika-parser-text-module/${tika-version}</bundle>
<bundle dependency='true'>mvn:commons-io/commons-io/${commons-io-version}</bundle>
<bundle dependency='true'>mvn:org.jsoup/jsoup/${jsoup-version}</bundle>
<bundle dependency='true'>mvn:commons-codec/commons-codec/${commons-codec-version}</bundle>
<bundle dependency='true'>mvn:org.apache.commons/commons-csv/${commons-csv-version}</bundle>
<bundle dependency='true'>wrap:mvn:com.github.albfernandez/juniversalchardet/${juniversalchardet-version}</bundle>
<bundle>mvn:org.apache.camel.karaf/camel-tika/${project.version}</bundle>
</feature>
<feature name='camel-torchserve' version='${project.version}' start-level='50'>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
<junit-jupiter-version>5.13.4</junit-jupiter-version>
<junit6-jupiter-version>6.0.1</junit6-jupiter-version>
<junit-pioneer-version>2.3.0</junit-pioneer-version>
<juniversalchardet-version>1.0.3</juniversalchardet-version>
<juniversalchardet-version>2.5.0</juniversalchardet-version>
<jxmpp-version>1.1.0</jxmpp-version>
<jython-version>2.7.4</jython-version>
<jzlib-version>1.1.3</jzlib-version>
Expand Down
48 changes: 48 additions & 0 deletions tests/features/camel-tika/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.karaf</groupId>
<artifactId>camel-karaf-features-test</artifactId>
<version>4.18.3-SNAPSHOT</version>
</parent>

<artifactId>camel-tika-test</artifactId>
<name>Apache Camel :: Karaf :: Tests :: Features :: Tika</name>

<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>../../../src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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<Exchange> 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();
}
}
1 change: 1 addition & 0 deletions tests/features/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<module>camel-quartz</module>
<module>camel-saxon</module>
<module>camel-spring-rabbitmq</module>
<module>camel-tika</module>
<module>camel-velocity</module>
<module>camel-weather</module>
<module>camel-xslt-saxon</module>
Expand Down
Loading