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 eb362013 camel-velocity integration test (#356)
eb362013 is described below
commit eb3620131f3dab381ec94b014ad7dceb5da538ca
Author: ÖZGÜR KISIR <[email protected]>
AuthorDate: Fri Jun 21 14:54:06 2024 +0300
camel-velocity integration test (#356)
---
tests/features/camel-velocity/pom.xml | 33 ++++++++++++++
.../camel/test/CamelVelocityRouteSupplier.java | 51 ++++++++++++++++++++++
.../camel-velocity/src/main/resources/greeting.vm | 1 +
.../karaf/camel/itest/CamelVelocityITest.java | 42 ++++++++++++++++++
tests/features/pom.xml | 1 +
5 files changed, 128 insertions(+)
diff --git a/tests/features/camel-velocity/pom.xml
b/tests/features/camel-velocity/pom.xml
new file mode 100644
index 00000000..9abb5f0f
--- /dev/null
+++ b/tests/features/camel-velocity/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-velocity-test</artifactId>
+ <name>Apache Camel :: Karaf :: Tests :: Features :: Velocity</name>
+
+</project>
\ No newline at end of file
diff --git
a/tests/features/camel-velocity/src/main/java/org/apache/karaf/camel/test/CamelVelocityRouteSupplier.java
b/tests/features/camel-velocity/src/main/java/org/apache/karaf/camel/test/CamelVelocityRouteSupplier.java
new file mode 100644
index 00000000..30ad987a
--- /dev/null
+++
b/tests/features/camel-velocity/src/main/java/org/apache/karaf/camel/test/CamelVelocityRouteSupplier.java
@@ -0,0 +1,51 @@
+
+/*
+ * 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;
+
+import static org.apache.camel.builder.Builder.constant;
+
+@Component(
+ name = "karaf-camel-saxon-test",
+ immediate = true,
+ service = CamelRouteSupplier.class
+)
+public class CamelVelocityRouteSupplier extends
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+
+ @Override
+ protected boolean consumerEnabled() {
+ return false;
+ }
+
+ @Override
+ protected void configureProducer(RouteBuilder builder, RouteDefinition
producerRoute) {
+ producerRoute.log("calling velocity endpoint")
+ .setHeader("greeting", constant("Hello"))
+ .setBody(builder.constant("World"))
+ .toF("velocity:file://%s/classes/greeting.vm",
System.getProperty("project.target"))
+ .log("${body}")
+ .toF("mock:%s", getResultMockName());
+
+ }
+}
+
diff --git a/tests/features/camel-velocity/src/main/resources/greeting.vm
b/tests/features/camel-velocity/src/main/resources/greeting.vm
new file mode 100644
index 00000000..d8a8ba60
--- /dev/null
+++ b/tests/features/camel-velocity/src/main/resources/greeting.vm
@@ -0,0 +1 @@
+${headers.greeting}, ${body}!
diff --git
a/tests/features/camel-velocity/src/test/test/org/apache/karaf/camel/itest/CamelVelocityITest.java
b/tests/features/camel-velocity/src/test/test/org/apache/karaf/camel/itest/CamelVelocityITest.java
new file mode 100644
index 00000000..5857a491
--- /dev/null
+++
b/tests/features/camel-velocity/src/test/test/org/apache/karaf/camel/itest/CamelVelocityITest.java
@@ -0,0 +1,42 @@
+/*
+ * 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(isBlueprintTest = true)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelVelocityITest extends
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("Hello, World!");
+ }
+
+ @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 317ff48b..1e15e9e6 100644
--- a/tests/features/pom.xml
+++ b/tests/features/pom.xml
@@ -63,6 +63,7 @@
<module>camel-quartz</module>
<module>camel-saxon</module>
<module>camel-spring-rabbitmq</module>
+ <module>camel-velocity</module>
<module>camel-weather</module>
<module>camel-xslt-saxon</module>
</modules>