cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1501342 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/
Date Tue, 09 Jul 2013 15:44:22 GMT
Author: sergeyb
Date: Tue Jul  9 15:44:21 2013
New Revision: 1501342

URL: http://svn.apache.org/r1501342
Log:
Merged revisions 1501339 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1501339 | sergeyb | 2013-07-09 16:41:31 +0100 (Tue, 09 Jul 2013) | 1 line
  
  [CXF-5115] Support for primitive arays
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1501339

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1501342&r1=1501341&r2=1501342&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Tue Jul  9 15:44:21 2013
@@ -796,6 +796,8 @@ public final class InjectionUtils {
         if (o != null) {
             if (theValues instanceof Collection) {
                 Collection.class.cast(theValues).add(o);
+            } else if (theValues.getClass().getComponentType().isPrimitive()) {
+                Array.set(theValues, index, o);
             } else {
                 ((Object[]) theValues)[index] = o;
             }

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=1501342&r1=1501341&r2=1501342&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
Tue Jul  9 15:44:21 2013
@@ -362,6 +362,16 @@ public class Customer extends AbstractCu
     }
     
     @Produces("text/xml")   
+    public void testQueryIntegerArray(@QueryParam("query") Integer[] query) {
+        // complete
+    }
+    
+    @Produces("text/xml")   
+    public void testQueryIntArray(@QueryParam("query") int[] query) {
+        // complete
+    }
+    
+    @Produces("text/xml")   
     public void testQueryAsList(
         @DefaultValue("default") @QueryParam("query") List<String> queryString,
         @QueryParam("query2") List<String> queryString2,

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1501342&r1=1501341&r2=1501342&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Tue Jul  9 15:44:21 2013
@@ -804,6 +804,38 @@ public class JAXRSUtilsTest extends Asse
         assertNull(params.get(3));
     }
     
+    @Test
+    public void testQueryParametersIntegerArray() throws Exception {
+        Class<?>[] argType = {Integer[].class};
+        Method m = Customer.class.getMethod("testQueryIntegerArray", argType);
+        MessageImpl messageImpl = new MessageImpl();
+        
+        messageImpl.put(Message.QUERY_STRING, "query=1&query=2");
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+                                                           null, 
+                                                           messageImpl);
+        assertEquals(1, params.size());
+        Integer[] intValues = (Integer[])params.get(0);
+        assertEquals(1, (int)intValues[0]);
+        assertEquals(2, (int)intValues[1]);
+    }
+    
+    @Test
+    public void testQueryParametersIntArray() throws Exception {
+        Class<?>[] argType = {int[].class};
+        Method m = Customer.class.getMethod("testQueryIntArray", argType);
+        MessageImpl messageImpl = new MessageImpl();
+        
+        messageImpl.put(Message.QUERY_STRING, "query=1&query=2");
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+                                                           null, 
+                                                           messageImpl);
+        assertEquals(1, params.size());
+        int[] intValues = (int[])params.get(0);
+        assertEquals(1, intValues[0]);
+        assertEquals(2, intValues[1]);
+    }
+    
     @SuppressWarnings("unchecked")
     @Test
     public void testQueryParamAsListWithDefaultValue() throws Exception {



Mime
View raw message