cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1177282 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java test/java/org/apache/cxf/jaxrs/Customer.java test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Date Thu, 29 Sep 2011 12:25:53 GMT
Author: sergeyb
Date: Thu Sep 29 12:25:53 2011
New Revision: 1177282

URL: http://svn.apache.org/viewvc?rev=1177282&view=rev
Log:
[CXF-3834] Minor fix to get arrays supported

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java

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=1177282&r1=1177281&r2=1177282&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
Thu Sep 29 12:25:53 2011
@@ -714,7 +714,8 @@ public final class InjectionUtils {
      //CHECKSTYLE:ON    
         Class<?> type = getCollectionType(rawType);
 
-        Class<?> realType = InjectionUtils.getActualType(genericType);
+        Class<?> realType = rawType.isArray() ? rawType.getComponentType() 
+                : InjectionUtils.getActualType(genericType);
         
         Object theValues = null;
         if (type != null) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=1177282&r1=1177281&r2=1177282&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java Thu Sep 29
12:25:53 2011
@@ -337,8 +337,10 @@ public class Customer extends AbstractCu
     public void testQueryAsList(
         @DefaultValue("default") @QueryParam("query") List<String> queryString,
         @QueryParam("query2") List<String> queryString2,
-        @QueryParam("query3") List<String> queryString3,
-        @QueryParam("query4") List<String> queryString4) {
+        @QueryParam("query3") List<Integer> queryString3,
+        @QueryParam("query3") Integer[] queryString3Array,
+        @QueryParam("query4") List<String> queryString4,
+        @QueryParam("query5") List<String> queryString5) {
         // complete
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1177282&r1=1177281&r2=1177282&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Thu Sep 29 12:25:53 2011
@@ -674,14 +674,16 @@ public class JAXRSUtilsTest extends Asse
     @SuppressWarnings("unchecked")
     @Test
     public void testQueryParamAsListWithDefaultValue() throws Exception {
-        Class[] argType = {List.class, List.class, List.class, List.class};
+        Class[] argType = {List.class, List.class, List.class, Integer[].class, 
+            List.class, List.class};
         Method m = Customer.class.getMethod("testQueryAsList", argType);
-        MessageImpl messageImpl = new MessageImpl();
-        messageImpl.put(Message.QUERY_STRING, "query2=query2Value&query3");
+        Message messageImpl = createMessage();
+        messageImpl.put(Message.QUERY_STRING, 
+                "query2=query2Value&query2=query2Value2&query3=1&query3=2&query4");
         List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
                                                            null, 
                                                            messageImpl);
-        assertEquals(4, params.size());
+        assertEquals(6, params.size());
         List<String> queryList = (List<String>)params.get(0);
         assertNotNull(queryList);
         assertEquals(1, queryList.size());
@@ -689,17 +691,30 @@ public class JAXRSUtilsTest extends Asse
         
         List<String> queryList2 = (List<String>)params.get(1);
         assertNotNull(queryList2);
-        assertEquals(1, queryList2.size());
+        assertEquals(2, queryList2.size());
         assertEquals("query2Value", queryList2.get(0));
+        assertEquals("query2Value2", queryList2.get(1));
         
-        List<String> queryList3 = (List<String>)params.get(2);
+        List<Integer> queryList3 = (List<Integer>)params.get(2);
         assertNotNull(queryList3);
-        assertEquals(1, queryList3.size());
-        assertEquals("", queryList3.get(0));
+        assertEquals(2, queryList3.size());
+        assertEquals(Integer.valueOf(1), queryList3.get(0));
+        assertEquals(Integer.valueOf(2), queryList3.get(1));
+        
+        Integer[] queryList3Array = (Integer[])params.get(3);
+        assertNotNull(queryList3Array);
+        assertEquals(2, queryList3Array.length);
+        assertEquals(Integer.valueOf(1), queryList3Array[0]);
+        assertEquals(Integer.valueOf(2), queryList3Array[1]);
         
-        List<String> queryList4 = (List<String>)params.get(3);
+        List<String> queryList4 = (List<String>)params.get(4);
         assertNotNull(queryList4);
-        assertEquals(0, queryList4.size());
+        assertEquals(1, queryList4.size());
+        assertEquals("", queryList4.get(0));
+        
+        List<String> queryList5 = (List<String>)params.get(5);
+        assertNotNull(queryList5);
+        assertEquals(0, queryList5.size());
     }
     
     @Test



Mime
View raw message