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 2023/08/28 08:04:57 UTC
[camel] branch ctr-mandatory created (now ed957ac83e4)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch ctr-mandatory
in repository https://gitbox.apache.org/repos/asf/camel.git
at ed957ac83e4 CAMEL-19792: camel-core - PropertyBinding - Constructor args for beans should be mandatory lookup
This branch includes the following new commits:
new 2073c5f62db Polished
new ed957ac83e4 CAMEL-19792: camel-core - PropertyBinding - Constructor args for beans should be mandatory lookup
The 2 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] 01/02: Polished
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch ctr-mandatory
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2073c5f62db14310d98cc1474771026eda04f76c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Aug 28 09:50:43 2023 +0200
Polished
---
.../java/org/apache/camel/dsl/yaml/deserializers/BeansDeserializer.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/BeansDeserializer.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/BeansDeserializer.java
index 63f4e81fb37..13c0e91a76a 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/BeansDeserializer.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/BeansDeserializer.java
@@ -48,7 +48,6 @@ public class BeansDeserializer extends YamlDeserializerSupport implements Constr
public Object construct(Node node) {
final BeansCustomizer answer = new BeansCustomizer();
final SequenceNode sn = asSequenceNode(node);
- final List<CamelContextCustomizer> customizers = new ArrayList<>();
final YamlDeserializationContext dc = getDeserializationContext(node);
for (Node item : sn.getValue()) {
[camel] 02/02: CAMEL-19792: camel-core - PropertyBinding - Constructor args for beans should be mandatory lookup
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch ctr-mandatory
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ed957ac83e40bc22028ebd4f37b12010549c2b3c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Aug 28 10:04:45 2023 +0200
CAMEL-19792: camel-core - PropertyBinding - Constructor args for beans should be mandatory lookup
---
.../camel/support/PropertyBindingSupportTest.java | 26 ++++++++++++++++++++++
.../camel/support/PropertyBindingSupport.java | 2 +-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportTest.java b/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportTest.java
index 1c7293db519..569c10cb938 100644
--- a/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportTest.java
@@ -22,9 +22,11 @@ import java.util.Properties;
import org.apache.camel.CamelContext;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.NoSuchBeanException;
import org.apache.camel.PropertyBindingException;
import org.apache.camel.spi.Injector;
import org.apache.camel.spi.PropertiesComponent;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@@ -466,6 +468,30 @@ public class PropertyBindingSupportTest extends ContextTestSupport {
assertFalse(foo.getAnimal().isDangerous());
}
+ @Test
+ public void testNestedClassConstructorParameterMandatoryBean() throws Exception {
+ Foo foo = new Foo();
+
+ PropertyBindingSupport.build().bind(context, foo, "name", "James");
+ try {
+ PropertyBindingSupport.build().bind(context, foo, "animal",
+ "#class:org.apache.camel.support.Animal('#bean:myName', false)");
+ fail("Should have thrown exception");
+ } catch (PropertyBindingException e) {
+ NoSuchBeanException nsb = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
+ assertEquals("myName", nsb.getName());
+ }
+
+ // add bean and try again
+ context.getRegistry().bind("myName", "Acme");
+ PropertyBindingSupport.build().bind(context, foo, "animal",
+ "#class:org.apache.camel.support.Animal('#bean:myName', false)");
+
+ assertEquals("James", foo.getName());
+ assertEquals("Acme", foo.getAnimal().getName());
+ assertFalse(foo.getAnimal().isDangerous());
+ }
+
@Test
public void testNestedClassFactoryParameterOneParameter() throws Exception {
Foo foo = new Foo();
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index 67d0a8179f4..222e3525e3c 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -1603,7 +1603,7 @@ public final class PropertyBindingSupport {
}
} else if (strval.startsWith("#bean:")) {
String key = strval.substring(6);
- answer = camelContext.getRegistry().lookupByName(key);
+ answer = CamelContextHelper.mandatoryLookup(camelContext, key);
} else if (strval.startsWith("#valueAs(")) {
String text = strval.substring(8);
String typeName = StringHelper.between(text, "(", ")");