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

ffang pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 30c85d10a50864b39b9553e94950180f4887035e
Author: Schippers <mike.schipp...@stedin.net>
AuthorDate: Fri Mar 23 10:51:14 2018 +0100

    CAMEL-12399: fix CxfRsProducer doesn't configure CxfRsEndpointConfigurer 
while using Proxy API
    
    (cherry picked from commit b1ad26ab133b50d91c298fbb82113f5ecc9b79cb)
---
 .../camel/component/cxf/jaxrs/CxfRsProducer.java   |  6 +-
 .../jaxrs/CxfRsProducerEndpointConfigurerTest.java | 87 ++++++++++++++++++++++
 2 files changed, 92 insertions(+), 1 deletion(-)

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 fa9978c..7edd0ba 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 @@ public class CxfRsProducer extends DefaultProducer 
implements AsyncProcessor {
             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 @@ public class CxfRsProducer extends DefaultProducer 
implements AsyncProcessor {
         } 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 0000000..6f6f8fc
--- /dev/null
+++ 
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerEndpointConfigurerTest.java
@@ -0,0 +1,87 @@
+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) {
+        }
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
ff...@apache.org.

Reply via email to