You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "jamesnetherton (via GitHub)" <gi...@apache.org> on 2025/05/16 14:42:46 UTC

[PR] Improve handling of findSingleByType where multiple beans exist without any @Default qualifier [camel-quarkus]

jamesnetherton opened a new pull request, #7370:
URL: https://github.com/apache/camel-quarkus/pull/7370

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve handling of findSingleByType where multiple beans exist without any @Default qualifier [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #7370:
URL: https://github.com/apache/camel-quarkus/pull/7370#discussion_r2092611502


##########
extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/runtime/CamelBeanPrecedenceTest.java:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.quarkus.core.runtime;
+
+import io.quarkus.arc.DefaultBean;
+import io.quarkus.test.QuarkusUnitTest;
+import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Priority;
+import jakarta.enterprise.inject.Produces;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.support.CamelContextHelper;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class CamelBeanPrecedenceTest {
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+            .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+
+    @Inject
+    CamelContext context;
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithPriority() {
+        BeanA bean = CamelContextHelper.findSingleByType(context, BeanA.class);
+        assertEquals("bar", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithSamePriority() {
+        BeanB bean = CamelContextHelper.findSingleByType(context, BeanB.class);
+        assertNull(bean);
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithoutPriority() {
+        BeanC bean = CamelContextHelper.findSingleByType(context, BeanC.class);
+        assertNull(bean);
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBean() {
+        BeanD bean = CamelContextHelper.findSingleByType(context, BeanD.class);
+        assertEquals("foo", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeWhereIdentifierQualifierAppliedToBean() {
+        BeanE bean = CamelContextHelper.findSingleByType(context, BeanE.class);
+        assertEquals("foo", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeWhereSingleBeanExists() {
+        BeanG bean = CamelContextHelper.findSingleByType(context, BeanG.class);
+        assertNull(bean);
+    }
+
+    @Test
+    public void findSingleByTypeWhereNoBeanProduced() {

Review Comment:
   Yes, I seem to have switched the method names around. I'll fix it together with your previous comment above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve handling of findSingleByType where multiple beans exist without any @Default qualifier [camel-quarkus]

Posted by "zhfeng (via GitHub)" <gi...@apache.org>.
zhfeng commented on code in PR #7370:
URL: https://github.com/apache/camel-quarkus/pull/7370#discussion_r2092592502


##########
extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/runtime/CamelBeanPrecedenceTest.java:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.quarkus.core.runtime;
+
+import io.quarkus.arc.DefaultBean;
+import io.quarkus.test.QuarkusUnitTest;
+import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Priority;
+import jakarta.enterprise.inject.Produces;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.support.CamelContextHelper;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class CamelBeanPrecedenceTest {
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+            .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+
+    @Inject
+    CamelContext context;
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithPriority() {
+        BeanA bean = CamelContextHelper.findSingleByType(context, BeanA.class);
+        assertEquals("bar", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithSamePriority() {
+        BeanB bean = CamelContextHelper.findSingleByType(context, BeanB.class);
+        assertNull(bean);
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithoutPriority() {
+        BeanC bean = CamelContextHelper.findSingleByType(context, BeanC.class);
+        assertNull(bean);
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBean() {
+        BeanD bean = CamelContextHelper.findSingleByType(context, BeanD.class);
+        assertEquals("foo", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeWhereIdentifierQualifierAppliedToBean() {
+        BeanE bean = CamelContextHelper.findSingleByType(context, BeanE.class);
+        assertEquals("foo", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeWhereSingleBeanExists() {

Review Comment:
   It's a little bit confuse. This test is for one existing bean? But it expects `null`?



##########
extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/runtime/CamelBeanPrecedenceTest.java:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.quarkus.core.runtime;
+
+import io.quarkus.arc.DefaultBean;
+import io.quarkus.test.QuarkusUnitTest;
+import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Priority;
+import jakarta.enterprise.inject.Produces;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.support.CamelContextHelper;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class CamelBeanPrecedenceTest {
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+            .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+
+    @Inject
+    CamelContext context;
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithPriority() {
+        BeanA bean = CamelContextHelper.findSingleByType(context, BeanA.class);
+        assertEquals("bar", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithSamePriority() {
+        BeanB bean = CamelContextHelper.findSingleByType(context, BeanB.class);
+        assertNull(bean);
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBeansWithoutPriority() {
+        BeanC bean = CamelContextHelper.findSingleByType(context, BeanC.class);
+        assertNull(bean);
+    }
+
+    @Test
+    public void findSingleByTypeForDefaultBean() {
+        BeanD bean = CamelContextHelper.findSingleByType(context, BeanD.class);
+        assertEquals("foo", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeWhereIdentifierQualifierAppliedToBean() {
+        BeanE bean = CamelContextHelper.findSingleByType(context, BeanE.class);
+        assertEquals("foo", bean.name());
+    }
+
+    @Test
+    public void findSingleByTypeWhereSingleBeanExists() {
+        BeanG bean = CamelContextHelper.findSingleByType(context, BeanG.class);
+        assertNull(bean);
+    }
+
+    @Test
+    public void findSingleByTypeWhereNoBeanProduced() {

Review Comment:
   The method name could be with above one?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve handling of findSingleByType where multiple beans exist without any @Default qualifier [camel-quarkus]

Posted by "zhfeng (via GitHub)" <gi...@apache.org>.
zhfeng commented on PR #7370:
URL: https://github.com/apache/camel-quarkus/pull/7370#issuecomment-2892752125

   [CAMEL-21991](https://issues.apache.org/jira/browse/CAMEL-21991) has been in camel-4.10.4 so I think we need to backport this fix to CQ `3.20.x` as well.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org