cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r808501 - in /cxf/branches/2.2.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 Thu, 27 Aug 2009 16:32:40 GMT
Author: dkulp
Date: Thu Aug 27 16:32:38 2009
New Revision: 808501

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

........
  r806876 | bimargulies | 2009-08-22 14:10:37 -0400 (Sat, 22 Aug 2009) | 1 line
  
  CXF-2401.
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisJSONProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 27 16:32:38 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,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803056,803129,803419,803460,803493,803689,804002,804175,804276,805784,805907,805909,806020-806021,806023,806405-806406,806576,806602-806604,806620,806627,806631,806633,806638,806687
+/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,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803056,803129,803419,803460,803493,803689,804002,804175,804276,805784,805907,805909,806020-806021,806023,806405-806406,806576,806602-806604,806620,806627,806631,806633,806638,806687,806876

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/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java?rev=808501&r1=808500&r2=808501&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java
Thu Aug 27 16:32:38 2009
@@ -32,6 +32,7 @@
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.Provider;
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
@@ -75,7 +76,7 @@
         org.apache.cxf.aegis.type.Type aegisType = TypeUtil.getWriteTypeStandalone(context,
obj, genericType);
         AegisWriter<XMLStreamWriter> aegisWriter = context.createXMLStreamWriter();
         try {
-            XMLStreamWriter xmlStreamWriter = createStreamWriter(type, os);
+            XMLStreamWriter xmlStreamWriter = createStreamWriter(aegisType.getSchemaType(),
os);
             // use type qname as element qname?
             xmlStreamWriter.writeStartDocument();
             aegisWriter.write(obj, aegisType.getSchemaType(), false, xmlStreamWriter, aegisType);
@@ -86,7 +87,8 @@
         }
     }
     
-    protected XMLStreamWriter createStreamWriter(Class<?> type, OutputStream os) throws
Exception {
+    protected XMLStreamWriter createStreamWriter(QName typeQName, 
+                                                 OutputStream os) throws Exception {
         return StaxUtils.createXMLStreamWriter(os);
     }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisJSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisJSONProvider.java?rev=808501&r1=808500&r2=808501&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisJSONProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisJSONProvider.java
Thu Aug 27 16:32:38 2009
@@ -68,10 +68,11 @@
     }
     
     @Override
-    protected XMLStreamWriter createStreamWriter(Class<?> type, OutputStream os) throws
Exception {
-        QName qname = getQName(type);
-        return JSONUtils.createStreamWriter(os, qname, writeXsiType, namespaceMap, 
-                                                           serializeAsArray, arrayKeys);
+    protected XMLStreamWriter createStreamWriter(QName typeQName, OutputStream os) throws
Exception {
+        namespaceMap.putIfAbsent(typeQName.getNamespaceURI(), "ns1");
+        XMLStreamWriter writer = JSONUtils.createStreamWriter(os, typeQName, writeXsiType,
namespaceMap, 
+                                                              serializeAsArray, arrayKeys);
+        return writer;
     }
     
     @Override

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java?rev=808501&r1=808500&r2=808501&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
Thu Aug 27 16:32:38 2009
@@ -21,11 +21,13 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.XMLConstants;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
@@ -40,6 +42,10 @@
 
 public final class JSONUtils {
 
+    private static final String XSI_PREFIX = "xsi";
+    private static final String XSI_URI = XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+    private static final Charset UTF8 = Charset.forName("utf-8");
+
     private JSONUtils() {
     }
     
@@ -49,13 +55,13 @@
                                                      boolean serializeAsArray,
                                                      List<String> arrayKeys) throws
Exception {
         if (writeXsiType) {
-            namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
+            namespaceMap.put(XSI_URI, XSI_PREFIX);
         }
         Configuration c = new Configuration(namespaceMap);
         MappedNamespaceConvention convention = new MappedNamespaceConvention(c);
         AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
                                             convention, 
-                                            new OutputStreamWriter(os, "UTF-8"));
+                                            new OutputStreamWriter(os, UTF8));
         if (serializeAsArray) {
             if (arrayKeys != null) {
                 for (String key : arrayKeys) {
@@ -80,7 +86,7 @@
     public static XMLStreamReader createStreamReader(InputStream is, boolean readXsiType,
                                                Map<String, String> namespaceMap) throws
Exception {
         if (readXsiType) {
-            namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
+            namespaceMap.put(XSI_URI, XSI_PREFIX);
         }
         MappedXMLInputFactory factory = new MappedXMLInputFactory(namespaceMap);
         return new JettisonReader(namespaceMap, factory.createXMLStreamReader(is));
@@ -98,8 +104,8 @@
         public String getAttributePrefix(int n) {
             QName name = getAttributeName(n);
             if (name != null 
-                && "http://www.w3.org/2001/XMLSchema-instance".equals(name.getNamespaceURI()))
{
-                return "xsi";
+                && XSI_URI.equals(name.getNamespaceURI())) {
+                return XSI_PREFIX;
             } else {
                 return super.getAttributePrefix(n);
             }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java?rev=808501&r1=808500&r2=808501&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java
Thu Aug 27 16:32:38 2009
@@ -132,7 +132,7 @@
         
     }
     
-    @org.junit.Ignore
+   // @org.junit.Ignore
     @Test
     public void testWriteCollection() throws Exception {
         AegisJSONProvider p = new AegisJSONProvider();
@@ -144,14 +144,13 @@
         bean.setStrValue("hovercraft");
         List<AegisTestBean> beans = new ArrayList<AegisTestBean>();
         beans.add(bean);
-        Method m = CollectionsResource.class.getMethod("getAegisBeans", new Class[]{});
-        p.writeTo(beans, (Class)m.getReturnType(), m.getGenericReturnType(), 
-                  AegisTestBean.class.getAnnotations(), 
-                  MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
+        Method m = CollectionsResource.class.getMethod("getAegisBeans", new Class[] {});
+        p.writeTo(beans, (Class)m.getReturnType(), m.getGenericReturnType(), AegisTestBean.class
+            .getAnnotations(), MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String,
Object>(), os);
         byte[] bytes = os.toByteArray();
         String json = new String(bytes, "utf-8");
-        System.out.println(json);
-        //assertEquals(data, json);
+        assertEquals("{\"ns1.ArrayOfAegisTestBean\":{\"ns1.AegisTestBean\":"
+                     + "{\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}}}", json);
     }
     
     @Test



Mime
View raw message