cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r800512 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
Date Mon, 03 Aug 2009 19:39:45 GMT
Author: dkulp
Date: Mon Aug  3 19:39:45 2009
New Revision: 800512

URL: http://svn.apache.org/viewvc?rev=800512&view=rev
Log:
Merged revisions 799245 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r799245 | sergeyb | 2009-07-30 07:56:07 -0400 (Thu, 30 Jul 2009) | 1 line
  
  JAXRS : updating JSONProviderTest to check Jettison can handle natural notations 
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  3 19:39:45 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
 4,798654,798748-798749,798891,798929-798930,799267,799439,799448,799637,799723-799724
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
 4,798654,798748-798749,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java?rev=800512&r1=800511&r2=800512&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
Mon Aug  3 19:39:45 2009
@@ -38,6 +38,7 @@
 import javax.xml.bind.annotation.XmlAnyElement;
 import javax.xml.bind.annotation.XmlMixed;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.cxf.jaxrs.impl.MetadataMap;
@@ -407,6 +408,33 @@
     }
     
     @Test
+    public void testWriteUsingNaturalNotation() throws Exception {
+        JSONProvider p = new JSONProvider();
+        p.setSerializeAsArray(true);
+        p.setArrayKeys(Collections.singletonList("comments"));
+        Post post = new Post();
+        post.setTitle("post");
+        Comment c1 = new Comment();
+        c1.setTitle("comment1");
+        Comment c2 = new Comment();
+        c2.setTitle("comment2");
+        post.getComments().add(c1);
+        post.getComments().add(c2);
+        
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        
+        p.writeTo(post, (Class)Post.class, Post.class, Post.class.getAnnotations(), 
+                  MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
+        
+        String s = os.toString();
+        System.out.println(s);
+        assertEquals(
+            "{\"post\":{\"title\":\"post\",\"comments\":[{\"title\":\"comment1\"},"
+            + "{\"title\":\"comment2\"}]}}",
+            s);
+    }
+    
+    @Test
     public void testManyTags() throws Exception {
         JSONProvider p = new JSONProvider();
         p.setSerializeAsArray(true);
@@ -455,4 +483,37 @@
             return books;
         }
     }
+    
+    @XmlRootElement()
+    @XmlType(name = "", propOrder = {"title", "comments" })
+    public static class Post {
+        private String title;
+        private List<Comment> comments = new ArrayList<Comment>();
+        public void setTitle(String title) {
+            this.title = title;
+        }
+        public String getTitle() {
+            return title;
+        }
+        public void setComments(List<Comment> comments) {
+            this.comments = comments;
+        }
+        public List<Comment> getComments() {
+            return comments;
+        }
+    }
+    
+    public static class Comment {
+        private String title;
+
+        public void setTitle(String title) {
+            this.title = title;
+        }
+
+        public String getTitle() {
+            return title;
+        }
+    }
+
+
 }



Mime
View raw message