cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1099496 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Wed, 04 May 2011 15:50:23 GMT
Author: sergeyb
Date: Wed May  4 15:50:22 2011
New Revision: 1099496

URL: http://svn.apache.org/viewvc?rev=1099496&view=rev
Log:
[CXF-3489] JSON sequences created from explicit collections of unqualified beans can not be
read without additional configuration

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=1099496&r1=1099495&r2=1099496&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
Wed May  4 15:50:22 2011
@@ -333,7 +333,7 @@ public class JSONProvider extends Abstra
                 qname = el.getName();
                 actualClass = el.getDeclaredType();
             } else {
-                qname = getCollectionWrapperQName(actualClass, genericType, firstObj, true);
+                qname = getCollectionWrapperQName(actualClass, genericType, firstObj, false);
             }
             if (qname.getNamespaceURI().length() > 0) {
                 startTag = "{\"ns1." + qname.getLocalPart() + "\":[";

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java?rev=1099496&r1=1099495&r2=1099496&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
Wed May  4 15:50:22 2011
@@ -391,6 +391,20 @@ public class JSONProviderTest extends As
     }
     
     @Test
+    public void testWriteUnqualifiedCollection() throws Exception {
+        JSONProvider p = new JSONProvider();
+        List<Book> books = new ArrayList<Book>();
+        books.add(new Book("CXF", 123L));
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        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);
+        assertEquals("{\"Book\":[{\"id\":123,\"name\":\"CXF\",\"state\":\"\"}]}",
+                     os.toString());
+        
+    }
+    
+    @Test
     public void testReadUnqualifiedCollection() throws Exception {
         String data = "{\"Book\":[{\"id\":\"123\",\"name\":\"CXF in Action\"}"
             + ",{\"id\":\"124\",\"name\":\"CXF Rocks\"}]}";

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1099496&r1=1099495&r2=1099496&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Wed May  4 15:50:22 2011
@@ -926,7 +926,7 @@ public class JAXRSClientServerBookTest e
         WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
         Response r = wc.type("application/xml").accept("application/json")
             .post(new Books(new Book("CXF", 123L)));
-        assertEquals("{\"Books\":[{\"id\":123,\"name\":\"CXF\"}]}",
+        assertEquals("{\"Book\":[{\"id\":123,\"name\":\"CXF\"}]}",
                      IOUtils.readStringFromStream((InputStream)r.getEntity()));
     }
     



Mime
View raw message