[ 
https://issues.apache.org/jira/browse/CAMEL-12399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16415053#comment-16415053
 ] 

ASF GitHub Bot commented on CAMEL-12399:
----------------------------------------

ffang closed pull request #2265: CAMEL-12399: CxfRsProducer configures 
CxfRsEndpointConfigurer while using the Proxy API
URL: https://github.com/apache/camel/pull/2265
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
index fa9978c71b3..7edd0ba83e3 100644
--- 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
+++ 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
@@ -200,6 +200,8 @@ protected void invokeAsyncProxyClient(Exchange exchange, 
final AsyncCallback cal
             target = cfb.createWithValues(varValues);
         }
 
+        ((CxfRsEndpoint) 
getEndpoint()).getChainedCxfRsEndpointConfigurer().configureClient(target);
+
         setupClientHeaders(target, exchange);
 
         // find out the method which we want to invoke
@@ -421,7 +423,9 @@ protected void invokeProxyClient(Exchange exchange) throws 
Exception {
         } else {
             target = cfb.createWithValues(varValues);
         }
-        
+
+        ((CxfRsEndpoint) 
getEndpoint()).getChainedCxfRsEndpointConfigurer().configureClient(target);
+
         setupClientHeaders(target, exchange);
         
         // find out the method which we want to invoke
diff --git 
a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerEndpointConfigurerTest.java
 
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerEndpointConfigurerTest.java
new file mode 100644
index 00000000000..035a79aede0
--- /dev/null
+++ 
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerEndpointConfigurerTest.java
@@ -0,0 +1,103 @@
+/**
+ * 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.cxf.jaxrs;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
+import org.apache.camel.component.cxf.jaxrs.testbean.CustomerService;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean;
+import org.apache.cxf.jaxrs.client.Client;
+import org.apache.cxf.message.MessageContentsList;
+import org.junit.Test;
+
+import javax.ws.rs.HttpMethod;
+
+public class CxfRsProducerEndpointConfigurerTest extends CamelTestSupport {
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                CxfRsEndpoint endpoint = new CxfRsEndpoint();
+                endpoint.setAddress("http://localhost:8000";);
+                endpoint.setCamelContext(context);
+                endpoint.setResourceClasses(CustomerService.class);
+                endpoint.setEndpointUriIfNotSpecified("cxfrs:simple");
+                endpoint.setCxfRsEndpointConfigurer(new 
MyCxfRsEndpointConfigurer());
+
+                from("direct:start")
+                        .to(endpoint)
+                        .to("mock:end");
+
+                from("jetty:http://localhost:8000?matchOnUriPrefix=true";)
+                        .to("mock:result")
+                        .process(exchange -> exchange.getIn().setBody(new 
Customer()));
+            }
+        };
+    }
+
+    @Test
+    public void testCxfRsEndpoinConfigurerProxyApi() throws 
InterruptedException {
+        template.send("direct:start", exchange -> {
+            exchange.setPattern(ExchangePattern.InOut);
+            Message inMessage = exchange.getIn();
+            inMessage.setHeader(CxfConstants.OPERATION_NAME, "getCustomer");
+            inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, 
Boolean.FALSE);
+            MessageContentsList messageContentsList = new 
MessageContentsList();
+            messageContentsList.add("1");
+            inMessage.setBody(messageContentsList);
+        });
+        getMockEndpoint("mock:result").expectedHeaderReceived("foo", "bar");
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testCxfRsEndpointConfigurerHttpApi() throws 
InterruptedException {
+        template.send("direct:start", exchange -> {
+            exchange.setPattern(ExchangePattern.InOut);
+            Message inMessage = exchange.getIn();
+            inMessage.setHeader(Exchange.HTTP_PATH, 
"/customerservice/customers/1");
+            inMessage.setHeader(Exchange.HTTP_METHOD, HttpMethod.GET);
+            inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, 
Boolean.TRUE);
+            inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, 
Customer.class);
+        });
+        getMockEndpoint("mock:result").expectedHeaderReceived("foo", "bar");
+        assertMockEndpointsSatisfied();
+    }
+
+    public static class MyCxfRsEndpointConfigurer implements 
CxfRsEndpointConfigurer {
+
+        @Override
+        public void configure(AbstractJAXRSFactoryBean factoryBean) {
+        }
+
+        @Override
+        public void configureClient(Client client) {
+            client.header("foo", "bar");
+        }
+
+        @Override
+        public void configureServer(Server server) {
+        }
+    }
+
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> CxfRsProducer doesn't configure CxfRsEndpointConfigurer while using the Proxy 
> API
> ---------------------------------------------------------------------------------
>
>                 Key: CAMEL-12399
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12399
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxfrs
>    Affects Versions: 2.21.0
>            Reporter: Mike Schippers
>            Assignee: Freeman Fang
>            Priority: Major
>
> The CxfRsProducer doesn't configure a CxfRsEndpointConfigurer on the client 
> while using the Proxy API. When using the HTTP API this is working fine.
> So when i create an endpoint like this:
>  
> {code:java}
> CxfRsEndpoint endpoint = new CxfRsEndpoint(); 
> endpoint.setCxfRsEndpointConfigurer(new MyCxfRsEndpointConfigurer());
> {code}
>  
> {code:java}
> public static class MyCxfRsEndpointConfigurer implements 
> CxfRsEndpointConfigurer {
>     @Override
>     public void configure(AbstractJAXRSFactoryBean factoryBean) {
>     }
>     @Override
>     public void configureClient(Client client) {
>         client.header("foo", "bar");
>     }
>     @Override
>     public void configureServer(Server server) {
>     }
> }
> {code}
> In case i use the HTTP API the header "foo" is sent but not when i use the 
> Proxy API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to