cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6121] Updating to Jettison 1.3.7
Date Fri, 28 Nov 2014 22:19:43 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 1842d5bb0 -> 9df5ed744


[CXF-6121] Updating to Jettison 1.3.7


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9df5ed74
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9df5ed74
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9df5ed74

Branch: refs/heads/2.7.x-fixes
Commit: 9df5ed744b044f75aa55579caddea7581736c245
Parents: 1842d5b
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Nov 28 22:10:05 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Nov 28 22:19:19 2014 +0000

----------------------------------------------------------------------
 parent/pom.xml                                  |  2 +-
 .../cxf/jaxrs/provider/json/JSONProvider.java   | 11 ++++++++-
 .../jaxrs/provider/json/utils/JSONUtils.java    |  6 ++++-
 .../jaxrs/provider/json/JSONProviderTest.java   | 24 ++++++++++++++++++--
 4 files changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9df5ed74/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 5634596..4ffd9b0 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -126,7 +126,7 @@
         <cxf.jaxb.xjc.version>${cxf.jaxb21.xjc.version}</cxf.jaxb.xjc.version>
         <cxf.joda.time.version>2.2</cxf.joda.time.version>
         <cxf.jdom.version>1.0</cxf.jdom.version>
-        <cxf.jettison.version>1.3.6</cxf.jettison.version>
+        <cxf.jettison.version>1.3.7</cxf.jettison.version>
         <cxf.jetty.version>8.1.15.v20140411</cxf.jetty.version>
         <cxf.jetty.osgi.version>[7.6,8.2)</cxf.jetty.osgi.version>
         <cxf.jibx.version>1.2.5</cxf.jibx.version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/9df5ed74/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
index 60ca4f1..22d2d3a 100644
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
+++ b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
@@ -102,6 +102,7 @@ public class JSONProvider<T> extends AbstractJAXBProvider<T>
 {
     private List<String> primitiveArrayKeys;
     private boolean unwrapped;
     private String wrapperName;
+    private String namespaceSeparator;
     private Map<String, String> wrapperMap;
     private boolean dropRootElement;
     private boolean dropElementsInXmlStream = true;
@@ -281,7 +282,8 @@ public class JSONProvider<T> extends AbstractJAXBProvider<T>
 {
         } else {
             reader = JSONUtils.createStreamReader(is, 
                                                   readXsiType, 
-                                                  namespaceMap, 
+                                                  namespaceMap,
+                                                  namespaceSeparator,
                                                   primitiveArrayKeys,
                                                   getDepthProperties());
         }
@@ -526,6 +528,9 @@ public class JSONProvider<T> extends AbstractJAXBProvider<T>
 {
                                           writeXsiType && !ignoreNamespaces,
                                           attributesToElements,
                                           typeConverter);
+        if (namespaceSeparator != null) {
+            config.setJsonNamespaceSeparator(namespaceSeparator);
+        }
         if (!dropElementsInXmlStreamProp && super.outDropElements != null) {
             config.setIgnoredElements(outDropElements);
         }
@@ -650,4 +655,8 @@ public class JSONProvider<T> extends AbstractJAXBProvider<T>
 {
     public void setEscapeForwardSlashesAlways(boolean escape) {
         this.escapeForwardSlashesAlways = escape;
     }
+
+    public void setNamespaceSeparator(String namespaceSeparator) {
+        this.namespaceSeparator = namespaceSeparator;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/9df5ed74/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
index 7cde645..754ef2b 100644
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
+++ b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
@@ -135,17 +135,21 @@ public final class JSONUtils {
     
     public static XMLStreamReader createStreamReader(InputStream is, boolean readXsiType,
         ConcurrentHashMap<String, String> namespaceMap) throws Exception {
-        return createStreamReader(is, readXsiType, namespaceMap, null, null);
+        return createStreamReader(is, readXsiType, namespaceMap, null, null, null);
     }
     
     public static XMLStreamReader createStreamReader(InputStream is, boolean readXsiType,
         ConcurrentHashMap<String, String> namespaceMap,
+        String namespaceSeparator,
         List<String> primitiveArrayKeys,
         DocumentDepthProperties depthProps) throws Exception {
         if (readXsiType) {
             namespaceMap.putIfAbsent(XSI_URI, XSI_PREFIX);
         }
         Configuration conf = new Configuration(namespaceMap);
+        if (namespaceSeparator != null) {
+            conf.setJsonNamespaceSeparator(namespaceSeparator);
+        }
         if (primitiveArrayKeys != null) { 
             conf.setPrimitiveArrayKeys(
                 new HashSet<String>(primitiveArrayKeys));

http://git-wip-us.apache.org/repos/asf/cxf/blob/9df5ed74/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
index df9c734..c662e12 100644
--- a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
+++ b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
@@ -430,11 +430,21 @@ public class JSONProviderTest extends Assert {
     
     @Test
     public void testReadFromQualifiedTag() throws Exception {
+        doTestReadFromQualifiedTag(".");
+    }
+    @Test
+    public void testReadFromQualifiedTagCustomNsSep() throws Exception {
+        doTestReadFromQualifiedTag("__");
+    }
+    private void doTestReadFromQualifiedTag(String nsSep) throws Exception {
         JSONProvider<TagVO2> p = new JSONProvider<TagVO2>();
         Map<String, String> namespaceMap = new HashMap<String, String>();
         namespaceMap.put("http://tags", "ns1");
         p.setNamespaceMap(namespaceMap);
-        byte[] bytes = "{\"ns1.thetag\":{\"group\":\"b\",\"name\":\"a\"}}"
+        if (!".".equals(nsSep)) {
+            p.setNamespaceSeparator(nsSep);
+        }
+        byte[] bytes = ("{\"ns1" + nsSep + "thetag\":{\"group\":\"b\",\"name\":\"a\"}}")
             .getBytes();
         Object tagsObject = p.readFrom(TagVO2.class, null, null, 
                                        null, null, new ByteArrayInputStream(bytes));
@@ -634,10 +644,20 @@ public class JSONProviderTest extends Assert {
     
     @Test
     public void testWriteToSingleQualifiedTag() throws Exception {
+        doTestWriteToSingleQualifiedTag(".");
+    }
+    @Test
+    public void testWriteToSingleQualifiedTagCustomNsSep() throws Exception {
+        doTestWriteToSingleQualifiedTag("__");
+    }
+    private void doTestWriteToSingleQualifiedTag(String nsSep) throws Exception {
         JSONProvider<TagVO2> p = new JSONProvider<TagVO2>();
         Map<String, String> namespaceMap = new HashMap<String, String>();
         namespaceMap.put("http://tags", "ns1");
         p.setNamespaceMap(namespaceMap);
+        if (!".".equals(nsSep)) {
+            p.setNamespaceSeparator(nsSep);
+        }
         TagVO2 tag = createTag2("a", "b");
         
         ByteArrayOutputStream os = new ByteArrayOutputStream();
@@ -646,7 +666,7 @@ public class JSONProviderTest extends Assert {
                   MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
         
         String s = os.toString();
-        assertEquals("{\"ns1.thetag\":{\"group\":\"b\",\"name\":\"a\"}}", s);
+        assertEquals("{\"ns1" + nsSep + "thetag\":{\"group\":\"b\",\"name\":\"a\"}}", s);
     }
     
     @Test


Mime
View raw message