This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git
The following commit(s) were added to refs/heads/main by this push:
new b39017c4 Ref #354: Add camel-xslt-saxon integration test (#355)
b39017c4 is described below
commit b39017c435f833340d4be0615d5ef85bd3cd80a7
Author: François de Parscau <[email protected]>
AuthorDate: Sat Jun 15 18:49:03 2024 +0200
Ref #354: Add camel-xslt-saxon integration test (#355)
---
features/src/main/feature/camel-features.xml | 1 +
tests/features/camel-xslt-saxon/pom.xml | 42 +++++++++++++++++
.../camel/test/CamelXsltSaxonRouteSupplier.java | 53 ++++++++++++++++++++++
.../src/main/resources/transform.xsl | 41 +++++++++++++++++
.../karaf/camel/itest/CamelXsltSaxonITest.java | 50 ++++++++++++++++++++
tests/features/pom.xml | 1 +
6 files changed, 188 insertions(+)
diff --git a/features/src/main/feature/camel-features.xml
b/features/src/main/feature/camel-features.xml
index 567ffeea..157cdbe8 100644
--- a/features/src/main/feature/camel-features.xml
+++ b/features/src/main/feature/camel-features.xml
@@ -2576,6 +2576,7 @@
<feature name='camel-xslt-saxon' version='${project.version}'
start-level='50'>
<feature version='${camel-osgi-version-range}'>camel-core</feature>
<bundle
dependency='true'>wrap:mvn:net.sf.saxon/Saxon-HE/${saxon-version}</bundle>
+ <bundle
dependency='true'>wrap:mvn:org.xmlresolver/xmlresolver/${auto-detect-version}</bundle>
<bundle>mvn:org.apache.camel.karaf/camel-xslt-saxon/${project.version}</bundle>
</feature>
<feature name='camel-yaml-dsl' version='${project.version}'
start-level='50'>
diff --git a/tests/features/camel-xslt-saxon/pom.xml
b/tests/features/camel-xslt-saxon/pom.xml
new file mode 100644
index 00000000..5dc23397
--- /dev/null
+++ b/tests/features/camel-xslt-saxon/pom.xml
@@ -0,0 +1,42 @@
+<?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.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-xslt-saxon-test</artifactId>
+ <name>Apache Camel :: Karaf :: Tests :: Features :: XSLT Saxon</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-xslt-saxon</artifactId>
+ <version>${camel-version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git
a/tests/features/camel-xslt-saxon/src/main/java/org/apache/karaf/camel/test/CamelXsltSaxonRouteSupplier.java
b/tests/features/camel-xslt-saxon/src/main/java/org/apache/karaf/camel/test/CamelXsltSaxonRouteSupplier.java
new file mode 100644
index 00000000..c6bb35ad
--- /dev/null
+++
b/tests/features/camel-xslt-saxon/src/main/java/org/apache/karaf/camel/test/CamelXsltSaxonRouteSupplier.java
@@ -0,0 +1,53 @@
+/*
+ * 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.CamelContext;
+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;
+
+import net.sf.saxon.TransformerFactoryImpl;
+
+@Component(
+ name = "karaf-camel-xslt-saxon-test",
+ immediate = true,
+ service = CamelRouteSupplier.class
+)
+public class CamelXsltSaxonRouteSupplier extends
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+ @Override
+ public void configure(CamelContext camelContext) {
+ camelContext.getRegistry().bind("factory",
TransformerFactoryImpl.newInstance());
+ }
+
+ @Override
+ protected boolean consumerEnabled() {
+ return false;
+ }
+
+ @Override
+ protected void configureProducer(RouteBuilder builder, RouteDefinition
producerRoute) {
+ configureConsumer(producerRoute.log("calling endpoint")
+
.setBody(builder.constant("<mail><subject>Hey</subject><body>Hello
world!</body></mail>"))
+
.to("xslt-saxon:file://%s/classes/transform.xsl?transformerFactory=#factory"
+ .formatted(System.getProperty("project.target")))
+ .log("${body}"));
+ }
+}
+
diff --git a/tests/features/camel-xslt-saxon/src/main/resources/transform.xsl
b/tests/features/camel-xslt-saxon/src/main/resources/transform.xsl
new file mode 100644
index 00000000..d2cef190
--- /dev/null
+++ b/tests/features/camel-xslt-saxon/src/main/resources/transform.xsl
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ 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.
+
+-->
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+ version='2.0'>
+
+ <xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>
+
+ <xsl:template match="/">
+ <transformed subject="{/mail/subject}">
+ <cheese>
+ <xsl:apply-templates select="*|@*"/>
+ </cheese>
+ </transformed>
+ </xsl:template>
+
+ <xsl:template match="*">
+ <xsl:copy>
+ <xsl:copy-of select="attribute::*"/>
+ <xsl:apply-templates/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git
a/tests/features/camel-xslt-saxon/src/test/java/org/apache/karaf/camel/itest/CamelXsltSaxonITest.java
b/tests/features/camel-xslt-saxon/src/test/java/org/apache/karaf/camel/itest/CamelXsltSaxonITest.java
new file mode 100644
index 00000000..b4a3872f
--- /dev/null
+++
b/tests/features/camel-xslt-saxon/src/test/java/org/apache/karaf/camel/itest/CamelXsltSaxonITest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.apache.karaf.camel.itests.CamelKarafTestHint;
+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;
+
+
+@CamelKarafTestHint
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelXsltSaxonITest extends
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("""
+<?xml version="1.0" encoding="ISO-8859-1"?><transformed subject="Hey">
+ <cheese>
+ <mail>
+ <subject>Hey</subject>
+ <body>Hello world!</body>
+ </mail>
+ </cheese>
+</transformed>
+""");
+ }
+
+ @Test
+ public void testResultMock() throws Exception {
+ assertMockEndpointsSatisfied();
+ }
+
+}
\ No newline at end of file
diff --git a/tests/features/pom.xml b/tests/features/pom.xml
index 01e4484b..09d02d94 100644
--- a/tests/features/pom.xml
+++ b/tests/features/pom.xml
@@ -55,6 +55,7 @@
<module>camel-quartz</module>
<module>camel-spring-rabbitmq</module>
<module>camel-weather</module>
+ <module>camel-xslt-saxon</module>
</modules>
<dependencyManagement>