This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch coheigea/CXF-5502
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 35cef71860500ea842dcd95b92eaf00d923002b1
Author: Colm O hEigeartaigh <[email protected]>
AuthorDate: Wed Oct 7 17:09:48 2026 +0100

    CXF-5502: Register the client endpoint with its Service in ClientImpl
---
 .../java/org/apache/cxf/endpoint/ClientImpl.java   |  7 ++-
 .../org/apache/cxf/endpoint/ClientImplTest.java    | 72 ++++++++++++++++++++++
 2 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java 
b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
index 30ac1ba0b3a..17fdc79b400 100644
--- a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
+++ b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
@@ -138,11 +138,14 @@ public class ClientImpl
         EndpointInfo epfo = findEndpoint(svc, port);
 
         try {
+            final Endpoint ep;
             if (endpointImplFactory != null) {
-                
getConduitSelector().setEndpoint(endpointImplFactory.newEndpointImpl(bus, svc, 
epfo));
+                ep = endpointImplFactory.newEndpointImpl(bus, svc, epfo);
             } else {
-                getConduitSelector().setEndpoint(new EndpointImpl(bus, svc, 
epfo));
+                ep = new EndpointImpl(bus, svc, epfo);
             }
+            svc.getEndpoints().put(epfo.getName(), ep);
+            getConduitSelector().setEndpoint(ep);
         } catch (EndpointException epex) {
             throw new IllegalStateException("Unable to create endpoint: " + 
epex.getMessage(), epex);
         }
diff --git a/core/src/test/java/org/apache/cxf/endpoint/ClientImplTest.java 
b/core/src/test/java/org/apache/cxf/endpoint/ClientImplTest.java
new file mode 100644
index 00000000000..251e2fbed81
--- /dev/null
+++ b/core/src/test/java/org/apache/cxf/endpoint/ClientImplTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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.cxf.endpoint;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.ServiceImpl;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+public class ClientImplTest {
+
+    private static final QName PORT_NAME = new 
QName("http://cxf.apache.org/test";, "TestPort");
+
+    @Test
+    public void testEndpointRegisteredWithService() throws Exception {
+        Bus bus = new ExtensionManagerBus();
+        Service svc = createService();
+
+        Client client = new ClientImpl(bus, svc, PORT_NAME, null);
+
+        assertEquals(1, svc.getEndpoints().size());
+        assertSame(client.getEndpoint(), svc.getEndpoints().get(PORT_NAME));
+        assertSame(client.getEndpoint(), 
client.getEndpoint().getService().getEndpoints().get(PORT_NAME));
+    }
+
+    @Test
+    public void testEndpointFromFactoryRegisteredWithService() throws 
Exception {
+        Bus bus = new ExtensionManagerBus();
+        Service svc = createService();
+
+        Client client = new ClientImpl(bus, svc, PORT_NAME, 
SimpleEndpointImplFactory.getSingleton());
+
+        assertEquals(1, svc.getEndpoints().size());
+        assertSame(client.getEndpoint(), svc.getEndpoints().get(PORT_NAME));
+    }
+
+    private static Service createService() {
+        ServiceInfo si = new ServiceInfo();
+        si.setName(new QName("http://cxf.apache.org/test";, "TestService"));
+        EndpointInfo ei = new EndpointInfo(si, 
"http://schemas.xmlsoap.org/soap/http";);
+        ei.setName(PORT_NAME);
+        ei.setAddress("http://localhost:9000/test";);
+        si.addEndpoint(ei);
+        return new ServiceImpl(si);
+    }
+}

Reply via email to