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 9579310CC7 for ; Mon, 17 Feb 2014 16:57:47 +0000 (UTC) Received: (qmail 27921 invoked by uid 500); 17 Feb 2014 16:57:46 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 26810 invoked by uid 500); 17 Feb 2014 16:57:36 -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 26787 invoked by uid 99); 17 Feb 2014 16:57:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Feb 2014 16:57:33 +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; Mon, 17 Feb 2014 16:57:30 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CDAE4238899C; Mon, 17 Feb 2014 16:57:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1569056 - in /cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs: provider/json/JSONProviderTest.java resources/jaxb/Book2NoRootElement.java Date: Mon, 17 Feb 2014 16:57:09 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140217165709.CDAE4238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sergeyb Date: Mon Feb 17 16:57:09 2014 New Revision: 1569056 URL: http://svn.apache.org/r1569056 Log: Adding few more tests to JSONProviderTest Added: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/resources/jaxb/Book2NoRootElement.java (with props) Modified: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java Modified: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java?rev=1569056&r1=1569055&r2=1569056&view=diff ============================================================================== --- cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java (original) +++ cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java Mon Feb 17 16:57:09 2014 @@ -73,6 +73,7 @@ import org.apache.cxf.jaxrs.resources.Ta import org.apache.cxf.jaxrs.resources.TagVO2; import org.apache.cxf.jaxrs.resources.Tags; import org.apache.cxf.jaxrs.resources.jaxb.Book2; +import org.apache.cxf.jaxrs.resources.jaxb.Book2NoRootElement; import org.apache.cxf.staxutils.DelegatingXMLStreamWriter; import org.apache.cxf.staxutils.StaxUtils; @@ -508,6 +509,40 @@ public class JSONProviderTest extends As } @Test + public void testIgnoreNamespacesPackageInfo() throws Exception { + JSONProvider p = new JSONProvider(); + p.setIgnoreNamespaces(true); + Book2 book = new Book2(123); + book.setName("CXF"); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + + p.writeTo(book, Book2.class, Book2.class, Book2.class.getAnnotations(), + MediaType.APPLICATION_JSON_TYPE, new MetadataMap(), os); + + String s = os.toString(); + assertEquals("{\"thebook2\":{\"id\":123,\"name\":\"CXF\"}}", s); + + } + + @Test + public void testIgnoreNamespacesPackageInfo2() throws Exception { + JSONProvider p = new JSONProvider(); + p.setMarshallAsJaxbElement(true); + p.setIgnoreNamespaces(true); + Book2NoRootElement book = new Book2NoRootElement(123); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + + p.writeTo(book, Book2NoRootElement.class, Book2NoRootElement.class, + Book2NoRootElement.class.getAnnotations(), + MediaType.APPLICATION_JSON_TYPE, new MetadataMap(), os); + + String s = os.toString(); + assertEquals("{\"book2\":{\"id\":123}}", s); + + } + + @Test public void testCopyReaderToDocument() throws Exception { String s = "{\"tagVO\":{\"group\":\"b\",\"name\":\"a\"}}"; Added: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/resources/jaxb/Book2NoRootElement.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/resources/jaxb/Book2NoRootElement.java?rev=1569056&view=auto ============================================================================== --- cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/resources/jaxb/Book2NoRootElement.java (added) +++ cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/resources/jaxb/Book2NoRootElement.java Mon Feb 17 16:57:09 2014 @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.jaxrs.resources.jaxb; + +import javax.xml.bind.annotation.XmlType; + +@XmlType(name = "book2") +public class Book2NoRootElement { + + private int id; + + public Book2NoRootElement() { + } + + public Book2NoRootElement(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setId(int ident) { + id = ident; + } +} Propchange: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/resources/jaxb/Book2NoRootElement.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/resources/jaxb/Book2NoRootElement.java ------------------------------------------------------------------------------ svn:keywords = Rev Date