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 3e576aac Ref #352: Add camel-saxon integration test (#353)
3e576aac is described below
commit 3e576aac60819b3b38a60368437d001096893c46
Author: François de Parscau <[email protected]>
AuthorDate: Sat Jun 15 18:50:53 2024 +0200
Ref #352: Add camel-saxon integration test (#353)
---
tests/features/camel-saxon/pom.xml | 33 ++++++++++++++
.../karaf/camel/test/CamelSaxonRouteSupplier.java | 53 ++++++++++++++++++++++
.../camel-saxon/src/main/resources/myTransform.xq | 20 ++++++++
.../apache/karaf/camel/itest/CamelSaxonITest.java | 41 +++++++++++++++++
tests/features/pom.xml | 1 +
5 files changed, 148 insertions(+)
diff --git a/tests/features/camel-saxon/pom.xml
b/tests/features/camel-saxon/pom.xml
new file mode 100644
index 00000000..4e113ccc
--- /dev/null
+++ b/tests/features/camel-saxon/pom.xml
@@ -0,0 +1,33 @@
+<?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-saxon-test</artifactId>
+ <name>Apache Camel :: Karaf :: Tests :: Features :: Saxon</name>
+
+</project>
\ No newline at end of file
diff --git
a/tests/features/camel-saxon/src/main/java/org/apache/karaf/camel/test/CamelSaxonRouteSupplier.java
b/tests/features/camel-saxon/src/main/java/org/apache/karaf/camel/test/CamelSaxonRouteSupplier.java
new file mode 100644
index 00000000..d0b39ba5
--- /dev/null
+++
b/tests/features/camel-saxon/src/main/java/org/apache/karaf/camel/test/CamelSaxonRouteSupplier.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.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-saxon-test",
+ immediate = true,
+ service = CamelRouteSupplier.class
+)
+public class CamelSaxonRouteSupplier extends
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+
+ @Override
+ protected boolean consumerEnabled() {
+ return false;
+ }
+
+ @Override
+ protected void configureProducer(RouteBuilder builder, RouteDefinition
producerRoute) {
+ producerRoute.log("calling xquery endpoint")
+
.setBody(builder.constant("<person><city>London</city></person>"))
+ .filter().xquery("/person/city = 'London'")
+ .setBody(builder.constant("""
+ <person user="james">
+ <firstName>James</firstName>
+ <lastName>Strachan</lastName>
+ <city>London</city>
+ </person>"""))
+
.to("xquery:file://%s/classes/myTransform.xq".formatted(System.getProperty("project.target")))
+ .log("${body}")
+ .toF("mock:%s", getResultMockName());
+ }
+}
+
diff --git a/tests/features/camel-saxon/src/main/resources/myTransform.xq
b/tests/features/camel-saxon/src/main/resources/myTransform.xq
new file mode 100644
index 00000000..c9f0c100
--- /dev/null
+++ b/tests/features/camel-saxon/src/main/resources/myTransform.xq
@@ -0,0 +1,20 @@
+(:
+ 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.
+:)
+<employee id="{person/@user}">
+ <name>{/person/firstName/text()} {/person/lastName/text()}</name>
+ <location>{/person/city/text()}</location>
+</employee>
diff --git
a/tests/features/camel-saxon/src/test/java/org/apache/karaf/camel/itest/CamelSaxonITest.java
b/tests/features/camel-saxon/src/test/java/org/apache/karaf/camel/itest/CamelSaxonITest.java
new file mode 100644
index 00000000..c799cfd0
--- /dev/null
+++
b/tests/features/camel-saxon/src/test/java/org/apache/karaf/camel/itest/CamelSaxonITest.java
@@ -0,0 +1,41 @@
+/*
+ * 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 CamelSaxonITest extends
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("<employee id=\"james\"><name>James
Strachan</name><location>London</location></employee>");
+ }
+
+ @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 09d02d94..03c6a5f0 100644
--- a/tests/features/pom.xml
+++ b/tests/features/pom.xml
@@ -53,6 +53,7 @@
<module>camel-mail</module>
<module>camel-olingo2</module>
<module>camel-quartz</module>
+ <module>camel-saxon</module>
<module>camel-spring-rabbitmq</module>
<module>camel-weather</module>
<module>camel-xslt-saxon</module>