davsclaus commented on code in PR #31283:
URL: https://github.com/apache/camel/pull/31283#discussion_r4796478952


##########
components/camel-twilio/src/test/java/org/apache/camel/component/twilio/TwilioComponentTest.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.component.twilio;
+
+import org.apache.camel.FailedToStartComponentException;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Unit tests for CAMEL-27976: component configuration shadowing and 
credential check bugs.
+ */
+class TwilioComponentTest {
+
+    /**
+     * Bug 1: TwilioComponent declared a private {@code configuration} field 
that shadowed
+     * {@code AbstractApiComponent.configuration}. As a result, {@code 
setConfiguration()} only updated the subclass
+     * field, while {@code createEndpointConfiguration()} (in the superclass) 
always saw {@code null} and never copied
+     * component-level options to endpoints.
+     * <p>
+     * After the fix, {@code getConfiguration()}/{@code setConfiguration()} 
delegate to the superclass, so the
+     * superclass field is kept in sync.
+     */
+    @Test
+    void testSetConfigurationIsVisibleToSuperclass() {
+        TwilioComponent component = new TwilioComponent();
+        TwilioConfiguration cfg = new TwilioConfiguration();
+        component.setConfiguration(cfg);
+
+        Assertions.assertSame(cfg, component.getConfiguration(),
+                "getConfiguration() must return the instance set via 
setConfiguration()");
+    }

Review Comment:
   Fixed in 0977cb7f2114. The test now also checks the protected 
`configuration` field of `AbstractApiComponent`, which 
`createEndpointConfiguration()` reads. It reads the field through a small test 
subclass instead of reflection. With the old shadowing field in 
`TwilioComponent`, the subclass would not compile, so the test guards against 
the field coming back.
   
   _Claude Code on behalf of davsclaus_



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to