cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1201680 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
Date Mon, 14 Nov 2011 12:22:28 GMT
Author: sergeyb
Date: Mon Nov 14 12:22:27 2011
New Revision: 1201680

URL: http://svn.apache.org/viewvc?rev=1201680&view=rev
Log:
[CXF-3900] Checking Sets when reading the beans

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/utils/InjectionUtilsTest.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=1201680&r1=1201679&r2=1201680&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
Mon Nov 14 12:22:27 2011
@@ -1014,10 +1014,11 @@ public final class InjectionUtils {
                 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 if (value instanceof Set) {
+                        theValues = new ArrayList<Object>((Set<?>)value);
                     } else {
                         theValues = CastUtils.cast((List<?>)value);
                     }

Modified: 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=1201680&r1=1201679&r2=1201680&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
Mon Nov 14 12:22:27 2011
@@ -73,10 +73,16 @@ public class InjectionUtilsTest extends 
         values.add("lv11");
         values.add("lv22");
         bean2.setC(values);
+        Set<String> set = new HashSet<String>();
+        set.add("set1");
+        set.add("set2");
+        bean2.setS(set);
+        
         bean1.setD(bean2);
         
+        
         MultivaluedMap<String, Object> map = InjectionUtils.extractValuesFromBean(bean1,
"");
-        assertEquals("Size is wrong", 6, map.size());
+        assertEquals("Size is wrong", 7, map.size());
         assertEquals(1, map.get("a").size());
         assertEquals("aValue", map.getFirst("a"));
         assertEquals(1, map.get("b").size());
@@ -93,6 +99,10 @@ public class InjectionUtilsTest extends 
         assertEquals("lv11", map.get("d.c").get(0));
         assertEquals("lv22", map.get("d.c").get(1));
         
+        assertEquals(2, map.get("d.s").size());
+        assertEquals("set1", map.get("d.s").get(0));
+        assertEquals("set2", map.get("d.s").get(1));
+        
     }
 
     static class CustomerBean1 {
@@ -140,6 +150,8 @@ public class InjectionUtilsTest extends 
         private String a;
         private Long b;
         private List<String> c;
+        private Set<String> s;
+        
         public void setA(String aString) {
             this.a = aString;
         }
@@ -159,7 +171,13 @@ public class InjectionUtilsTest extends 
             return c;
         }
         
+        public void setS(Set<String> set) {
+            this.s = set;
+        }
         
+        public Set<String> getS() {
+            return this.s;
+        }
     }
     
 }



Mime
View raw message