cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [03/16] git commit: The the rs/providers working with MOXy
Date Fri, 04 Apr 2014 15:01:39 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/78c5ca8e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/78c5ca8e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/78c5ca8e

Branch: refs/heads/2.7.x-fixes
Commit: 78c5ca8e5336c080b1c2f88a95e7791eedde648a
Parents: 323863b
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Mar 26 19:07:01 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Apr 4 09:56:35 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/78c5ca8e/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
b/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
index 9d5737f..041b181 100644
--- a/api/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
+++ b/api/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/78c5ca8e/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 5039617..6b2a4ad 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/78c5ca8e/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 bf9a7fd..c5e1086 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
@@ -633,6 +633,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");
         
@@ -893,9 +897,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();
@@ -1366,6 +1371,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);
@@ -1380,6 +1390,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);
@@ -1394,6 +1409,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);
@@ -1473,7 +1491,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