cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
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 GMT
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<Book2> p = new JSONProvider<Book2>();
+        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<String, Object>(),
os);
+        
+        String s = os.toString();
+        assertEquals("{\"thebook2\":{\"id\":123,\"name\":\"CXF\"}}", s);
+        
+    }
+    
+    @Test
+    public void testIgnoreNamespacesPackageInfo2() throws Exception {
+        JSONProvider<Book2NoRootElement> p = new JSONProvider<Book2NoRootElement>();
+        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<String, Object>(),
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



Mime
View raw message