cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1431988 - in /cxf/branches/2.6.x-fixes: ./ parent/ rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/ rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/ rt/rs/extensions/providers/s...
Date Fri, 11 Jan 2013 11:03:44 GMT
Author: sergeyb
Date: Fri Jan 11 11:03:44 2013
New Revision: 1431988

URL: http://svn.apache.org/viewvc?rev=1431988&view=rev
Log:
Merged revisions 1431984 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

................
  r1431984 | sergeyb | 2013-01-11 10:54:15 +0000 (Fri, 11 Jan 2013) | 13 lines
  
  Merged revisions 1431604,1431607 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1431604 | sergeyb | 2013-01-10 20:15:53 +0000 (Thu, 10 Jan 2013) | 1 line
    
    [CXF-4744] Upgrade to Jettison 1.3.3
  ........
    r1431607 | sergeyb | 2013-01-10 20:19:59 +0000 (Thu, 10 Jan 2013) | 1 line
    
    Also enabling the last ignored JSONProvider test
  ........
................

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/parent/pom.xml
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1431984
  Merged /cxf/trunk:r1431604-1431607

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

Modified: cxf/branches/2.6.x-fixes/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/parent/pom.xml?rev=1431988&r1=1431987&r2=1431988&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/parent/pom.xml (original)
+++ cxf/branches/2.6.x-fixes/parent/pom.xml Fri Jan 11 11:03:44 2013
@@ -119,7 +119,7 @@
         <cxf.jaxb.xjc.version>${cxf.jaxb21.xjc.version}</cxf.jaxb.xjc.version>
 
         <cxf.jdom.version>1.0</cxf.jdom.version>
-        <cxf.jettison.version>1.3.2</cxf.jettison.version>
+        <cxf.jettison.version>1.3.3</cxf.jettison.version>
         <cxf.jetty.osgi.version>[7.2,8.2)</cxf.jetty.osgi.version>
         <cxf.jetty.version>7.5.4.v20111024</cxf.jetty.version>
         <cxf.jibx.version>1.2.4.5</cxf.jibx.version>

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java?rev=1431988&r1=1431987&r2=1431988&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
Fri Jan 11 11:03:44 2013
@@ -93,6 +93,7 @@ public class JSONProvider<T> extends Abs
         new ConcurrentHashMap<String, String>();
     private boolean serializeAsArray;
     private List<String> arrayKeys;
+    private List<String> primitiveArrayKeys;
     private boolean unwrapped;
     private String wrapperName;
     private Map<String, String> wrapperMap;
@@ -269,7 +270,8 @@ public class JSONProvider<T> extends Abs
         if (BADGER_FISH_CONVENTION.equals(convention)) {
             reader = JSONUtils.createBadgerFishReader(is);
         } else {
-            reader = JSONUtils.createStreamReader(is, readXsiType, namespaceMap, getDepthProperties());
+            reader = JSONUtils.createStreamReader(is, readXsiType, namespaceMap, 
+                                                  primitiveArrayKeys, getDepthProperties());
         }
         reader = createTransformReaderIfNeeded(reader, is);
         
@@ -548,4 +550,8 @@ public class JSONProvider<T> extends Abs
         this.readXsiType = readXsiType;
     }
 
+    public void setPrimitiveArrayKeys(List<String> primitiveArrayKeys) {
+        this.primitiveArrayKeys = primitiveArrayKeys;
+    }
+
 }

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java?rev=1431988&r1=1431987&r2=1431988&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
Fri Jan 11 11:03:44 2013
@@ -23,6 +23,7 @@ import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.Charset;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -136,25 +137,29 @@ public final class JSONUtils {
     
     public static XMLStreamReader createStreamReader(InputStream is, boolean readXsiType,
         ConcurrentHashMap<String, String> namespaceMap) throws Exception {
-        return createStreamReader(is, readXsiType, namespaceMap, null);
+        return createStreamReader(is, readXsiType, namespaceMap, null, null);
     }
     
     public static XMLStreamReader createStreamReader(InputStream is, boolean readXsiType,
-        ConcurrentHashMap<String, String> namespaceMap, 
+        ConcurrentHashMap<String, String> namespaceMap,
+        List<String> primitiveArrayKeys,
         DocumentDepthProperties depthProps) throws Exception {
         if (readXsiType) {
             namespaceMap.putIfAbsent(XSI_URI, XSI_PREFIX);
         }
+        Configuration conf = new Configuration(namespaceMap);
+        conf.setPrimitiveArrayKeys(primitiveArrayKeys == null 
+            ? Collections.<String>emptySet() : new HashSet<String>(primitiveArrayKeys));
         XMLInputFactory factory = depthProps != null 
-            ? new JettisonMappedReaderFactory(namespaceMap, depthProps) 
-            : new MappedXMLInputFactory(namespaceMap);
+            ? new JettisonMappedReaderFactory(conf, depthProps) 
+            : new MappedXMLInputFactory(conf);
         return new JettisonReader(namespaceMap, factory.createXMLStreamReader(is));
     }
     
     private static class JettisonMappedReaderFactory extends MappedXMLInputFactory {
         private DocumentDepthProperties depthProps;
-        public JettisonMappedReaderFactory(Map<?, ?> nstojns, DocumentDepthProperties
depthProps) {
-            super(nstojns);
+        public JettisonMappedReaderFactory(Configuration conf, DocumentDepthProperties depthProps)
{
+            super(conf);
             this.depthProps = depthProps;
         }
         protected JSONTokener createNewJSONTokener(String doc) {

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java?rev=1431988&r1=1431987&r2=1431988&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
Fri Jan 11 11:03:44 2013
@@ -73,7 +73,6 @@ import org.apache.cxf.jaxrs.resources.ja
 import org.apache.cxf.staxutils.StaxUtils;
 
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class JSONProviderTest extends Assert {
@@ -93,6 +92,26 @@ public class JSONProviderTest extends As
     }
     
     @Test
+    public void testReadListOfProperties() throws Exception {
+        
+        String input = 
+            "{\"theBook\":"
+            + "{" 
+            + "\"Names\":[{\"Name\":\"1\"}, {\"Name\":\"2\"}]"
+            + " }                   "
+            + "}                    ";
+    
+        JSONProvider<TheBook> provider = new JSONProvider<TheBook>();
+        provider.setPrimitiveArrayKeys(Collections.singletonList("Names"));
+        TheBook theBook = provider.readFrom(TheBook.class, null, null, 
+                                   null, null, new ByteArrayInputStream(input.getBytes()));
+        List<String> names = theBook.getName();
+        assertNotNull(names);
+        assertEquals("1", names.get(0));
+        assertEquals("2", names.get(1));
+    }
+    
+    @Test
     public void testReadEmbeddedArray() throws Exception {
         String input = 
                 "{\"store\":"
@@ -955,8 +974,6 @@ public class JSONProviderTest extends As
     
     
     @Test
-    @Ignore
-    // name:A is lost
     public void testDropElementsIgnored() throws Exception {
         JSONProvider<ManyTags> provider = new JSONProvider<ManyTags>();
         List<String> list = new ArrayList<String>();
@@ -1295,6 +1312,18 @@ public class JSONProviderTest extends As
     }
     
     @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
+    @XmlRootElement(name = "theBook")
+    public static class TheBook {
+        private List<String> name = new LinkedList<String>();
+       
+        @XmlElement(name = "Name")
+        @XmlElementWrapper(name = "Names")
+        public List<String> getName() {
+            return name;
+        }
+    }
+    
+    @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
     @XmlRootElement(name = "store", namespace = "http://superbooks")
     public static class QualifiedStore {
         private List<Book2> books = new LinkedList<Book2>();



Mime
View raw message