cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r770684 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java...
Date Fri, 01 May 2009 13:59:20 GMT
Author: sergeyb
Date: Fri May  1 13:59:19 2009
New Revision: 770684

URL: http://svn.apache.org/viewvc?rev=770684&view=rev
Log:
JAXRS: support for parameter extensions on the client side

Added:
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Fri May  1 13:59:19 2009
@@ -59,6 +59,8 @@
 import org.apache.cxf.jaxrs.impl.UriBuilderImpl;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.ParameterType;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -397,6 +399,35 @@
         return null;                                                
     }
     
+    // TODO : shall we just do the reflective invocation here ?
+    protected static void addParametersToBuilder(UriBuilder ub, String paramName, Object
pValue,
+                                                 ParameterType pt) {
+        if (pt != ParameterType.MATRIX && pt != ParameterType.QUERY) {
+            throw new IllegalArgumentException("This method currently deal "
+                                               + "with matrix and query parameters only");
+        }
+        if (!"".equals(paramName)) {
+            addToBuilder(ub, paramName, pValue, pt);    
+        } else {
+            MultivaluedMap<String, Object> values = 
+                InjectionUtils.extractValuesFromBean(pValue, "");
+            for (Map.Entry<String, List<Object>> entry : values.entrySet()) {
+                for (Object v : entry.getValue()) {
+                    addToBuilder(ub, entry.getKey(), v, pt);
+                }
+            }
+        }
+    }
+
+    private static void addToBuilder(UriBuilder ub, String paramName, Object pValue,
+                                     ParameterType pt) {
+        if (pt == ParameterType.MATRIX) {
+            ub.matrixParam(paramName, pValue.toString());
+        } else {
+            ub.queryParam(paramName, pValue.toString());
+        }
+    }
+    
     protected static void reportNoMessageHandler(String name, Class<?> cls) {
         org.apache.cxf.common.i18n.Message errorMsg = 
             new org.apache.cxf.common.i18n.Message(name, 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Fri May  1 13:59:19 2009
@@ -56,6 +56,7 @@
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import org.apache.cxf.jaxrs.utils.FormUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.ParameterType;
 import org.apache.cxf.message.Message;
@@ -290,7 +291,17 @@
                     }
                 }
             } else {
-                list.add(params[p.getIndex()]);
+                String paramName = p.getValue();
+                if (!"".equals(paramName)) {
+                    list.add(params[p.getIndex()]);
+                } else {
+                    MultivaluedMap<String, Object> values = 
+                        InjectionUtils.extractValuesFromBean(params[p.getIndex()], "");
+                    for (String var : vars) {
+                        list.addAll(values.get(var));
+                    }
+                }
+                
             }
         }
         return list;
@@ -308,7 +319,7 @@
         List<Parameter> qs = getParameters(map, ParameterType.QUERY);
         for (Parameter p : qs) {
             if (params[p.getIndex()] != null) {
-                ub.queryParam(p.getValue(), params[p.getIndex()].toString());
+                addParametersToBuilder(ub, p.getValue(), params[p.getIndex()], ParameterType.QUERY);
             }
         }
     }
@@ -318,20 +329,20 @@
         List<Parameter> mx = getParameters(map, ParameterType.MATRIX);
         for (Parameter p : mx) {
             if (params[p.getIndex()] != null) {
-                ub.matrixParam(p.getValue(), params[p.getIndex()].toString());
+                addParametersToBuilder(ub, p.getValue(), params[p.getIndex()], ParameterType.MATRIX);
             }
         }
     }
 
-    private MultivaluedMap<String, String> handleForm(MultivaluedMap<ParameterType,
Parameter> map, 
+    private MultivaluedMap<String, Object> handleForm(MultivaluedMap<ParameterType,
Parameter> map, 
                                                       Object[] params) {
         
-        MultivaluedMap<String, String> form = new MetadataMap<String, String>();
+        MultivaluedMap<String, Object> form = new MetadataMap<String, Object>();
         
         List<Parameter> fm = getParameters(map, ParameterType.FORM);
         for (Parameter p : fm) {
             if (params[p.getIndex()] != null) {
-                form.add(p.getValue(), params[p.getIndex()].toString());
+                FormUtils.addPropertyToForm(form, p.getValue(), params[p.getIndex()]);
             }
         }
         

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Fri
May  1 13:59:19 2009
@@ -44,6 +44,7 @@
 import org.apache.cxf.jaxrs.ext.form.Form;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ParameterType;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.phase.Phase;
@@ -298,6 +299,7 @@
      */
     public WebClient path(Object path) {
         getCurrentBuilder().path(path.toString());
+        
         return this;
     }
     
@@ -308,7 +310,11 @@
      * @return updated WebClient
      */
     public WebClient query(String name, Object ...values) {
-        getCurrentBuilder().queryParam(name, values);
+        if (!"".equals(name)) {
+            getCurrentBuilder().queryParam(name, values);
+        } else {
+            addParametersToBuilder(getCurrentBuilder(), name, values[0], ParameterType.QUERY);
+        }
         
         return this;
     }
@@ -320,7 +326,12 @@
      * @return updated WebClient
      */
     public WebClient matrix(String name, Object ...values) {
-        getCurrentBuilder().matrixParam(name, values);
+        if (!"".equals(name)) {
+            getCurrentBuilder().matrixParam(name, values);
+        } else {
+            addParametersToBuilder(getCurrentBuilder(), name, values[0], ParameterType.MATRIX);
+        }
+        
         return this;
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java Fri
May  1 13:59:19 2009
@@ -22,6 +22,7 @@
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.jaxrs.utils.FormUtils;
 
 /**
  * Simple MultivaluedMap wrapper 
@@ -32,7 +33,8 @@
         new MetadataMap<String, Object>();
     
     public Form set(String name, Object value) {
-        map.add(name, value);
+        
+        FormUtils.addPropertyToForm(map, name, value);
         return this;
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java Fri
May  1 13:59:19 2009
@@ -24,6 +24,7 @@
 import java.io.InputStream;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MultivaluedMap;
@@ -42,6 +43,20 @@
         
     }
     
+    public static void addPropertyToForm(MultivaluedMap<String, Object> map, String
name, Object value) {
+        if (!"".equals(name)) {
+            map.add(name, value);
+        } else {
+            MultivaluedMap<String, Object> values = 
+                InjectionUtils.extractValuesFromBean(value, "");
+            for (Map.Entry<String, List<Object>> entry : values.entrySet()) {
+                for (Object v : entry.getValue()) {
+                    map.add(entry.getKey(), v.toString());
+                }
+            }
+        }
+    }
+    
     public static String readBody(InputStream is) {
         try {
             ByteArrayOutputStream bos = new ByteArrayOutputStream();

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Fri May  1 13:59:19 2009
@@ -31,6 +31,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -62,6 +63,7 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PrimitiveUtils;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.ParameterHandler;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
@@ -300,7 +302,7 @@
     }
     
     public static Object handleBean(Class<?> paramType, MultivaluedMap<String, String>
values,
-                                    ParameterType pType, Message message) {
+                                    ParameterType pType, Message message, boolean decoded)
{
         Object bean = null;
         try {
             bean = paramType.newInstance();
@@ -392,12 +394,11 @@
                                                             genericType);
                         } else if (isbean) {
                             paramValue = InjectionUtils.handleBean(type, processedValues,
-                                                            pType, message);
+                                                            pType, message, decoded);
                         } else {
-                            paramValue = InjectionUtils.handleParameter(
-                                                            processedValues.values().iterator().next().get(0),
-                                                            type,
-                                                            pType, message);
+                            String value = decodeValue(processedValues.values().iterator().next().get(0),
+                                                       decoded, pType);
+                            paramValue = InjectionUtils.handleParameter(value, type, pType,
message);
                         }
 
                         if (paramValue != null) {
@@ -531,7 +532,7 @@
             theValues = Array.newInstance(realType, isbean ? 1 : values.values().iterator().next().size());
         }
         if (isbean) {
-            Object o = InjectionUtils.handleBean(realType, values, pathParam, message);
+            Object o = InjectionUtils.handleBean(realType, values, pathParam, message, decoded);
             addToCollectionValues(theValues, o, 0);
         } else {
             List<String> valuesList = values.values().iterator().next();
@@ -727,6 +728,44 @@
         }
     }
     
+    public static MultivaluedMap<String, Object> extractValuesFromBean(Object bean,
String baseName) {
+        MultivaluedMap<String, Object> values = new MetadataMap<String, Object>();
+        fillInValuesFromBean(bean, baseName, values);
+        return values;
+    }
+    
+    public static void fillInValuesFromBean(Object bean, String baseName, 
+                                            MultivaluedMap<String, Object> values)
{
+        for (Method m : bean.getClass().getMethods()) {
+            if (m.getName().startsWith("get") && m.getParameterTypes().length ==
0 
+                && m.getName().length() > 3) {
+                String propertyName = m.getName().substring(3).toLowerCase();
+                if (baseName.contains(propertyName) || "class".equals(propertyName)) {
+                    continue;
+                }
+                if (!"".equals(baseName)) {
+                    propertyName = baseName + "." + propertyName;
+                }
+                
+                Object value = extractFromMethod(bean, m);
+                if (isPrimitive(value.getClass())) {
+                    values.putSingle(propertyName, value);
+                } else if (isSupportedCollectionOrArray(value.getClass())) {
+                    // ignoring arrrays for a moment
+                    List<Object> theValues = null;
+                    if (value.getClass().isArray()) {
+                        theValues = Arrays.asList(value);
+                    } else {
+                        theValues = CastUtils.cast((List<?>)value);
+                    }
+                    values.put(propertyName, theValues);
+                } else {
+                    fillInValuesFromBean(value, propertyName, values);
+                }
+            }
+        }
+    }
+    
     public static boolean isPrimitive(Class<?> type) {
         return type.isPrimitive() 
             || Number.class.isAssignableFrom(type)

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Fri
May  1 13:59:19 2009
@@ -547,10 +547,7 @@
             }
             
             if ("".equals(key)) {
-                return InjectionUtils.handleBean(pClass, 
-                                                 params, 
-                                                 ParameterType.MATRIX,
-                                                 m);
+                return InjectionUtils.handleBean(pClass, params, ParameterType.MATRIX, m,
false);
             } else {
                 List<String> values = params.get(key);
                 return InjectionUtils.createParameterObject(values, 
@@ -589,7 +586,7 @@
         }
         
         if ("".equals(key)) {
-            return InjectionUtils.handleBean(pClass, params, ParameterType.FORM, m);
+            return InjectionUtils.handleBean(pClass, params, ParameterType.FORM, m, false);
         } else {
             List<String> results = params.get(key);
     
@@ -724,11 +721,11 @@
                                            Type genericType,
                                            MultivaluedMap<String, String> values,
                                            String defaultValue,
-                                           boolean  decoded) {
+                                           boolean decoded) {
         
         String parameterName = uriParamAnnotation.value();
         if ("".equals(parameterName)) {
-            return InjectionUtils.handleBean(paramType, values, ParameterType.PATH, m);
+            return InjectionUtils.handleBean(paramType, values, ParameterType.PATH, m, decoded);
         } else {
             List<String> results = values.get(parameterName);
             return InjectionUtils.createParameterObject(results, 
@@ -753,9 +750,8 @@
         String queryName = queryParam.value();
 
         if ("".equals(queryName)) {
-            return InjectionUtils.handleBean(paramType, 
-                                             new UriInfoImpl(m, null).getQueryParameters(),
-                                             ParameterType.QUERY, m);
+            return InjectionUtils.handleBean(paramType, new UriInfoImpl(m, null).getQueryParameters(),
+                                             ParameterType.QUERY, m, decode);
         } else {
             List<String> results = getStructuredParams((String)m.get(Message.QUERY_STRING),
                                        "&",

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
Fri May  1 13:59:19 2009
@@ -59,6 +59,15 @@
         assertEquals(URI.create("http://foo/bar"), wc.getCurrentURI());
     }
     
+    @Test 
+    public void testCompositePath() {
+        WebClient wc = WebClient.create("http://foo");
+        wc.path("/bar/baz/");
+        assertEquals(URI.create("http://foo"), wc.getBaseURI());
+        assertEquals(URI.create("http://foo/bar/baz/"), wc.getCurrentURI());
+    }
+    
+    
     @Test(expected = IllegalArgumentException.class) 
     public void testWrongForward() {
         WebClient wc = WebClient.create("http://foo");

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java?rev=770684&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
Fri May  1 13:59:19 2009
@@ -0,0 +1,127 @@
+/**
+ * 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.jaxrs.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class InjectionUtilsTest extends Assert {
+    
+    @Test
+    public void testExtractValuesFromBean() {
+        CustomerBean1 bean1 = new CustomerBean1();
+        bean1.setA("aValue");
+        bean1.setB(1L);
+        List<String> values = new ArrayList<String>();
+        values.add("lv1");
+        values.add("lv2");
+        bean1.setC(values);
+        CustomerBean2 bean2 = new CustomerBean2();
+        bean2.setA("aaValue");
+        bean2.setB(2L);
+        values = new ArrayList<String>();
+        values.add("lv11");
+        values.add("lv22");
+        bean2.setC(values);
+        bean1.setD(bean2);
+        
+        MultivaluedMap<String, Object> map = InjectionUtils.extractValuesFromBean(bean1,
"");
+        assertEquals("Size is wrong", 6, map.size());
+        assertEquals(1, map.get("a").size());
+        assertEquals("aValue", map.getFirst("a"));
+        assertEquals(1, map.get("b").size());
+        assertEquals(1L, map.getFirst("b"));
+        assertEquals(2, map.get("c").size());
+        assertEquals("lv1", map.get("c").get(0));
+        assertEquals("lv2", map.get("c").get(1));
+        
+        assertEquals(1, map.get("d.a").size());
+        assertEquals("aaValue", map.getFirst("d.a"));
+        assertEquals(1, map.get("d.b").size());
+        assertEquals(2L, map.getFirst("d.b"));
+        assertEquals(2, map.get("d.c").size());
+        assertEquals("lv11", map.get("d.c").get(0));
+        assertEquals("lv22", map.get("d.c").get(1));
+        
+    }
+
+    private static class CustomerBean1 {
+        private String a;
+        private Long b;
+        private List<String> c;
+        private CustomerBean2 d;
+        public void setA(String aString) {
+            this.a = aString;
+        }
+        public void setB(Long bLong) {
+            this.b = bLong;
+        }
+        public void setC(List<String> cStringList) {
+            this.c = cStringList;
+        }
+        public void setD(CustomerBean2 dCustomerBean) {
+            this.d = dCustomerBean;
+        }
+        public String getA() {
+            return a;
+        }
+        public Long getB() {
+            return b;
+        }
+        public List<String> getC() {
+            return c;
+        }
+        public CustomerBean2 getD() {
+            return d;
+        }
+        
+    }
+    
+    private static class CustomerBean2 {
+        private String a;
+        private Long b;
+        private List<String> c;
+        public void setA(String aString) {
+            this.a = aString;
+        }
+        public void setB(Long bLong) {
+            this.b = bLong;
+        }
+        public void setC(List<String> cStringList) {
+            this.c = cStringList;
+        }
+        public String getA() {
+            return a;
+        }
+        public Long getB() {
+            return b;
+        }
+        public List<String> getC() {
+            return c;
+        }
+        
+        
+    }
+    
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java Fri
May  1 13:59:19 2009
@@ -57,5 +57,13 @@
     Book getTheBook3(@FormParam("id") String id,
                      @FormParam("name") String name) throws BookNotFoundFault;
     
+    @GET
+    @Path("/subresource4/{id}/{name}")
+    @Produces("application/xml")
+    Book getTheBook4(@PathParam("") Book bookPath,
+                     @QueryParam("") Book bookQuery,
+                     @MatrixParam("") Book matrixBook) throws BookNotFoundFault;
+    
+    
 }
 

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
Fri May  1 13:59:19 2009
@@ -62,5 +62,24 @@
         b.setName(name);
         return b;
     }
+    
+    public Book getTheBook4(Book bookPath, Book bookQuery, Book bookMatrix) throws BookNotFoundFault
{
+        if (bookPath == null || bookQuery == null || bookMatrix == null) {
+            throw new RuntimeException();
+        }
+        long id1 = bookPath.getId();
+        long id2 = bookQuery.getId();
+        long id3 = bookMatrix.getId();
+        if (id1 != 139L || id1 != id2 || id1 != id3 || id1 != id.longValue()) {
+            throw new RuntimeException();
+        }
+        String name1 = bookPath.getName();
+        String name2 = bookQuery.getName();
+        String name3 = bookMatrix.getName();
+        if (!"CXF Rocks".equals(name1) || !name1.equals(name2) || !name1.equals(name3)) {
+            throw new RuntimeException();
+        }
+        return bookPath;
+    }
 
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=770684&r1=770683&r2=770684&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Fri
May  1 13:59:19 2009
@@ -58,7 +58,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerRestSoap.class));
+                   launchServer(BookServerRestSoap.class, true));
     }
     
     @Test
@@ -174,6 +174,31 @@
     }
     
     @Test
+    public void testGetBookSubresourceParamExtensions() throws Exception {
+        
+        String baseAddress = "http://localhost:9092/test/services/rest";
+        BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress,
+                                                              BookStoreJaxrsJaxws.class);
+        BookSubresource bs = proxy.getBookSubresource("139");
+        Book bean = new Book("CXF Rocks", 139L);
+        Book b = bs.getTheBook4(bean, bean, bean);
+        assertEquals(139, b.getId());
+        assertEquals("CXF Rocks", b.getName());
+    }
+    
+    @Test
+    public void testGetBookSubresourceWebClientParamExtensions() throws Exception {
+        
+        WebClient client = WebClient.create("http://localhost:9092/test/services/rest");
+        client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
+        client.path("/bookstore/books/139/subresource4/139/CXF Rocks");
+        Book bean = new Book("CXF Rocks", 139L);
+        Book b = client.matrix("", bean).query("", bean).get(Book.class);
+        assertEquals(139, b.getId());
+        assertEquals("CXF Rocks", b.getName());
+    }
+    
+    @Test
     public void testGetBookSubresourceClient2() throws Exception {
         
         String baseAddress = "http://localhost:9092/test/services/rest";



Mime
View raw message