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.git
The following commit(s) were added to refs/heads/main by this push:
new 41c94ef25b22 CAMEL-23652: Add tests for bean EIP ref with local
template beans (#23650)
41c94ef25b22 is described below
commit 41c94ef25b2248d81e51ddbb78ec156277aac5d9
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat May 30 15:31:09 2026 +0200
CAMEL-23652: Add tests for bean EIP ref with local template beans (#23650)
Co-authored-by: Claude <[email protected]>
---
.../apache/camel/dsl/yaml/KameletLoaderTest.groovy | 56 ++++++++++++++++++++++
.../org/apache/camel/dsl/yaml/KameletTest.groovy | 34 +++++++++++++
2 files changed, 90 insertions(+)
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletLoaderTest.groovy
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletLoaderTest.groovy
index b341c62d37f2..b9d4244af0bc 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletLoaderTest.groovy
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletLoaderTest.groovy
@@ -451,6 +451,62 @@ class KameletLoaderTest extends YamlTestSupport {
}
}
+ def "kamelet with local bean via bean ref"() {
+ setup:
+ loadKamelets '''
+ apiVersion: camel.apache.org/v1
+ kind: Kamelet
+ metadata:
+ name: counter-action
+ labels:
+ camel.apache.org/kamelet.type: action
+ spec:
+ definition:
+ title: "Counter Action"
+ properties:
+ start:
+ title: Start
+ description: The starting value for the counter
+ type: integer
+ default: 0
+ template:
+ beans:
+ - name: counter
+ type: java.util.concurrent.atomic.AtomicInteger
+ constructors:
+ "0": "{{start}}"
+ from:
+ uri: kamelet:source
+ steps:
+ - bean:
+ ref: "{{counter}}"
+ method: getAndIncrement
+ - to: "kamelet:sink"
+ '''
+
+ loadRoutes """
+ - from:
+ uri: "direct:start"
+ steps:
+ - kamelet:
+ name: "counter-action"
+ - to: "mock:result"
+ """
+
+ withMock('mock:result') {
+ expectedBodiesReceived '0'
+ }
+
+ when:
+ context.start()
+
+ withTemplate {
+ to('direct:start').withBody('hello').send()
+ }
+ then:
+ MockEndpoint.assertIsSatisfied(context)
+ }
+
def "kamelet with bean constructors"() {
when:
loadKamelets('''
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletTest.groovy
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletTest.groovy
index 971be12b5ede..b9ef38fcb29a 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletTest.groovy
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletTest.groovy
@@ -291,6 +291,40 @@ class KameletTest extends YamlTestSupport {
MockEndpoint.assertIsSatisfied(context)
}
+ def "kamelet (definition with local bean via bean ref)"() {
+ setup:
+ loadRoutes '''
+ - routeTemplate:
+ id: "myTemplate"
+ beans:
+ - name: "myCounter"
+ type: java.util.concurrent.atomic.AtomicInteger
+ from:
+ uri: "kamelet:source"
+ steps:
+ - bean:
+ ref: "{{myCounter}}"
+ method: "getAndIncrement"
+ - from:
+ uri: "direct:start"
+ steps:
+ - to: "kamelet:myTemplate"
+ - to: "mock:result"
+ '''
+
+ withMock('mock:result') {
+ expectedMessageCount 1
+ expectedBodiesReceived '0'
+ }
+ when:
+ withTemplate {
+ to('direct:start').withBody('hello').send()
+ }
+
+ then:
+ MockEndpoint.assertIsSatisfied(context)
+ }
+
def "kamelet (definition with default parameters)"() {
setup:
loadRoutes """