You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2025/01/21 15:03:59 UTC

(camel-karaf) branch essobedo/579/handover-completions-4.9 created (now da755898e)

This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a change to branch essobedo/579/handover-completions-4.9
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git


      at da755898e Ref #579: camel-vm - Handover completions

This branch includes the following new commits:

     new da755898e Ref #579: camel-vm - Handover completions

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel-karaf) 01/01: Ref #579: camel-vm - Handover completions

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch essobedo/579/handover-completions-4.9
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git

commit da755898e53c660c5e9b0c9bccad5d5124d1a17b
Author: Nicolas Filotto <ni...@qlik.com>
AuthorDate: Tue Jan 21 12:31:17 2025 +0100

    Ref #579: camel-vm - Handover completions
---
 components/camel-vm/pom.xml                        | 19 ++++++++
 .../camel/karaf/component/vm/VmConsumer.java       |  1 +
 .../karaf/component/vm/VmComplexInOutTest.java     | 56 ++++++++++++++++++++++
 .../camel-vm/src/test/resources/log4j2.properties  | 28 +++++++++++
 4 files changed, 104 insertions(+)

diff --git a/components/camel-vm/pom.xml b/components/camel-vm/pom.xml
index d66c69df5..1875d35b8 100644
--- a/components/camel-vm/pom.xml
+++ b/components/camel-vm/pom.xml
@@ -47,6 +47,25 @@
             <artifactId>camel-seda</artifactId>
             <version>${camel-version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-junit5</artifactId>
+            <version>${camel-version}</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- logging for testing -->
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-slf4j2-impl</artifactId>
+            <version>${log4j2-version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>${log4j2-version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/components/camel-vm/src/main/java/org/apache/camel/karaf/component/vm/VmConsumer.java b/components/camel-vm/src/main/java/org/apache/camel/karaf/component/vm/VmConsumer.java
index 1e1d5faf1..0c49d8f25 100644
--- a/components/camel-vm/src/main/java/org/apache/camel/karaf/component/vm/VmConsumer.java
+++ b/components/camel-vm/src/main/java/org/apache/camel/karaf/component/vm/VmConsumer.java
@@ -45,6 +45,7 @@ public class VmConsumer extends SedaConsumer implements CamelContextAware {
     @Override
     protected Exchange prepareExchange(Exchange exchange) {
         Exchange result = ExchangeHelper.copyExchangeWithProperties(exchange, camelContext);
+        exchange.getExchangeExtension().handoverCompletions(result);
         ExchangeExtension exchangeExtension = result.getExchangeExtension();
         exchangeExtension.setFromEndpoint(getEndpoint());
         exchangeExtension.setFromRouteId(getRouteId());
diff --git a/components/camel-vm/src/test/java/org/apache/camel/karaf/component/vm/VmComplexInOutTest.java b/components/camel-vm/src/test/java/org/apache/camel/karaf/component/vm/VmComplexInOutTest.java
new file mode 100644
index 000000000..5042ca5dc
--- /dev/null
+++ b/components/camel-vm/src/test/java/org/apache/camel/karaf/component/vm/VmComplexInOutTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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.camel.karaf.component.vm;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class VmComplexInOutTest extends CamelTestSupport {
+
+    @Test
+    void testInOut() throws Exception {
+        getMockEndpoint("mock:result-inner").expectedBodiesReceived("Bye World");
+        getMockEndpoint("mock:result").expectedBodiesReceived("OK");
+
+        String out = template.requestBody("direct:start", "Hello World", String.class);
+        assertEquals("OK", out);
+
+        MockEndpoint.assertIsSatisfied(context);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                getContext().setTracing(true);
+
+                from("direct:start").to("vm:a").setBody(constant("OK")).to("mock:result");
+
+                from("vm:a").to("log:bar", "vm:b");
+                from("vm:b").delay(10).to("direct:c");
+
+                from("direct:c").transform(constant("Bye World")).to("mock:result-inner");
+            }
+        };
+    }
+}
diff --git a/components/camel-vm/src/test/resources/log4j2.properties b/components/camel-vm/src/test/resources/log4j2.properties
new file mode 100644
index 000000000..259b872e4
--- /dev/null
+++ b/components/camel-vm/src/test/resources/log4j2.properties
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-vm-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file