You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2025/02/19 10:09:08 UTC
(camel-spring-boot) branch main updated: CAMEL-21759: camel-test - Add @StubEndpoints to make it easy to test and replace out comp onents like kafka
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new 188a3945cf6 CAMEL-21759: camel-test - Add @StubEndpoints to make it easy to test and replace out comp onents like kafka
188a3945cf6 is described below
commit 188a3945cf6062dc90201ce3d3c16d274b12afb5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Feb 19 10:30:22 2025 +0100
CAMEL-21759: camel-test - Add @StubEndpoints to make it easy to test and replace out comp
onents like kafka
---
.../camel/spring/boot/stub/StubEndpointsTest.java | 64 ++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/stub/StubEndpointsTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/stub/StubEndpointsTest.java
new file mode 100644
index 00000000000..482587c1088
--- /dev/null
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/stub/StubEndpointsTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.camel.spring.boot.stub;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.FluentProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.SpringRouteBuilder;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.apache.camel.test.spring.junit5.StubEndpoints;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Configuration;
+
+@CamelSpringBootTest
+@StubEndpoints("kafka,amqp")
+@SpringBootApplication
+@SpringBootTest(classes = StubEndpointsTest.class)
+public class StubEndpointsTest {
+
+ @Autowired
+ FluentProducerTemplate producerTemplate;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Configuration
+ public static class Config extends SpringRouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").to("amqp:cheese");
+ from("amqp:cheese").to("mock:middle").transform(simple("Bye ${body}")).to("kafka:beer");
+ from("kafka:beer").to("mock:result");
+ }
+ }
+
+ @Test
+ public void shouldStubEndpoints() throws Exception {
+ camelContext.getEndpoint("mock:middle", MockEndpoint.class).expectedBodiesReceived("World");
+ camelContext.getEndpoint("mock:result", MockEndpoint.class).expectedBodiesReceived("Bye World");
+
+ producerTemplate.withBody("World").to("direct:start").send();
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ }
+
+}