cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1233306 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/
Date Thu, 19 Jan 2012 12:12:14 GMT
Author: sergeyb
Date: Thu Jan 19 12:12:13 2012
New Revision: 1233306

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

................
  r1233299 | sergeyb | 2012-01-19 11:53:18 +0000 (Thu, 19 Jan 2012) | 20 lines
  
  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.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 19 12:12:13 2012
@@ -1,3 +1,3 @@
-/cxf/branches/2.4.x-fixes:1232881,1233114
-/cxf/branches/2.5.x-fixes:1232880,1233113
-/cxf/trunk:1232877,1233112
+/cxf/branches/2.4.x-fixes:1232881,1233114,1233299
+/cxf/branches/2.5.x-fixes:1232880,1233113,1233296
+/cxf/trunk:1232877,1233112,1233289-1233294

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

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=1233306&r1=1233305&r2=1233306&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
Thu Jan 19 12:12:13 2012
@@ -409,12 +409,14 @@ public class JSONProvider extends Abstra
     protected XMLStreamWriter createWriter(Object actualObject, Class<?> actualClass,

         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);
         }
         
-        QName qname = getQName(actualClass, genericType, actualObject, true);
-        
         Configuration config = 
             JSONUtils.createConfiguration(namespaceMap, 
                                           writeXsiType && !ignoreNamespaces,
@@ -425,7 +427,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.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java?rev=1233306&r1=1233305&r2=1233306&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
Thu Jan 19 12:12:13 2012
@@ -220,6 +220,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.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=1233306&r1=1233305&r2=1233306&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
Thu Jan 19 12:12:13 2012
@@ -22,7 +22,6 @@ package org.apache.cxf.jaxrs;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 import java.util.UUID;
 
 import javax.annotation.PostConstruct;

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java?rev=1233306&r1=1233305&r2=1233306&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
Thu Jan 19 12:12:13 2012
@@ -267,6 +267,22 @@ public class JSONProviderTest extends As
     }
     
     @Test
+    public void testWriteToSingleTag2NoNs() throws Exception {
+        JSONProvider p = new JSONProvider();
+        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 testWriteBookWithStringConverter() throws Exception {
         JSONProvider p = new JSONProvider();
         p.setConvertTypesToStrings(true);
@@ -335,6 +351,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);
@@ -411,7 +428,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());
         
@@ -523,6 +539,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