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 12709e139 Ref#305 add camel core test (#306)
12709e139 is described below
commit 12709e1396e6d1289d49dac40040c3e5e4b19099
Author: François de Parscau <[email protected]>
AuthorDate: Thu May 30 19:25:26 2024 +0200
Ref#305 add camel core test (#306)
* Add camel-timer test
* Add camel-bean test
---
.../karaf/camel/test/CamelBeanRouteSupplier.java | 48 ++++++++++++++++++++++
.../karaf/camel/test/CamelTimerRouteSupplier.java | 45 ++++++++++++++++++++
.../apache/karaf/camel/itest/CamelCoreITest.java | 34 +++++++++++++++
3 files changed, 127 insertions(+)
diff --git
a/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelBeanRouteSupplier.java
b/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelBeanRouteSupplier.java
new file mode 100644
index 000000000..a12af1da6
--- /dev/null
+++
b/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelBeanRouteSupplier.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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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-bean-test",
+ immediate = true,
+ service = CamelRouteSupplier.class
+)
+public class CamelBeanRouteSupplier extends
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+ @Override
+ protected void configureProducer(RouteBuilder builder, RouteDefinition
producerRoute) {
+ configureConsumer(producerRoute.bean(BeanTest.class,
"setBody").log("body is now ${body}"));
+ }
+
+ @Override
+ protected boolean consumerEnabled() {
+ return false;
+ }
+
+ private static class BeanTest {
+ public static String setBody() {
+ return "OK";
+ }
+ }
+}
diff --git
a/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelTimerRouteSupplier.java
b/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelTimerRouteSupplier.java
new file mode 100644
index 000000000..cbe5c3843
--- /dev/null
+++
b/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelTimerRouteSupplier.java
@@ -0,0 +1,45 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 java.util.function.Function;
+
+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-timer-test",
+ immediate = true,
+ service = CamelRouteSupplier.class
+)
+public class CamelTimerRouteSupplier extends
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+ @Override
+ protected Function<RouteBuilder, RouteDefinition> consumerRoute() {
+ return builder ->
builder.from("timer://testTimer?repeatCount=1").log("timer next called")
+ .setBody(builder.constant("OK"));
+ }
+
+ @Override
+ protected boolean producerEnabled() {
+ return false;
+ }
+}
diff --git
a/tests/features/camel-core/src/test/java/org/apache/karaf/camel/itest/CamelCoreITest.java
b/tests/features/camel-core/src/test/java/org/apache/karaf/camel/itest/CamelCoreITest.java
index 5a2648ab5..1015dc335 100644
---
a/tests/features/camel-core/src/test/java/org/apache/karaf/camel/itest/CamelCoreITest.java
+++
b/tests/features/camel-core/src/test/java/org/apache/karaf/camel/itest/CamelCoreITest.java
@@ -51,6 +51,16 @@ public class CamelCoreITest extends
AbstractCamelRouteWithBundleITest {
new CamelSedaITest(this).testRoutes();
}
+ @Test
+ public void testCamelTimer() throws Exception {
+ new CamelTimerITest(this).testRoutes();
+ }
+
+ @Test
+ public void testCamelBean() throws Exception {
+ new CamelBeanITest(this).testRoutes();
+ }
+
public static class CamelFileITest extends
AbstractCamelSingleFeatureResultFileBasedRoute {
public CamelFileITest(CamelContextProvider provider, String baseDir) {
@@ -74,4 +84,28 @@ public class CamelCoreITest extends
AbstractCamelRouteWithBundleITest {
mock.expectedBodiesReceived("OK");
}
}
+
+ public static class CamelTimerITest extends
AbstractCamelSingleFeatureResultMockBasedRoute {
+
+ public CamelTimerITest(CamelContextProvider provider) {
+ super(provider);
+ }
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("OK");
+ }
+ }
+
+ public static class CamelBeanITest extends
AbstractCamelSingleFeatureResultMockBasedRoute {
+
+ public CamelBeanITest(CamelContextProvider provider) {
+ super(provider);
+ }
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("OK");
+ }
+ }
}
\ No newline at end of file