cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1170736 - in /cxf/branches/2.4.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
Date Wed, 14 Sep 2011 17:52:42 GMT
Author: dkulp
Date: Wed Sep 14 17:52:42 2011
New Revision: 1170736

URL: http://svn.apache.org/viewvc?rev=1170736&view=rev
Log:
Merged revisions 1170731 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1170731 | dkulp | 2011-09-14 13:43:57 -0400 (Wed, 14 Sep 2011) | 2 lines
  
  [CXF-3611] Fix the detection of array/list types in
  JAXBSchemaInitializer
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java

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

Modified: cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=1170736&r1=1170735&r2=1170736&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Wed Sep 14 17:52:42 2011
@@ -26,6 +26,7 @@ import java.lang.reflect.GenericArrayTyp
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.logging.Logger;
 
@@ -548,7 +549,10 @@ class JAXBSchemaInitializer extends Serv
         if (cls instanceof Class) {
             return ((Class)cls).isArray();
         } else if (cls instanceof ParameterizedType) {
-            return true;
+            ParameterizedType pt = (ParameterizedType)cls;
+            return pt.getActualTypeArguments().length == 1
+                && pt.getRawType() instanceof Class
+                && Collection.class.isAssignableFrom((Class)pt.getRawType());
         } else if (cls instanceof GenericArrayType) {
             return true;
         }

Modified: cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java?rev=1170736&r1=1170735&r2=1170736&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
Wed Sep 14 17:52:42 2011
@@ -26,6 +26,7 @@ import java.io.StringWriter;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.XMLConstants;
@@ -79,6 +80,9 @@ public class JAXBEncoderDecoderTest exte
     RequestWrapper wrapperAnnotation;
     JAXBContext context;
     Schema schema;
+    Map<String, String> mapField;
+    String arrayField[];
+    List<String> listField;
     
     @Before
     public void setUp() throws Exception {
@@ -100,6 +104,24 @@ public class JAXBEncoderDecoderTest exte
         assertNotNull(schema);
     }
 
+    
+    private Type getFieldType(String name) throws Exception {
+        return this.getClass()
+            .getDeclaredField(name)
+            .getGenericType();
+    }
+    
+    @Test
+    public void testCXF3611() throws Exception {
+        Map<String, String> foo = new HashMap<String, String>();
+        
+        assertTrue(JAXBSchemaInitializer.isArray(getFieldType("arrayField")));
+        assertTrue(JAXBSchemaInitializer.isArray(getFieldType("listField")));
+
+        assertFalse(JAXBSchemaInitializer.isArray(foo.getClass()));
+        assertFalse(JAXBSchemaInitializer.isArray(getFieldType("mapField")));
+    }
+    
     @Test
     public void testMarshallIntoDOM() throws Exception {
         String str = new String("Hello");



Mime
View raw message