cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1104186 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/
Date Tue, 17 May 2011 12:19:56 GMT
Author: sergeyb
Date: Tue May 17 12:19:56 2011
New Revision: 1104186

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

........
  r1104180 | sergeyb | 2011-05-17 13:04:51 +0100 (Tue, 17 May 2011) | 1 line
  
  [CXF-3528] Transform writer needs to writeEndDocument
........

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

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 17 12:19:56 2011
@@ -1 +1 @@
-/cxf/trunk:1099767,1100898,1101399,1102198,1103904,1104144
+/cxf/trunk:1099767,1100898,1101399,1102198,1103904,1104144,1104180

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

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1104186&r1=1104185&r2=1104186&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Tue May 17 12:19:56 2011
@@ -396,13 +396,8 @@ public class JAXBElementProvider extends
                 }
                 mc.put(XMLStreamWriter.class.getName(), writer);    
             }
-                
             marshalToWriter(ms, obj, writer, mt);
-            if (mc != null && mc.getContent(XMLStreamWriter.class) != null) {
-                writer.writeEndDocument();
-                writer.flush();
-                writer.close();
-            }
+            writer.writeEndDocument();
         } else {
             marshalToOutputStream(ms, obj, os, mt);
         }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1104186&r1=1104185&r2=1104186&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Tue May 17 12:19:56 2011
@@ -26,6 +26,7 @@ import java.io.OutputStream;
 import java.io.Writer;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -716,6 +717,42 @@ public class JAXBElementProviderTest ext
             + "<thetag><group>B</group><name>A</name></thetag></tagholder>";
         assertEquals(expected, bos.toString());
     }
+    @Test
+    public void testOutAttributesAsElementsForList() throws Exception {
+
+        //Provider
+        JAXBElementProvider provider = new JAXBElementProvider();
+        provider.setCollectionWrapperName("tagholders");
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("{http://tags}*", "*");
+        provider.setOutTransformElements(map);
+        provider.setAttributesToElements(true);
+    
+        //data setup
+        TagVO2 tag = new TagVO2("A", "B");
+        TagVO2Holder holder = new TagVO2Holder();
+        holder.setTag(tag);
+        List<TagVO2Holder> list = new ArrayList<JAXBElementProviderTest.TagVO2Holder>();
+        list.add(holder);
+    
+        //ParameterizedType required for Lists of Objects
+        ParameterizedType type = new ParameterizedType() {
+            public Type getRawType() { return List.class; }
+            public Type getOwnerType() { return null; }
+            public Type[] getActualTypeArguments() {
+                return new Type[] {TagVO2Holder.class};
+            }
+        };
+    
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        provider.writeTo(list, ArrayList.class, type,
+            new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String, Object>(),
bos);
+    
+        String expected = "<tagholders><tagholder><attr>attribute</attr>"
+            + "<thetag><group>B</group><name>A</name></thetag></tagholder></tagholders>";
+        assertEquals(expected, bos.toString());
+    }
+    
     
     @Test
     public void testOutAppendElementsDiffNs() throws Exception {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java?rev=1104186&r1=1104185&r2=1104186&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
Tue May 17 12:19:56 2011
@@ -24,6 +24,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -818,6 +820,43 @@ public class JSONProviderTest extends As
         assertEquals(expected, bos.toString());
     }
     
+    @Test
+    public void testOutAttributesAsElementsForList() throws Exception {
+
+        //Provider
+        JSONProvider provider = new JSONProvider();
+        provider.setCollectionWrapperName("tagholders");
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("{http://tags}*", "*");
+        provider.setOutTransformElements(map);
+        provider.setAttributesToElements(true);
+    
+        //data setup
+        TagVO2 tag = new TagVO2("A", "B");
+        TagVO2Holder holder = new TagVO2Holder();
+        holder.setTag(tag);
+        List<TagVO2Holder> list = new ArrayList<JAXBElementProviderTest.TagVO2Holder>();
+        list.add(holder);
+    
+        //ParameterizedType required for Lists of Objects
+        ParameterizedType type = new ParameterizedType() {
+            public Type getRawType() { return List.class; }
+            public Type getOwnerType() { return null; }
+            public Type[] getActualTypeArguments() {
+                return new Type[] {TagVO2Holder.class};
+            }
+        };
+    
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        provider.writeTo(list, ArrayList.class, type,
+            new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String, Object>(),
bos);
+        String expected = 
+            "{\"tagholders\":["
+            + "{\"tagholder\":{\"attr\":\"attribute\",\"thetag\":{\"group\":\"B\",\"name\":\"A\"}}}"
+            + "]}";
+        assertEquals(expected, bos.toString());
+    }
+    
     @SuppressWarnings("unchecked")
     private void readTagVOAfterTransform(String data, String keyValue) throws Exception {
         JSONProvider provider = new JSONProvider();



Mime
View raw message