cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r806142 - 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, 20 Aug 2009 12:30:37 GMT
Author: sergeyb
Date: Thu Aug 20 12:30:36 2009
New Revision: 806142

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

........
  r803056 | sergeyb | 2009-08-11 11:23:15 +0100 (Tue, 11 Aug 2009) | 1 line
  
  JAXRS : adding DataBindingJSONProvider
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProvider.java
      - copied unchanged from r803056, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONUtils.java
      - copied unchanged from r803056, cxf/trunk/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/DataBindingJSONProviderTest.java
      - copied, changed from r803056, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
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/AbstractJAXBProvider.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/DataBindingProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.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 20 12:30:36 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,803129,803460,803493,803689,804002,804276,805784,805907,805909
+/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,803460,803493,803689,804002,804276,805784,805907,805909

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/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=806142&r1=806141&r2=806142&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Thu Aug 20 12:30:36 2009
@@ -143,7 +143,7 @@
             }
         }
         
-        return isSupported(type, genericType, anns);
+        return unmarshalAsJaxbElement || isSupported(type, genericType, anns);
     }
     
     protected JAXBContext getCollectionContext(Class<?> type) throws JAXBException
{
@@ -329,6 +329,9 @@
     }
     
     protected boolean isSupported(Class<?> type, Type genericType, Annotation[] anns)
{
+        if (jaxbElementClassMap != null && jaxbElementClassMap.containsKey(type.getName()))
{
+            return true;
+        }
         return type.getAnnotation(XmlRootElement.class) != null
             || JAXBElement.class.isAssignableFrom(type)
             || objectFactoryForClass(type)

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=806142&r1=806141&r2=806142&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 20 12:30:36 2009
@@ -22,11 +22,8 @@
 
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.OutputStreamWriter;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -35,18 +32,11 @@
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.Provider;
-import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.staxutils.DepthXMLStreamReader;
-import org.codehaus.jettison.AbstractXMLStreamWriter;
-import org.codehaus.jettison.mapped.Configuration;
-import org.codehaus.jettison.mapped.MappedNamespaceConvention;
-import org.codehaus.jettison.mapped.MappedXMLInputFactory;
-import org.codehaus.jettison.mapped.MappedXMLStreamWriter;
 
 @Provider
 @Produces({"application/json" })
@@ -70,7 +60,7 @@
     
     @Override
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
-        return false;
+        return true;
     }
     
     public void setNamespaceMap(Map<String, String> nsMap) {
@@ -80,35 +70,14 @@
     @Override
     protected XMLStreamWriter createStreamWriter(Class<?> type, OutputStream os) throws
Exception {
         QName qname = getQName(type);
-        if (writeXsiType) {
-            namespaceMap.putIfAbsent("http://www.w3.org/2001/XMLSchema-instance", "xsins");
-        }
-        Configuration c = new Configuration(namespaceMap);
-        MappedNamespaceConvention convention = new MappedNamespaceConvention(c);
-        AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
-                                            convention, 
-                                            new OutputStreamWriter(os, "UTF-8"));
-        if (serializeAsArray) {
-            if (arrayKeys != null) {
-                for (String key : arrayKeys) {
-                    xsw.seriliazeAsArray(key);
-                }
-            } else {
-                String key = getKey(convention, qname);
-                xsw.seriliazeAsArray(key);
-            }
-        }
-        return xsw;
+        return JSONUtils.createStreamWriter(os, qname, writeXsiType, namespaceMap, 
+                                                           serializeAsArray, arrayKeys);
     }
     
     @Override
     protected XMLStreamReader createStreamReader(Class<?> type, InputStream is) throws
Exception {
-        if (readXsiType) {
-            namespaceMap.putIfAbsent("http://www.w3.org/2001/XMLSchema-instance", "xsins");
-        }
         getQName(type);
-        MappedXMLInputFactory factory = new MappedXMLInputFactory(namespaceMap);
-        return new NamespaceContextReader(factory.createXMLStreamReader(is));
+        return JSONUtils.createStreamReader(is, readXsiType, namespaceMap);
     }
     
     private QName getQName(Class<?> type) {
@@ -116,42 +85,4 @@
         namespaceMap.putIfAbsent(qname.getNamespaceURI(), "ns1");
         return qname;
     }
-    
-    private String getKey(MappedNamespaceConvention convention, QName qname) throws Exception
{
-        return convention.createKey(qname.getPrefix(), 
-                                    qname.getNamespaceURI(),
-                                    qname.getLocalPart());
-    }
-    
-    private class NamespaceContextReader extends DepthXMLStreamReader {
-        public NamespaceContextReader(XMLStreamReader reader) {
-            super(reader);
-        }
-        
-        @Override
-        public NamespaceContext getNamespaceContext() {
-            return new NamespaceContext() {
-
-                public String getNamespaceURI(String prefix) {
-                    for (Map.Entry<String, String> entry : namespaceMap.entrySet())
{
-                        if (entry.getValue().equals(prefix)) {
-                            return entry.getKey();
-                        }
-                    }
-                    return null;
-                }
-
-                public String getPrefix(String ns) {
-                    return namespaceMap.get(ns);
-                }
-
-                public Iterator getPrefixes(String ns) {
-                    String prefix = getPrefix(ns);
-                    return prefix == null ? null : Collections.singletonList(prefix).iterator();
-                }
-                
-            };
-        }
-    }
-    
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java?rev=806142&r1=806141&r2=806142&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
Thu Aug 20 12:30:36 2009
@@ -26,6 +26,7 @@
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -64,12 +65,16 @@
     public Object readFrom(Class<Object> clazz, Type genericType, Annotation[] annotations,
MediaType type, 
                        MultivaluedMap<String, String> headers, InputStream is)
         throws IOException {
-        XMLStreamReader reader = createReader(clazz, is);
-        DataReader<XMLStreamReader> dataReader = binding.createReader(XMLStreamReader.class);
-        return dataReader.read(null, reader, clazz);
+        try {
+            XMLStreamReader reader = createReader(clazz, is);
+            DataReader<XMLStreamReader> dataReader = binding.createReader(XMLStreamReader.class);
+            return dataReader.read(null, reader, clazz);
+        } catch (Exception ex) {
+            throw new WebApplicationException(ex);
+        }
     }
 
-    protected XMLStreamReader createReader(Class<?> clazz, InputStream is) {
+    protected XMLStreamReader createReader(Class<?> clazz, InputStream is) throws Exception
{
         return StaxUtils.createXMLStreamReader(is);
     }
     
@@ -87,20 +92,22 @@
     public void writeTo(Object o, Class<?> clazz, Type genericType, Annotation[] annotations,

                         MediaType type, MultivaluedMap<String, Object> headers, OutputStream
os)
         throws IOException {
-        XMLStreamWriter writer = createWriter(clazz, os);
-        DataWriter<XMLStreamWriter> dataWriter = binding.createWriter(XMLStreamWriter.class);
-        
-        dataWriter.write(o, writer);
         try {
-            writer.flush();
+            XMLStreamWriter writer = createWriter(clazz, os);
+            writeToWriter(writer, o);
         } catch (Exception ex) {
-            // ignore
+            throw new WebApplicationException(ex);
         }
     }
     
-    protected XMLStreamWriter createWriter(Class<?> clazz, OutputStream os) {
-        return StaxUtils.createXMLStreamWriter(os);
+    protected void writeToWriter(XMLStreamWriter writer, Object o) throws Exception {
+        DataWriter<XMLStreamWriter> dataWriter = binding.createWriter(XMLStreamWriter.class);
+        dataWriter.write(o, writer);
+        writer.flush();
     }
     
+    protected XMLStreamWriter createWriter(Class<?> clazz, 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/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=806142&r1=806141&r2=806142&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
Thu Aug 20 12:30:36 2009
@@ -24,7 +24,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.OutputStreamWriter;
 import java.io.SequenceInputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
@@ -57,11 +56,7 @@
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
 import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
-import org.codehaus.jettison.AbstractXMLStreamWriter;
-import org.codehaus.jettison.mapped.Configuration;
-import org.codehaus.jettison.mapped.MappedNamespaceConvention;
 import org.codehaus.jettison.mapped.MappedXMLInputFactory;
-import org.codehaus.jettison.mapped.MappedXMLStreamWriter;
 
 @Produces("application/json")
 @Consumes("application/json")
@@ -314,22 +309,9 @@
     protected XMLStreamWriter createWriter(Object actualObject, Class<?> actualClass,

         Type genericType, String enc, OutputStream os, boolean isCollection) throws Exception
{
         QName qname = getQName(actualClass, genericType, actualObject, true);
-        Configuration c = new Configuration(namespaceMap);
-        MappedNamespaceConvention convention = new MappedNamespaceConvention(c);
-        AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
-                                            convention, 
-                                            new OutputStreamWriter(os, enc));
-        if (serializeAsArray) {
-            if (arrayKeys != null) {
-                for (String key : arrayKeys) {
-                    xsw.seriliazeAsArray(key);
-                }
-            } else {
-                String key = getKey(convention, qname);
-                xsw.seriliazeAsArray(key);
-            }
-        }
-
+        XMLStreamWriter xsw = JSONUtils.createStreamWriter(os, qname, false, 
+                                                           namespaceMap, serializeAsArray,
arrayKeys);
+        
         return isCollection || dropRootElement ? new JSONCollectionWriter(xsw, qname) : xsw;

     }
     
@@ -345,14 +327,6 @@
         marshal(ms, actualObject, actualClass, genericType, enc, os, false);
     }
     
-    private String getKey(MappedNamespaceConvention convention, QName qname) throws Exception
{
-        return convention.createKey(qname.getPrefix(), 
-                                    qname.getNamespaceURI(),
-                                    qname.getLocalPart());
-            
-        
-    }
-    
     private QName getQName(Class<?> cls, Type type, Object object, boolean allocatePrefix)

         throws Exception {
         QName qname = getJaxbQName(cls, type, object, false);

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=806142&r1=806141&r2=806142&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 20 12:30:36 2009
@@ -48,7 +48,7 @@
     @Test
     public void testIsReadable() {
         MessageBodyReader<Object> p = new AegisJSONProvider();
-        assertFalse(p.isReadable(AegisTestBean.class, null, null, null));
+        assertTrue(p.isReadable(AegisTestBean.class, null, null, null));
     }
     
     
@@ -69,10 +69,10 @@
         if (setNsMap) {
             Map<String, String> namespaceMap = new HashMap<String, String>();
             namespaceMap.put("http://fortest.jaxrs.cxf.apache.org", "ns1");
-            namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsins");
+            namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
             p.setNamespaceMap(namespaceMap);
         }
-        String data = "{\"ns1.AegisTestBean\":{\"@xsins.type\":\"ns1:AegisTestBean\","
+        String data = "{\"ns1.AegisTestBean\":{\"@xsi.type\":\"ns1:AegisTestBean\","
             + "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}}";
         
         byte[] simpleBytes = data.getBytes("utf-8");
@@ -85,14 +85,14 @@
     
     @Test
     public void testWriteToWithXsiType() throws Exception {
-        String data = "{\"ns1.AegisTestBean\":{\"@ns2.type\":\"ns1:AegisTestBean\","
+        String data = "{\"ns1.AegisTestBean\":{\"@xsi.type\":\"ns1:AegisTestBean\","
             + "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}}";
         doTestWriteTo(data, true, true);
     }
     
     @Test
     public void testWriteToWithXsiTypeNoNamespaces() throws Exception {
-        String data = "{\"ns1.AegisTestBean\":{\"@xsins.type\":\"ns1:AegisTestBean\","
+        String data = "{\"ns1.AegisTestBean\":{\"@xsi.type\":\"ns1:AegisTestBean\","
             + "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}}";
         doTestWriteTo(data, true, false);
     }
@@ -112,7 +112,7 @@
         if (setNsMap) {
             Map<String, String> namespaceMap = new HashMap<String, String>();
             namespaceMap.put("http://fortest.jaxrs.cxf.apache.org", "ns1");
-            namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "ns2");
+            namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
             p.setNamespaceMap(namespaceMap);
         }    
         ByteArrayOutputStream os = new ByteArrayOutputStream();

Copied: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
(from r803056, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java?p2=cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java&p1=cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java&r1=803056&r2=806142&rev=806142&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
Thu Aug 20 12:30:36 2009
@@ -25,7 +25,6 @@
 import java.lang.annotation.Annotation;
 import java.util.Collections;
 
-import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -38,10 +37,7 @@
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.resources.Book;
-import org.apache.cxf.jaxrs.resources.sdo.Structure;
-import org.apache.cxf.jaxrs.resources.sdo.impl.StructureImpl;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
-import org.apache.cxf.sdo.SDODataBinding;
 import org.apache.cxf.service.Service;
 
 import org.junit.Assert;
@@ -52,55 +48,12 @@
 public class DataBindingJSONProviderTest extends Assert {
 
     private ClassResourceInfo c;
-    private ClassResourceInfo c2;
     
     @Before
     public void setUp() {
         c = ResourceUtils.createClassResourceInfo(TheBooks.class, TheBooks.class, true, true);
-        c2 = ResourceUtils.createClassResourceInfo(TheSDOBooks.class, TheSDOBooks.class,
true, true);
     }
     
-    @SuppressWarnings("unchecked")
-    @Test
-    public void testSDOWrite() throws Exception {
-        Service s = new JAXRSServiceImpl(Collections.singletonList(c2));
-        DataBinding binding = new SDODataBinding();
-        binding.initialize(s);
-        DataBindingJSONProvider p = new DataBindingJSONProvider();
-        p.setDataBinding(binding);
-        p.setNamespaceMap(Collections.singletonMap("http://apache.org/structure/types", "p0"));
-        Structure struct = new StructureImpl();
-        struct.getTexts().add("text1");
-        struct.setText("sdo");
-        struct.setInt(3);
-        struct.setDbl(123.5);
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        p.writeTo(struct, Structure.class, Structure.class,
-            new Annotation[0], MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String,
Object>(), bos);
-        String data = "{\"p0.Structure\":{\"@xsi.type\":\"p0:Structure\",\"p0.text\":\"sdo\",\"p0.int\":3"
-            + ",\"p0.dbl\":123.5,\"p0.texts\":\"text1\"}}";
-        assertEquals(bos.toString(), data);
-    }
-    
-    @SuppressWarnings("unchecked")
-    @Test
-    public void testSDORead() throws Exception {
-        String data = "{\"p0.Structure\":{\"@xsi.type\":\"p0:Structure\",\"p0.text\":\"sdo\",\"p0.int\":3"
-            + ",\"p0.dbl\":123.5,\"p0.texts\":\"text1\"}}";
-        Service s = new JAXRSServiceImpl(Collections.singletonList(c2));
-        DataBinding binding = new SDODataBinding();
-        binding.initialize(s);
-        DataBindingJSONProvider p = new DataBindingJSONProvider();
-        p.setDataBinding(binding);
-        p.setNamespaceMap(Collections.singletonMap("http://apache.org/structure/types", "p0"));
-        ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
-        Structure struct = (Structure)p.readFrom((Class)Structure.class, Structure.class,
-                                      new Annotation[0], MediaType.APPLICATION_JSON_TYPE,

-                                      new MetadataMap<String, String>(), is);
-        assertEquals("sdo", struct.getText());
-        assertEquals(123.5, struct.getDbl(), 0.01);
-        assertEquals(3, struct.getInt());
-    }
     
     @Test
     public void testJAXBWrite() throws Exception {
@@ -196,15 +149,4 @@
         }
     }
     
-    @Path("/")
-    @Ignore
-    public static class TheSDOBooks {
-
-        @GET
-        @Path("/books/{bookId}/{new}")
-        public Structure getStructure() {
-            return null;
-        }
-        
-    }
 }



Mime
View raw message