cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1351667 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/p...
Date Tue, 19 Jun 2012 12:18:52 GMT
Author: sergeyb
Date: Tue Jun 19 12:18:52 2012
New Revision: 1351667

URL: http://svn.apache.org/viewvc?rev=1351667&view=rev
Log:
Merged revisions 1351663 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

................
  r1351663 | sergeyb | 2012-06-19 13:06:58 +0100 (Tue, 19 Jun 2012) | 16 lines
  
  Merged revisions 1351659 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
  
  ................
    r1351659 | sergeyb | 2012-06-19 13:01:22 +0100 (Tue, 19 Jun 2012) | 9 lines
    
    Merged revisions 1351657 via svnmerge from 
    https://svn.apache.org/repos/asf/cxf/trunk
    
    ........
      r1351657 | sergeyb | 2012-06-19 12:57:21 +0100 (Tue, 19 Jun 2012) | 1 line
      
      [CXF-4380] Support for reading custom JAXBElements
    ........
  ................
................

Added:
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/
      - copied from r1351663, cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java
      - copied, changed from r1351663, cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java
      - copied, changed from r1351663, cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java
      - copied, changed from r1351663, cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/package-info.java
      - copied unchanged from r1351663, cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/package-info.java
Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Jun 19 12:18:52 2012
@@ -0,0 +1,3 @@
+/cxf/branches/2.5.x-fixes:1351663
+/cxf/branches/2.6.x-fixes:1351659
+/cxf/trunk:1351657

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

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1351667&r1=1351666&r2=1351667&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Tue Jun 19 12:18:52 2012
@@ -169,9 +169,12 @@ public class JAXBElementProvider extends
                 || !isCollection && (unmarshalAsJaxbElement  
                 || jaxbElementClassMap != null && jaxbElementClassMap.containsKey(theType.getName())))
{
                 XMLStreamReader reader = getStreamReader(is, type, mt);
-                response = unmarshaller.unmarshal(
-                     TransformUtils.createNewReaderIfNeeded(reader, is), 
-                     theType);
+                reader = TransformUtils.createNewReaderIfNeeded(reader, is);
+                if (JAXBElement.class.isAssignableFrom(type) && type == theType)
{
+                    response = unmarshaller.unmarshal(reader);
+                } else {
+                    response = unmarshaller.unmarshal(reader, theType);
+                }
             } else {
                 response = doUnmarshal(unmarshaller, type, is, mt);
             }

Copied: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java
(from r1351663, cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java?p2=cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java&p1=cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java&r1=1351663&r2=1351667&rev=1351667&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java
Tue Jun 19 12:18:52 2012
@@ -47,6 +47,6 @@ public class ObjectFactory {
     public JAXBElement<String> createRevocationRemark(String value) {
         return new JAXBElement<String>(_ParamJAXBElement_QNAME, String.class, null,
value);
     }
-
+//CHECKSTYLE:ON
 }
-//CHECKSTYLE:ON
\ No newline at end of file
+

Copied: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java
(from r1351663, cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java?p2=cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java&p1=cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java&r1=1351663&r2=1351667&rev=1351667&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java
Tue Jun 19 12:18:52 2012
@@ -37,6 +37,6 @@ public class ParamJAXBElement extends JA
     public ParamJAXBElement() {
         super(NAME, ((Class) ParamType.class), null, null);
     }
-
+//CHECKSTYLE:ON
 }
-//CHECKSTYLE:ON
\ No newline at end of file
+

Copied: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java
(from r1351663, cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java?p2=cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java&p1=cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java&r1=1351663&r2=1351667&rev=1351667&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java
Tue Jun 19 12:18:52 2012
@@ -42,6 +42,5 @@ public class ParamType implements Serial
     public void setComment(String value) {
         this.comment = value;
     }
-
+//CHECKSTYLE:ON
 }
-//CHECKSTYLE:ON
\ No newline at end of file

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1351667&r1=1351666&r2=1351667&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Tue Jun 19 12:18:52 2012
@@ -67,6 +67,8 @@ import org.w3c.dom.Node;
 import org.xml.sax.ContentHandler;
 
 import org.apache.cxf.jaxrs.ext.xml.XMLSource;
+import org.apache.cxf.jaxrs.fortest.jaxb.jaxbelement.ParamJAXBElement;
+import org.apache.cxf.jaxrs.fortest.jaxb.jaxbelement.ParamType;
 import org.apache.cxf.jaxrs.fortest.jaxb.packageinfo.Book2;
 import org.apache.cxf.jaxrs.fortest.jaxb.packageinfo.Book2NoRootElement;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
@@ -587,6 +589,33 @@ public class JAXBElementProviderTest ext
     }
     
     @Test
+    public void testReadJAXBElement() throws Exception {
+        String xml = "<Book><id>123</id><name>CXF in Action</name></Book>";
+        JAXBElementProvider provider = new JAXBElementProvider();
+        JAXBElement jaxbElement = (JAXBElement)provider.readFrom((Class)JAXBElement.class,
Book.class,
+             new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String, String>(),
+             new ByteArrayInputStream(xml.getBytes("UTF-8")));
+        Book book = (Book)jaxbElement.getValue();
+        assertEquals(123L, book.getId());
+        assertEquals("CXF in Action", book.getName());
+        
+    }
+    
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testReadParamJAXBElement() throws Exception {
+        String xml = "<param xmlns=\"http://jaxbelement/10\">"
+            + "<filter name=\"foo\"/><comment>a</comment></param>";
+        JAXBElementProvider provider = new JAXBElementProvider();
+        ParamJAXBElement jaxbElement = (ParamJAXBElement)provider.readFrom((Class)ParamJAXBElement.class,
+            ParamJAXBElement.class,
+            new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String, String>(),
+            new ByteArrayInputStream(xml.getBytes("UTF-8")));
+        ParamType param = (ParamType)jaxbElement.getValue();
+        assertEquals("a", param.getComment());
+    }
+    
+    @Test
     public void testWriteQualifiedCollection() throws Exception {
         JAXBElementProvider provider = new JAXBElementProvider();
         provider.setCollectionWrapperName("{http://tags}tags");
@@ -1488,4 +1517,5 @@ public class JAXBElementProviderTest ext
             return null;
         }
     }
+
 }



Mime
View raw message