Author: raulk
Date: Sun Mar 31 18:42:02 2013
New Revision: 1463031

URL: http://svn.apache.org/r1463031
Log:
CAMEL-5916 CXFRS: Simpler, higher-level binding style injecting headers, 
attachments and entity

Added:
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SimpleCxfRsBinding.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Customer.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerList.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerServiceResource.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/MultipartCustomer.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Order.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Product.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/VipCustomerResource.java
Modified:
    camel/trunk/components/camel-cxf/pom.xml
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java

Modified: camel/trunk/components/camel-cxf/pom.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/pom.xml?rev=1463031&r1=1463030&r2=1463031&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/pom.xml (original)
+++ camel/trunk/components/camel-cxf/pom.xml Sun Mar 31 18:42:02 2013
@@ -208,6 +208,13 @@
       <version>${httpclient4-version}</version>
       <scope>test</scope>
     </dependency>
+    
+    <dependency>
+       <groupId>org.apache.httpcomponents</groupId>
+       <artifactId>httpmime</artifactId>
+           <version>${httpclient4-version}</version>
+       <scope>test</scope>
+    </dependency>
 
     <dependency>
       <groupId>org.slf4j</groupId>

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java?rev=1463031&r1=1463030&r2=1463031&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
 Sun Mar 31 18:42:02 2013
@@ -45,6 +45,23 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class CxfRsEndpoint extends DefaultEndpoint implements 
HeaderFilterStrategyAware, Service {
+    
+    public enum BindingStyle {
+        /**
+         * <i>Only available for consumers.</i>
+         * This binding style processes request parameters, multiparts, etc. 
and maps them to IN headers, IN attachments and to the message body.
+         * It aims to eliminate low-level processing of {@link 
org.apache.cxf.message.MessageContentsList}.
+         * It also also adds more flexibility and simplicity to the response 
mapping.
+         */
+        SimpleConsumer,
+        
+        /**
+         * This is the traditional binding style, which simply dumps the 
{@link org.apache.cxf.message.MessageContentsList} coming in from the CXF stack
+         * onto the IN message body. The user is then responsible for 
processing it according to the contract defined by the JAX-RS method signature.
+         */
+        Default
+    }
+
     private static final Logger LOG = 
LoggerFactory.getLogger(CxfRsEndpoint.class);
 
     protected Bus bus;
@@ -60,6 +77,7 @@ public class CxfRsEndpoint extends Defau
     private boolean loggingFeatureEnabled;
     private int loggingSizeLimit;
     private boolean skipFaultLogging;
+    private BindingStyle bindingStyle = BindingStyle.Default;
     
     private AtomicBoolean getBusHasBeenCalled = new AtomicBoolean(false);
 
@@ -115,6 +133,9 @@ public class CxfRsEndpoint extends Defau
     }
 
     public Producer createProducer() throws Exception {
+        if (bindingStyle == BindingStyle.SimpleConsumer) {
+            throw new IllegalArgumentException("The SimpleConsumer Binding 
Style cannot be used in a camel-cxfrs producer");
+        }
         return new CxfRsProducer(this);
     }
 
@@ -338,14 +359,25 @@ public class CxfRsEndpoint extends Defau
         return isSetDefaultBus;
     }
     
+    public BindingStyle getBindingStyle() {
+        return bindingStyle;
+    }
+
+    /**
+     * See documentation of {@link BindingStyle}.
+     */
+    public void setBindingStyle(BindingStyle bindingStyle) {
+        this.bindingStyle = bindingStyle;
+    }
+    
     @Override
     protected void doStart() throws Exception {
         if (headerFilterStrategy == null) {
             headerFilterStrategy = new CxfRsHeaderFilterStrategy();
         }
-        if (binding == null) {
-            binding = new DefaultCxfRsBinding();
-        }
+        
+        binding = bindingStyle == null || bindingStyle == BindingStyle.Default 
? new DefaultCxfRsBinding() : new SimpleCxfRsBinding();
+        
         if (binding instanceof HeaderFilterStrategyAware) {
             ((HeaderFilterStrategyAware) 
binding).setHeaderFilterStrategy(getHeaderFilterStrategy());
         }
@@ -355,4 +387,5 @@ public class CxfRsEndpoint extends Defau
     protected void doStop() throws Exception {
         // noop
     }
+
 }

Added: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SimpleCxfRsBinding.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SimpleCxfRsBinding.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SimpleCxfRsBinding.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SimpleCxfRsBinding.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,346 @@
+/**
+ * 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 java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.ws.rs.CookieParam;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+
+import org.apache.camel.Message;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.cxf.jaxrs.ext.multipart.Attachment;
+import org.apache.cxf.jaxrs.ext.multipart.InputStreamDataSource;
+import org.apache.cxf.jaxrs.ext.multipart.Multipart;
+import org.apache.cxf.jaxrs.model.URITemplate;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.MessageContentsList;
+
+/**
+ * A CXF RS Binding which maps method parameters as Camel IN headers and the 
payload as the IN message body.
+ * It replaces the default behaviour of creating a MessageContentsList, which 
requires the route to process the contents low-level.
+ * 
+ * <p />
+ * 
+ * The mapping from CXF to Camel is performed as follows:
+ * 
+ * <ul>
+ *  <li>JAX-RS Parameter types (@QueryParam, @HeaderParam, @CookieParam, 
@FormParam, @PathParam, @MatrixParam) are all transferred
+ *      as IN message headers.</li>
+ *  <li>If a request entity is clearly identified (for example, because it's 
the only parameter without an annotation), it's 
+ *      set as the IN message body. Otherwise, the original {@link 
MessageContentsList} is preserved as the message body.</li>
+ *  <li>If Multipart is in use, binary parts are mapped as Camel IN message 
attachments, while any others are mapped as IN message headers for convenience.
+ *      These classes are considered binary: Attachment, DataHandler, 
DataSource, InputStream. Additionally, the original {@link MessageContentsList} 
is
+ *      preserved as the message body.</li>
+ * </ul>
+ * 
+ * For example, the following JAX-RS method signatures are supported, with the 
specified outcomes:
+ * <p />
+ * 
+ * <b><tt>public Response doAction(BusinessObject request);</tt></b><br />
+ * Request payload is placed in IN message body, replacing the original {@link 
MessageContentsList}.
+ * <p />
+ * 
+ * <b><tt>public Response doAction(BusinessObject request, 
@HeaderParam("abcd") String abcd, @QueryParam("defg") String 
defg);</tt></b><br/>
+ * Request payload placed in IN message body, replacing the original {@link 
MessageContentsList}. 
+ * Both request params mapped as IN message headers with names <tt>abcd</tt> 
and <tt>defg</tt>.
+ * <p />
+ * 
+ * <b><tt>public Response doAction(@HeaderParam("abcd") String abcd, 
@QueryParam("defg") String defg);</tt></b><br/>
+ * Both request params mapped as IN message headers with names <tt>abcd</tt> 
and <tt>defg</tt>. 
+ * The original {@link MessageContentsList} is preserved, even though it only 
contains the 2 parameters.
+ * <p />
+ * 
+ * <b><tt>public Response doAction(@Multipart(value="body1") BusinessObject 
request, @Multipart(value="body2") BusinessObject request2);</tt></b><br/>
+ * The first parameter is transferred as a header with name <tt>body1</tt>, 
and the second one is mapped as header <tt>body2</tt>. The original
+ * {@link MessageContentsList} is preserved as the IN message body.
+ * <p />
+ * 
+ * <b><tt>public Response doAction(InputStream abcd);</tt></b><br/>
+ * The InputStream is unwrapped from the {@link MessageContentsList} and 
preserved as the IN message body.
+ * <p />
+ * 
+ * <b><tt>public Response doAction(DataHandler abcd);</tt></b><br/>
+ * The DataHandler is unwrapped from the {@link MessageContentsList} and 
preserved as the IN message body.
+ * 
+ */
+public class SimpleCxfRsBinding extends DefaultCxfRsBinding {
+
+    /** The JAX-RS annotations to be injected as headers in the IN message */
+    private static Set<Class<?>> HEADER_ANNOTATIONS = 
Collections.unmodifiableSet(
+            new HashSet<Class<?>>(Arrays.asList(new Class<?>[]{ 
+                    CookieParam.class, 
+                    FormParam.class, 
+                    PathParam.class,
+                    HeaderParam.class, 
+                    MatrixParam.class, 
+                    QueryParam.class})));
+    
+    private static Set<Class<?>> BINARY_ATTACHMENT_TYPES = 
Collections.unmodifiableSet(
+            new HashSet<Class<?>>(Arrays.asList(new Class<?>[] {
+                    Attachment.class,
+                    DataHandler.class,
+                    DataSource.class,
+                    InputStream.class,
+            })));
+    
+    /** Caches the Method to Parameters associations to avoid reflection with 
every request */
+    private Map<Method, MethodSpec> methodSpecCache = new 
ConcurrentHashMap<Method, MethodSpec>();
+    
+    private final static Class<?>[] NO_PARAMETER_TYPES = (Class<?>[]) null;
+    private final static Object[] NO_PARAMETERS = (Object[]) null;
+
+    @Override
+    public void populateExchangeFromCxfRsRequest(Exchange cxfExchange, 
org.apache.camel.Exchange camelExchange,
+                                                 Method method, Object[] 
paramArray) {
+        super.populateExchangeFromCxfRsRequest(cxfExchange, camelExchange, 
method, paramArray);
+        Message in = camelExchange.getIn();
+        bindHeadersFromSubresourceLocators(cxfExchange, camelExchange);
+        MethodSpec spec = methodSpecCache.get(method);
+        if (spec == null) {
+            spec = MethodSpec.fromMethod(method);
+            methodSpecCache.put(method, spec);
+        }
+        bindParameters(in, paramArray, spec.paramNames, spec.numberParameters);
+        bindBody(in, paramArray, spec.entityIndex);
+        if (spec.multipart) {
+            transferMultipartParameters(paramArray, spec.multipartNames, 
spec.multipartTypes, in);
+        }
+    }
+
+    @Override
+    public Object populateCxfRsResponseFromExchange(org.apache.camel.Exchange 
camelExchange, Exchange cxfExchange) throws Exception {
+        Object base = super.populateCxfRsResponseFromExchange(camelExchange, 
cxfExchange);
+        return buildResponse(camelExchange, base);
+    }
+
+    /**
+     * Builds the response for the client.
+     * <p />
+     * Always returns a JAX-RS {@link Response} object, which gives the user a 
better control on the response behaviour.
+     * If the message body is already an instance of {@link Response}, we 
reuse it and just inject the relevant HTTP headers.
+     * @param camelExchange
+     * @param base
+     * @return
+     */
+    protected Object buildResponse(org.apache.camel.Exchange camelExchange, 
Object base) {
+        Message m = camelExchange.hasOut() ? camelExchange.getOut() : 
camelExchange.getIn();
+        ResponseBuilder response;
+
+        // if the body is different to Response, it's an entity; therefore, 
check 
+        if (base instanceof Response) {
+            response = Response.fromResponse((Response) base);
+        } else {
+            int status = 
m.getHeader(org.apache.camel.Exchange.HTTP_RESPONSE_CODE, 
Status.OK.getStatusCode(), Integer.class);
+            response = Response.status(status);
+            
+            // avoid using the request MessageContentsList as the entity; it 
simply doesn't make sense
+            if (base != null && !(base instanceof MessageContentsList)) {
+                response.entity(base);
+            }
+        }
+
+        // Compute which headers to transfer by applying the 
HeaderFilterStrategy, and transfer them to the JAX-RS Response
+        Map<String, String> headersToPropagate = 
filterCamelHeadersForResponseHeaders(m.getHeaders(), camelExchange);
+        for (Entry<String, String> entry : headersToPropagate.entrySet()) {
+            response.header(entry.getKey(), entry.getValue());
+        }
+        return response.build();
+    }
+
+    /**
+     * Filters the response headers that will be sent back to the client.
+     * <p />
+     * The {@link DefaultCxfRsBinding} doesn't filter the response headers 
according to the {@link HeaderFilterStrategy}, 
+     * so we handle this task in this binding.
+     * @param headers
+     * @param camelExchange
+     * @return
+     */
+    protected Map<String, String> 
filterCamelHeadersForResponseHeaders(Map<String, Object> headers,
+                                                                     
org.apache.camel.Exchange camelExchange) {
+        Map<String, String> answer = new HashMap<String, String>();
+        for (Map.Entry<String, Object> entry : headers.entrySet()) {
+            if 
(getHeaderFilterStrategy().applyFilterToCamelHeaders(entry.getKey(), 
entry.getValue(), camelExchange)) {
+                continue;
+            }
+            answer.put(entry.getKey(), entry.getValue().toString());
+        }
+        return answer;
+    }
+
+    /**
+     * Transfers path parameters from the full path (including ancestor 
subresource locators) into Camel IN Message Headers.
+     */
+    @SuppressWarnings("unchecked")
+    protected void bindHeadersFromSubresourceLocators(Exchange cxfExchange, 
org.apache.camel.Exchange camelExchange) {
+        MultivaluedMap<String, String> pathParams = (MultivaluedMap<String, 
String>) 
+                
cxfExchange.getInMessage().get(URITemplate.TEMPLATE_PARAMETERS);
+
+        // return immediately if we have no path parameters
+        if (pathParams == null || (pathParams.size() == 1 && 
pathParams.containsKey(URITemplate.FINAL_MATCH_GROUP))) {
+            return;
+        }
+
+        Message m = camelExchange.getIn();
+        for (Entry<String, List<String>> entry : pathParams.entrySet()) {
+            // skip over the FINAL_MATCH_GROUP which stores the entire path
+            if (URITemplate.FINAL_MATCH_GROUP.equals(entry.getKey())) {
+                continue;
+            }
+            m.setHeader(entry.getKey(), entry.getValue().get(0));
+        }
+    }
+
+    /**
+     * Binds JAX-RS parameter types (@HeaderParam, @QueryParam, @MatrixParam, 
etc.) to the exchange.
+     * 
+     * @param in
+     * @param paramArray
+     * @param paramNames
+     * @param numberParameters
+     */
+    protected void bindParameters(Message in, Object[] paramArray, String[] 
paramNames, int numberParameters) {
+        if (numberParameters == 0) return;
+        
+        for (int i = 0; i < paramNames.length; i++) {
+            if (paramNames[i] != null) {
+                in.setHeader(paramNames[i], paramArray[i]);
+            }
+        }
+    }
+
+    /**
+     * Binds the message body.
+     * 
+     * @param in
+     * @param paramArray
+     * @param singleBodyIndex
+     */
+    protected void bindBody(Message in, Object[] paramArray, int 
singleBodyIndex) {
+        if (singleBodyIndex == -1) return;
+        in.setBody(paramArray[singleBodyIndex]);
+    }
+   
+    private void transferMultipartParameters(Object[] paramArray, String[] 
multipartNames, String[] multipartTypes, Message in) {
+        for (int i = 0; i < multipartNames.length; i++) {
+            if (multipartNames[i] == null || paramArray[i] == null) continue;
+            if (BINARY_ATTACHMENT_TYPES.contains(paramArray[i].getClass())) {
+                transferBinaryMultipartParameter(paramArray[i], 
multipartNames[i], multipartTypes[i], in);
+            } else {
+                in.setHeader(multipartNames[i], paramArray[i]);
+            }
+        }
+    }
+
+    private void transferBinaryMultipartParameter(Object toMap, String 
parameterName, String multipartType, Message in) {
+        DataHandler dh = null;
+        if (toMap instanceof Attachment) {
+            dh = ((Attachment) toMap).getDataHandler();
+        } else if (toMap instanceof DataSource) {
+            dh = new DataHandler((DataSource) toMap);
+        } else if (toMap instanceof DataHandler) {
+            dh = (DataHandler) toMap;
+        } else if (toMap instanceof InputStream) {
+            dh = new DataHandler(new InputStreamDataSource((InputStream) 
toMap, multipartType == null ? "application/octet-stream" : multipartType));
+        }
+        if (dh != null) {
+            in.addAttachment(parameterName, dh);
+        }
+    }
+    
+    protected static class MethodSpec {
+        private boolean multipart = false;
+        private int numberParameters = 0;
+        private int entityIndex = -1;
+        private String[] paramNames;
+        private String[] multipartNames;
+        private String[] multipartTypes;
+        
+        /**
+         * Processes this method definition and extracts metadata relevant for 
the binding process.
+         * @param method The Method to process.
+         * @return A MethodSpec instance representing the method metadata 
relevant to the Camel binding process.
+         */
+        public static MethodSpec fromMethod(Method method) {
+            MethodSpec answer = new MethodSpec();
+            
+            Annotation[][] annotations = method.getParameterAnnotations();
+            int paramCount = method.getParameterTypes().length;
+            answer.paramNames = new String[paramCount];
+            answer.multipartNames = new String[paramCount];
+            answer.multipartTypes = new String[paramCount];
+            // remember the names of parameters to be bound to headers and/or 
attachments
+            for (int i = 0; i < paramCount; i++) {
+                // if the parameter has no annotations, let its array element 
remain = null
+                for (Annotation a : annotations[i]) {
+                    // am I a header?
+                    if (HEADER_ANNOTATIONS.contains(a.annotationType())) {
+                        try {
+                            answer.paramNames[i] = (String) 
a.annotationType().getMethod("value", NO_PARAMETER_TYPES).invoke(a, 
NO_PARAMETERS);
+                            answer.numberParameters++;
+                        } catch (Exception e) { }
+                    }
+                    
+                    // am I multipart?
+                    if (Multipart.class.equals(a.annotationType())) {
+                        Multipart multipart = (Multipart) a;
+                        answer.multipart = true;
+                        answer.multipartNames[i] = multipart.value();
+                        answer.multipartTypes[i] = multipart.type();
+                    }
+                }
+            }
+            
+            // if we are not multipart and the number of detected JAX-RS 
parameters (query, headers, etc.) is less than the number of method parameters
+            // there's one parameter that will serve as message body
+            if (!answer.multipart && answer.numberParameters < 
method.getParameterTypes().length) {
+                for (int i = 0; i < answer.paramNames.length; i++) {
+                    if (answer.paramNames[i] == null) {
+                        answer.entityIndex = i;
+                        break;
+                    }
+                }
+            }
+            
+            return answer;
+        }
+
+    }
+    
+}

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,325 @@
+/**
+ * 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.simplebinding;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.JAXBContext;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cxf.CXFTestSupport;
+import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Customer;
+import 
org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.CustomerList;
+import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Order;
+import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Product;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.cxf.message.MessageContentsList;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.HttpMultipartMode;
+import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.junit.Test;
+
+/**
+ * Tests for the Simple Binding style of CXF JAX-RS consumers.
+ */
+public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
+    private static final String PORT_PATH = CXFTestSupport.getPort1() + 
"/CxfRsConsumerTest";
+    private static final String CXF_RS_ENDPOINT_URI = 
"cxfrs://http://localhost:"; + PORT_PATH + 
"/rest?resourceClasses=org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.CustomerServiceResource&bindingStyle=SimpleConsumer";
+    
+    private JAXBContext jaxb;
+    private HttpClient httpclient;
+    
+    public void setUp() throws Exception {
+        super.setUp();
+        httpclient = new DefaultHttpClient();
+        jaxb = JAXBContext.newInstance(CustomerList.class, Customer.class, 
Order.class, Product.class);
+    }
+    
+    public void tearDown() throws Exception {
+        super.tearDown();
+        httpclient.getConnectionManager().shutdown();
+    }
+    
+    protected RouteBuilder createRouteBuilder() throws Exception {
+                
+        return new RouteBuilder() {
+            public void configure() {
+                
+                from(CXF_RS_ENDPOINT_URI)
+                    .recipientList(simple("direct:${header.operationName}"));
+                    
+                from("direct:getCustomer").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertNotNull(exchange.getIn().getHeader("id"));
+                        long id = exchange.getIn().getHeader("id", Long.class);
+                        if (id == 123) {
+                            assertEquals("123", 
exchange.getIn().getHeader("id"));
+                            assertEquals(MessageContentsList.class, 
exchange.getIn().getBody().getClass());
+                            exchange.getOut().setBody(new Customer(123, 
"Raul"));
+                            
exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 200);
+                        } else if (id == 456) {
+                            
exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);                  
                      
+                        } else {
+                            fail();
+                        }
+                    }
+                });
+                            
+               from("direct:updateCustomer").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertEquals("123", exchange.getIn().getHeader("id"));
+                        Customer c = exchange.getIn().getBody(Customer.class);
+                        assertEquals(123, c.getId());
+                        assertNotNull(c);
+                    }
+               });
+                        
+                from("direct:newCustomer").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        Customer c = exchange.getIn().getBody(Customer.class);
+                        assertNotNull(c);
+                        assertEquals(123, c.getId());
+                    }
+                });
+                
+                from("direct:listVipCustomers").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertEquals("gold", 
exchange.getIn().getHeader("status", String.class));
+                        assertEquals(MessageContentsList.class, 
exchange.getIn().getBody().getClass());
+                        assertEquals(0, 
exchange.getIn().getBody(MessageContentsList.class).size());
+                        CustomerList response = new CustomerList();
+                        List<Customer> list = new ArrayList<Customer>(2);
+                        list.add(new Customer(123, "Raul"));
+                        list.add(new Customer(456, "Raul2"));
+                        response.setCustomers(list);
+                        exchange.getOut().setBody(response);
+                    }
+                });
+                
+                from("direct:updateVipCustomer").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertEquals("gold", 
exchange.getIn().getHeader("status", String.class));
+                        assertEquals("123", exchange.getIn().getHeader("id"));
+                        Customer c = exchange.getIn().getBody(Customer.class);
+                        assertEquals(123, c.getId());
+                        assertNotNull(c);
+                    }
+                });
+                
+                from("direct:deleteVipCustomer").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertEquals("gold", 
exchange.getIn().getHeader("status", String.class));
+                        assertEquals("123", exchange.getIn().getHeader("id"));
+                    }
+                });
+                
+                from("direct:uploadImageInputStream").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertEquals("123", exchange.getIn().getHeader("id"));
+                        assertEquals("image/jpeg", 
exchange.getIn().getHeader("Content-Type"));
+                        
assertTrue(InputStream.class.isAssignableFrom(exchange.getIn().getBody().getClass()));
+                        InputStream is = 
exchange.getIn().getBody(InputStream.class);
+                        is.close();
+                        exchange.getOut().setBody(null);
+                    }
+                });
+                
+                from("direct:uploadImageDataHandler").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertEquals("123", exchange.getIn().getHeader("id"));
+                        assertEquals("image/jpeg", 
exchange.getIn().getHeader("Content-Type"));
+                        
assertTrue(DataHandler.class.isAssignableFrom(exchange.getIn().getBody().getClass()));
+                        DataHandler dh = 
exchange.getIn().getBody(DataHandler.class);
+                        assertEquals("image/jpeg", dh.getContentType());
+                        dh.getInputStream().close();
+                        exchange.getOut().setBody(null);
+                    }
+                });
+                
+                
from("direct:multipartPostWithParametersAndPayload").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertEquals("abcd", 
exchange.getIn().getHeader("query"));
+                        assertEquals("123", exchange.getIn().getHeader("id"));
+                        assertNotNull(exchange.getIn().getAttachment("part1"));
+                        assertNotNull(exchange.getIn().getAttachment("part2"));
+                        assertNull(exchange.getIn().getHeader("part1"));
+                        assertNull(exchange.getIn().getHeader("part2"));
+                        assertEquals(Customer.class, 
exchange.getIn().getHeader("body").getClass());
+                        exchange.getOut().setBody(null);
+                    }
+                });
+                
+                from("direct:multipartPostWithoutParameters").process(new 
Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertNotNull(exchange.getIn().getAttachment("part1"));
+                        assertNotNull(exchange.getIn().getAttachment("part2"));
+                        assertNull(exchange.getIn().getHeader("part1"));
+                        assertNull(exchange.getIn().getHeader("part2"));
+                        assertEquals(Customer.class, 
exchange.getIn().getHeader("body").getClass());
+                        exchange.getOut().setBody(null);
+                    }
+                });
+        
+        }};
+            
+    }
+    
+    @Test
+    public void testGetCustomerOnlyHeaders() throws Exception {
+        HttpGet get = new HttpGet("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/123");
+        get.addHeader("Accept", "text/xml");
+        HttpResponse response = httpclient.execute(get);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+        Customer entity = (Customer) 
jaxb.createUnmarshaller().unmarshal(response.getEntity().getContent());
+        assertEquals(123, entity.getId());
+    }
+    
+    @Test
+    public void testGetCustomerHttp404CustomStatus() throws Exception {
+        HttpGet get = new HttpGet("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/456");
+        get.addHeader("Accept", "text/xml");
+        HttpResponse response = httpclient.execute(get);
+        assertEquals(404, response.getStatusLine().getStatusCode());
+    }
+    
+    @Test
+    public void testUpdateCustomerBodyAndHeaders() throws Exception {
+        HttpPut put = new HttpPut("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/123");
+        StringWriter sw = new StringWriter();
+        jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
+        put.setEntity(new StringEntity(sw.toString()));
+        put.addHeader("Content-Type", "text/xml");
+        put.addHeader("Accept", "text/xml");
+        HttpResponse response = httpclient.execute(put);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+    }
+    
+    @Test
+    public void testNewCustomerOnlyBody() throws Exception {
+        HttpPost post = new HttpPost("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers");
+        StringWriter sw = new StringWriter();
+        jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
+        post.setEntity(new StringEntity(sw.toString()));
+        post.addHeader("Content-Type", "text/xml");
+        post.addHeader("Accept", "text/xml");
+        HttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+    }
+    
+    @Test
+    public void testListVipCustomers() throws Exception {
+        HttpGet get = new HttpGet("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/vip/gold");
+        get.addHeader("Content-Type", "text/xml");
+        get.addHeader("Accept", "text/xml");
+        HttpResponse response = httpclient.execute(get);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+        CustomerList cl = (CustomerList) 
jaxb.createUnmarshaller().unmarshal(new 
StringReader(EntityUtils.toString(response.getEntity())));
+        List<Customer> vips = (List<Customer>) cl.getCustomers();
+        assertEquals(2, vips.size());
+        assertEquals(123, vips.get(0).getId());
+        assertEquals(456, vips.get(1).getId());
+    }
+
+    @Test
+    public void testUpdateVipCustomer() throws Exception {
+        HttpPut put = new HttpPut("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/vip/gold/123");
+        StringWriter sw = new StringWriter();
+        jaxb.createMarshaller().marshal(new Customer(123, "Raul2"), sw);
+        put.setEntity(new StringEntity(sw.toString()));
+        put.addHeader("Content-Type", "text/xml");
+        put.addHeader("Accept", "text/xml");
+        HttpResponse response = httpclient.execute(put);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+    }
+    
+    @Test
+    public void testDeleteVipCustomer() throws Exception {
+        HttpDelete delete = new HttpDelete("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/vip/gold/123");
+        delete.addHeader("Accept", "text/xml");
+        HttpResponse response = httpclient.execute(delete);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+    }
+    
+    @Test
+    public void testUploadInputStream() throws Exception {
+        HttpPost post = new HttpPost("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/123/image_inputstream");
+        post.addHeader("Content-Type", "image/jpeg");
+        post.addHeader("Accept", "text/xml");
+        post.setEntity(new 
InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"),
 100));
+        HttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+    }
+    
+    @Test
+    public void testUploadDataHandler() throws Exception {
+        HttpPost post = new HttpPost("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/123/image_datahandler");
+        post.addHeader("Content-Type", "image/jpeg");
+        post.addHeader("Accept", "text/xml");
+        post.setEntity(new 
InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"),
 100));
+        HttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+    }
+    
+    @Test
+    public void testMultipartPostWithParametersAndPayload() throws Exception {
+        HttpPost post = new HttpPost("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/multipart/123?query=abcd");
+        MultipartEntity multipart = new 
MultipartEntity(HttpMultipartMode.STRICT);
+        multipart.addPart("part1", new FileBody(new 
File(this.getClass().getClassLoader().getResource("java.jpg").toURI()), 
"java.jpg"));
+        multipart.addPart("part2", new FileBody(new 
File(this.getClass().getClassLoader().getResource("java.jpg").toURI()), 
"java.jpg"));
+        StringWriter sw = new StringWriter();
+        jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
+        multipart.addPart("body", new StringBody(sw.toString(), "text/xml", 
Charset.forName("UTF-8")));
+        post.setEntity(multipart);
+        HttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+    }
+    
+    @Test
+    public void testMultipartPostWithoutParameters() throws Exception {
+        HttpPost post = new HttpPost("http://localhost:"; + PORT_PATH + 
"/rest/customerservice/customers/multipart");
+        MultipartEntity multipart = new 
MultipartEntity(HttpMultipartMode.STRICT);
+        multipart.addPart("part1", new FileBody(new 
File(this.getClass().getClassLoader().getResource("java.jpg").toURI()), 
"java.jpg"));
+        multipart.addPart("part2", new FileBody(new 
File(this.getClass().getClassLoader().getResource("java.jpg").toURI()), 
"java.jpg"));
+        StringWriter sw = new StringWriter();
+        jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
+        multipart.addPart("body", new StringBody(sw.toString(), "text/xml", 
Charset.forName("UTF-8")));
+        post.setEntity(multipart);
+        HttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getStatusLine().getStatusCode());
+    }
+    
+}

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Customer.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Customer.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Customer.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Customer.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,79 @@
+/**
+ * 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.simplebinding.testbean;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ *
+ * @version 
+ */
+@XmlRootElement(name = "Customer")
+public class Customer {
+    private long id;
+    private String name;
+
+    public Customer() {
+    }
+
+    public Customer(long id, String name) {
+        setId(id);
+        setName(name);
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (id ^ (id >>> 32));
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof Customer)) {
+            return false;
+        }
+
+        if (this == obj) {
+            return true;
+        }
+
+        Customer other = (Customer) obj;
+        return id == other.id && ObjectHelper.equal(name, other.name);
+    }
+
+}

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerList.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerList.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerList.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerList.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,41 @@
+/**
+ * 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.simplebinding.testbean;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @version 
+ */
+@XmlRootElement(name = "CustomerList")
+public class CustomerList {
+    
+    private List<Customer> customers;
+
+    public List<Customer> getCustomers() {
+        return customers;
+    }
+
+    public void setCustomers(List<Customer> customers) {
+        this.customers = customers;
+    }
+    
+
+}

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerServiceResource.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerServiceResource.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerServiceResource.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/CustomerServiceResource.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,84 @@
+/**
+ * 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.simplebinding.testbean;
+
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
+
+@Path("/customerservice/")
+public class CustomerServiceResource {
+    
+    @PathParam("id")
+    private String id;
+
+    @GET @Path("/customers/{id}/")
+    public Customer getCustomer(@PathParam("id") String id) {
+        return null;
+    }
+
+    @PUT @Path("/customers/{id}")
+    public Response updateCustomer(Customer customer, @PathParam("id") String 
id) {
+        return null;
+    }
+    
+    @POST @Path("/customers/")
+    public Response newCustomer(Customer customer, @PathParam("type") String 
type, @QueryParam("age") int age) {
+        return null;
+    }
+    
+    @Path("/customers/vip/{status}")
+    public VipCustomerResource vipCustomer(@PathParam("status") String status) 
{
+        return new VipCustomerResource();
+    }
+
+    @Consumes("image/jpeg")
+    @POST @Path("/customers/{id}/image_inputstream")
+    public Response uploadImageInputStream(InputStream is) {
+        return null;
+    }
+    
+    @Consumes("image/jpeg")
+    @POST @Path("/customers/{id}/image_datahandler")
+    public Response uploadImageDataHandler(DataHandler dh) {
+        return null;
+    }
+    
+    @Path("/customers/multipart")
+    public MultipartCustomer multipart() {
+        return new MultipartCustomer();
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+    
+}

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/MultipartCustomer.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/MultipartCustomer.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/MultipartCustomer.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/MultipartCustomer.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,47 @@
+/**
+ * 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.simplebinding.testbean;
+
+import javax.activation.DataHandler;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.jaxrs.ext.multipart.Multipart;
+
+public class MultipartCustomer {
+
+    @POST @Path("/{id}")
+    public Response multipartPostWithParametersAndPayload(
+            @QueryParam("query") String abc, @PathParam("id") String id,
+            @Multipart(value = "part1", type = "image/jpeg") DataHandler dh1, 
+            @Multipart(value = "part2", type = "image/jpeg") DataHandler dh2, 
+            @Multipart(value = "body", type = "text/xml") Customer request) {
+        return null;
+    }
+    
+    @POST
+    public Response multipartPostWithoutParameters(
+            @Multipart(value = "part1", type = "image/jpeg") DataHandler dh1, 
+            @Multipart(value = "part2", type = "image/jpeg") DataHandler dh2, 
+            @Multipart(value = "body", type = "text/xml") Customer request) {
+        return null;
+    }
+    
+}

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Order.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Order.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Order.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Order.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,71 @@
+/**
+ * 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.simplebinding.testbean;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @version 
+ */
+@XmlRootElement(name = "Order")
+public class Order {
+    private long id;
+    private String description;
+    private Map<Long, Product> products = new HashMap<Long, Product>();
+
+    public Order() {
+        init();
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String d) {
+        this.description = d;
+    }
+
+    @GET
+    @Path("products/{productId}/")
+    public Product getProduct(@PathParam("productId")int productId) {
+        Product p = products.get(new Long(productId));
+        return p;
+    }
+
+    final void init() {
+        Product p = new Product();
+        p.setId(323);
+        p.setDescription("product 323");
+        products.put(p.getId(), p);
+    }
+
+}

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Product.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Product.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Product.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/Product.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,45 @@
+/**
+ * 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.simplebinding.testbean;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @version 
+ */
+@XmlRootElement(name = "Product")
+public class Product {
+    private long id;
+    private String description;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String d) {
+        this.description = d;
+    }
+}

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/VipCustomerResource.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/VipCustomerResource.java?rev=1463031&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/VipCustomerResource.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/testbean/VipCustomerResource.java
 Sun Mar 31 18:42:02 2013
@@ -0,0 +1,44 @@
+/**
+ * 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.simplebinding.testbean;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+public class VipCustomerResource {
+
+    @GET
+    public Response listVipCustomers() {
+        return null;
+    }
+    
+    @PUT @Path("/{id}")
+    public Response updateVipCustomer(@PathParam("id") String id, Customer 
customer) {
+        return null;
+    }
+    
+    @DELETE @Path("/{id}")
+    public Response deleteVipCustomer(@PathParam("id") String id, 
@QueryParam("sendEmail") Boolean sendEmail) {
+        return null;
+    }
+    
+}


Reply via email to