From commits-return-14660-apmail-cxf-commits-archive=cxf.apache.org@cxf.apache.org Wed May 4 15:50:44 2011 Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A06813F7C for ; Wed, 4 May 2011 15:50:44 +0000 (UTC) Received: (qmail 5710 invoked by uid 500); 4 May 2011 15:50:44 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 5664 invoked by uid 500); 4 May 2011 15:50:44 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 5657 invoked by uid 99); 4 May 2011 15:50:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 May 2011 15:50:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 May 2011 15:50:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1E6BB23889EC; Wed, 4 May 2011 15:50:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110504155023.1E6BB23889EC@eris.apache.org> 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 books = new ArrayList(); + 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(), 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())); }