cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [3/7] git commit: The the rs/providers working with MOXy
Date Thu, 27 Mar 2014 13:07:55 GMT
The the rs/providers working with MOXy


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

Branch: refs/heads/master
Commit: 434807822d07b68df50c96f005c1085a12b51e74
Parents: 8749d14
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Mar 26 19:07:01 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Mar 27 09:07:49 2014 -0400

----------------------------------------------------------------------
 .../transform/DelegatingNamespaceContext.java   |  6 +++--
 .../jaxrs/provider/json/utils/JSONUtils.java    |  9 ++++++++
 .../jaxrs/provider/json/JSONProviderTest.java   | 23 ++++++++++++++++++--
 3 files changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/43480782/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
b/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
index 9d5737f..041b181 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
@@ -52,8 +52,10 @@ class DelegatingNamespaceContext implements NamespaceContext {
     }
     
     public void addPrefix(String prefix, String ns) {
-        namespaces.getFirst().put(prefix, ns);
-        prefixes.getFirst().put(ns, prefix);
+        if (!namespaces.isEmpty()) {
+            namespaces.getFirst().put(prefix, ns);
+            prefixes.getFirst().put(ns, prefix);
+        }
     }
     
     public String findUniquePrefix(String ns) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/43480782/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 27642a4..348cd84 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
@@ -176,6 +176,15 @@ public final class JSONUtils {
             this.namespaceMap = nsMap;
         }
         
+
+        public String getNamespaceURI(String arg0) {
+            String uri = super.getNamespaceURI(arg0);
+            if (uri == null) {
+                uri = getNamespaceContext().getNamespaceURI(arg0);
+            }
+            return uri;
+        }
+        
         @Override
         public String getAttributePrefix(int n) {
             QName name = getAttributeName(n);

http://git-wip-us.apache.org/repos/asf/cxf/blob/43480782/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 9437bae..adccbb5 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
@@ -61,6 +61,7 @@ import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.stream.StreamSource;
 
 import org.w3c.dom.Document;
+
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
@@ -76,6 +77,7 @@ import org.apache.cxf.jaxrs.resources.jaxb.Book2;
 import org.apache.cxf.jaxrs.resources.jaxb.Book2NoRootElement;
 import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
 import org.apache.cxf.staxutils.StaxUtils;
+
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -635,6 +637,10 @@ public class JSONProviderTest extends Assert {
     @Test
     public void testWriteToSingleQualifiedTagBadgerFish() throws Exception {
         JSONProvider<TagVO2> p = new JSONProvider<TagVO2>();
+        Map<String, String> namespaceMap = new HashMap<String, String>();
+        namespaceMap.put("http://tags", "ns2");
+        p.setNamespaceMap(namespaceMap);
+
         p.setConvention("badgerfish");
         TagVO2 tag = createTag2("a", "b");
         
@@ -895,9 +901,10 @@ public class JSONProviderTest extends Assert {
     
     private void doTestMixedContent(String data, boolean ignore, String fileName) throws
Exception {
         InputStream is = getClass().getResourceAsStream(fileName);
-        JAXBContext context = JAXBContext.newInstance(new Class[]{Books.class, Book.class});
+        JAXBContext context = JAXBContext.newInstance(Books.class);
         Unmarshaller um = context.createUnmarshaller();
         JAXBElement<?> jaxbEl = um.unmarshal(new StreamSource(is), Books.class);
+        
         JSONProvider<JAXBElement<?>> p = new JSONProvider<JAXBElement<?>>();
         p.setIgnoreMixedContent(ignore);
         ByteArrayOutputStream os = new ByteArrayOutputStream();
@@ -1368,6 +1375,11 @@ public class JSONProviderTest extends Assert {
     @Test
     public void testOutAppendElementsSameNs() throws Exception {
         JSONProvider<TagVO2> provider = new JSONProvider<TagVO2>();
+
+        Map<String, String> namespaceMap = new HashMap<String, String>();
+        namespaceMap.put("http://tags", "ns2");
+        provider.setNamespaceMap(namespaceMap);
+
         Map<String, String> map = new HashMap<String, String>();
         map.put("{http://tags}thetag", "{http://tags}t");
         provider.setOutAppendElements(map);
@@ -1382,6 +1394,11 @@ public class JSONProviderTest extends Assert {
     @Test
     public void testOutAppendElementsDiffNs() throws Exception {
         JSONProvider<TagVO2> provider = new JSONProvider<TagVO2>();
+
+        Map<String, String> namespaceMap = new HashMap<String, String>();
+        namespaceMap.put("http://tags", "ns2");
+        provider.setNamespaceMap(namespaceMap);
+
         Map<String, String> map = new HashMap<String, String>();
         map.put("{http://tags}thetag", "{http://tagsvo2}t");
         provider.setOutAppendElements(map);
@@ -1396,6 +1413,9 @@ public class JSONProviderTest extends Assert {
     @Test
     public void testOutElementsMapLocalNsToLocalNs() throws Exception {
         JSONProvider<TagVO2> provider = new JSONProvider<TagVO2>();
+        Map<String, String> namespaceMap = new HashMap<String, String>();
+        namespaceMap.put("http://tags", "ns2");
+        provider.setNamespaceMap(namespaceMap);
         Map<String, String> map = new HashMap<String, String>();
         map.put("{http://tags}thetag", "{http://tagsvo2}t");
         provider.setOutTransformElements(map);
@@ -1475,7 +1495,6 @@ public class JSONProviderTest extends Assert {
         provider.writeTo(b, Base1.class, Base1.class,
                         new Annotation[0], MediaType.APPLICATION_JSON_TYPE,
                         new MetadataMap<String, Object>(), bos);
-        
         readBase(bos.toString());
     }
 


Mime
View raw message