cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1549539 - /cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
Date Mon, 09 Dec 2013 10:58:16 GMT
Author: sergeyb
Date: Mon Dec  9 10:58:16 2013
New Revision: 1549539

URL: http://svn.apache.org/r1549539
Log:
[CXF-5445] Adding a JSONProvider test

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=1549539&r1=1549538&r2=1549539&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 Dec  9 10:58:16 2013
@@ -699,6 +699,21 @@ public class JSONProviderTest extends As
     }
     
     @Test
+    public void testIgnoreNamespaces() throws Exception {
+        JSONProvider<TestBean> p = new JSONProvider<TestBean>();
+        p.setIgnoreNamespaces(true);
+        TestBean bean = new TestBean();
+        bean.setName("a");
+        bean.setId("b");
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        p.writeTo(bean, TestBean.class, TestBean.class, new Annotation[0], 
+                  MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
+        String s = os.toString();
+        assertEquals("{\"testBean\":{\"@id\":\"b\",\"name\":\"a\"}}", s);
+        
+    }
+    
+    @Test
     public void testWriteUnqualifiedCollection() throws Exception {
         JSONProvider<List<Book>> p = new JSONProvider<List<Book>>();
         List<Book> books = new ArrayList<Book>();
@@ -1646,4 +1661,26 @@ public class JSONProviderTest extends As
             }
         }
     }
+    
+    @XmlRootElement(namespace = "http://testbean")
+    public static class TestBean {
+        private String name;
+        private String id;
+        public TestBean() {
+            
+        }
+        public String getName() {
+            return name;
+        }
+        public void setName(String name) {
+            this.name = name;
+        }
+        public String getId() {
+            return id;
+        }
+        @XmlAttribute(namespace = "http://testbean")
+        public void setId(String id) {
+            this.id = id;
+        }
+    }    
 }



Mime
View raw message