cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1233299 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/
Date Thu, 19 Jan 2012 11:53:19 GMT
Author: sergeyb
Date: Thu Jan 19 11:53:18 2012
New Revision: 1233299

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

................
  r1233296 | sergeyb | 2012-01-19 11:42:09 +0000 (Thu, 19 Jan 2012) | 13 lines
  
  Merged revisions 1233289,1233294 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1233289 | sergeyb | 2012-01-19 11:29:14 +0000 (Thu, 19 Jan 2012) | 1 line
    
    [CXF-4043] Some updates to do with ignoreNamespaces & collections
  ........
    r1233294 | sergeyb | 2012-01-19 11:38:08 +0000 (Thu, 19 Jan 2012) | 1 line
    
    [CXF-4043] One more update to do with ignoreNamespaces and dropRootElement
  ........
................

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 19 11:53:18 2012
@@ -1,2 +1,2 @@
-/cxf/branches/2.5.x-fixes:1233076,1233113
-/cxf/trunk:1233075,1233112
+/cxf/branches/2.5.x-fixes:1233076,1233113,1233296
+/cxf/trunk:1233075,1233112,1233289-1233294

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

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=1233299&r1=1233298&r2=1233299&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
Thu Jan 19 11:53:18 2012
@@ -467,7 +467,9 @@ public class JSONProvider extends Abstra
         Type genericType, String enc, OutputStream os, boolean isCollection) throws Exception
{
         
         QName qname = getQName(actualClass, genericType, actualObject, true);
-        
+        if (ignoreNamespaces && (isCollection  || dropRootElement)) {        
+            qname = new QName(qname.getLocalPart());
+        }
         if (BADGER_FISH_CONVENTION.equals(convention)) {
             return JSONUtils.createBadgerFishWriter(os);
         }
@@ -482,7 +484,7 @@ public class JSONProvider extends Abstra
              writeXsiType && !ignoreNamespaces, config, serializeAsArray, arrayKeys,
              isCollection || dropRootElement);
         writer = JSONUtils.createIgnoreMixedContentWriterIfNeeded(writer, ignoreMixedContent);
-        writer = JSONUtils.createIgnoreNsWriterIfNeeded(writer, ignoreNamespaces &&
!isCollection);
+        writer = JSONUtils.createIgnoreNsWriterIfNeeded(writer, ignoreNamespaces);
         return createTransformWriterIfNeeded(writer, os);
     }
     

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java?rev=1233299&r1=1233298&r2=1233299&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
Thu Jan 19 11:53:18 2012
@@ -221,6 +221,11 @@ public final class JSONUtils {
         }
         
         @Override
+        public void writeStartElement(String local) throws XMLStreamException {
+            this.writeStartElement("", local, "");
+        }
+        
+        @Override
         public void writeEndElement() throws XMLStreamException {
             index--;
             if (rootDropped && index == 0) {

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java?rev=1233299&r1=1233298&r2=1233299&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
Thu Jan 19 11:53:18 2012
@@ -274,6 +274,22 @@ public class JSONProviderTest extends As
     
     @SuppressWarnings("unchecked")
     @Test
+    public void testWriteToSingleTag2NoNs() throws Exception {
+        JSONProvider<TagVO2> p = new JSONProvider<TagVO2>();
+        p.setIgnoreNamespaces(true);
+        TagVO2 tag = createTag2("a", "b");
+        
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        
+        p.writeTo(tag, TagVO2.class, TagVO2.class, TagVO2.class.getAnnotations(), 
+                  MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
+        
+        String s = os.toString();
+        assertEquals("{\"thetag\":{\"group\":\"b\",\"name\":\"a\"}}", s);
+        
+    }
+    
+    @Test
     public void testCopyReaderToDocument() throws Exception {
         String s = "{\"tagVO\":{\"group\":\"b\",\"name\":\"a\"}}";
         
@@ -381,6 +397,7 @@ public class JSONProviderTest extends As
     public void testDropRootElement() throws Exception {
         JSONProvider p = new JSONProvider();
         p.setDropRootElement(true);
+        p.setIgnoreNamespaces(true);
         Map<String, String> namespaceMap = new HashMap<String, String>();
         namespaceMap.put("http://tags", "ns1");
         p.setNamespaceMap(namespaceMap);
@@ -457,7 +474,6 @@ public class JSONProviderTest extends As
         Method m = CollectionsResource.class.getMethod("getBooks", new Class[0]);
         p.writeTo(books, m.getReturnType(), m.getGenericReturnType(), new Annotation[0],

                   MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
-        System.out.println(os.toString());
         assertEquals("{\"Book\":[{\"id\":123,\"name\":\"CXF\",\"state\":\"\"}]}",
                      os.toString());
         
@@ -569,6 +585,7 @@ public class JSONProviderTest extends As
                   MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
         
         String s = os.toString();
+        System.out.println(s);
         assertEquals("{\"ns1.thetag\":{\"group\":\"b\",\"name\":\"a\"}}", s);
         
     }



Mime
View raw message