cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r787200 - 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, 22 Jun 2009 11:11:13 GMT
Author: sergeyb
Date: Mon Jun 22 11:11:12 2009
New Revision: 787200

URL: http://svn.apache.org/viewvc?rev=787200&view=rev
Log:
CXF-2303 : proper support for SortedSets

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=787200&r1=787199&r2=787200&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 Jun 22 11:11:12 2009
@@ -519,7 +519,6 @@
     public static boolean isSupportedCollectionOrArray(Class<?> type) {
         return List.class.isAssignableFrom(type)
             || Set.class.isAssignableFrom(type)
-            || SortedSet.class.isAssignableFrom(type)
             || type.isArray();
     }
 
@@ -541,18 +540,25 @@
         }
     }
 
-    private static Object injectIntoCollectionOrArray(Class<?> rawType, Type genericType,
-                                        MultivaluedMap<String, String> values,
-                                        boolean isbean, boolean decoded,
-                                        ParameterType pathParam, Message message) {
+    
+    static Class<?> getCollectionType(Class<?> rawType) {
         Class<?> type = null;
         if (List.class.isAssignableFrom(rawType)) {
             type = ArrayList.class;
-        } else if (Set.class.isAssignableFrom(rawType)) {
-            type = HashSet.class;
         } else if (SortedSet.class.isAssignableFrom(rawType)) {
             type = TreeSet.class;
+        } else if (Set.class.isAssignableFrom(rawType)) {
+            type = HashSet.class;
         }
+        return type;
+        
+    }
+    
+    private static Object injectIntoCollectionOrArray(Class<?> rawType, Type genericType,
+                                        MultivaluedMap<String, String> values,
+                                        boolean isbean, boolean decoded,
+                                        ParameterType pathParam, Message message) {
+        Class<?> type = getCollectionType(rawType);
 
         Class<?> realType = InjectionUtils.getActualType(genericType);
         

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=787200&r1=787199&r2=787200&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 Jun 22 11:11:12 2009
@@ -19,7 +19,12 @@
 package org.apache.cxf.jaxrs.utils;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import javax.ws.rs.core.MultivaluedMap;
 
@@ -28,6 +33,27 @@
 
 public class InjectionUtilsTest extends Assert {
     
+    public void testCollectionTypeFromArray() {
+        assertNull(InjectionUtils.getCollectionType(String[].class));
+    }
+    
+    @Test
+    public void testCollectionType() {
+        assertEquals(ArrayList.class, InjectionUtils.getCollectionType(List.class));
+        assertEquals(HashSet.class, InjectionUtils.getCollectionType(Set.class));
+        assertEquals(TreeSet.class, InjectionUtils.getCollectionType(SortedSet.class));
+    }
+    
+    @Test
+    public void testSupportedCollectionType() {
+        assertFalse(InjectionUtils.isSupportedCollectionOrArray(Map.class));
+        assertTrue(InjectionUtils.isSupportedCollectionOrArray(String[].class));
+        assertTrue(InjectionUtils.isSupportedCollectionOrArray(List.class));
+        assertTrue(InjectionUtils.isSupportedCollectionOrArray(Set.class));
+        assertTrue(InjectionUtils.isSupportedCollectionOrArray(SortedSet.class));
+    }
+    
+    
     @Test
     public void testExtractValuesFromBean() {
         CustomerBean1 bean1 = new CustomerBean1();



Mime
View raw message