cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1351663 - in /cxf/branches/2.5.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:06:59 GMT
Author: sergeyb
Date: Tue Jun 19 12:06:58 2012
New Revision: 1351663

URL: http://svn.apache.org/viewvc?rev=1351663&view=rev
Log:
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.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/
      - copied from r1351659, cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java
      - copied unchanged from r1351659, cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ObjectFactory.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java
      - copied unchanged from r1351659, cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamJAXBElement.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java
      - copied unchanged from r1351659, cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/ParamType.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/package-info.java
      - copied unchanged from r1351659, cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/jaxb/jaxbelement/package-info.java
Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1351657
  Merged /cxf/branches/2.6.x-fixes:r1351659

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

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1351663&r1=1351662&r2=1351663&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Tue Jun 19 12:06:58 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);
             }

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1351663&r1=1351662&r2=1351663&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Tue Jun 19 12:06:58 2012
@@ -70,6 +70,8 @@ import org.xml.sax.ContentHandler;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.ext.MessageContextImpl;
 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;
@@ -619,18 +621,17 @@ public class JAXBElementProviderTest ext
     }
     
     @Test
-    @Ignore
     @SuppressWarnings("unchecked")
-    public void testReadBookJAXBElement() throws Exception {
-        String xml = "<Book><id>123</id><name>CXF in Action</name></Book>";
-        JAXBElementProvider provider = new JAXBElementProvider();
-        BookJAXBElement jaxbElement = (BookJAXBElement)provider.readFrom((Class)BookJAXBElement.class,
-            BookJAXBElement.class, new Annotation[0], MediaType.TEXT_XML_TYPE, 
-            new MetadataMap<String, String>(), new ByteArrayInputStream(xml.getBytes("UTF-8")));
-        Book book = jaxbElement.getValue();
-        assertEquals(123L, book.getId());
-        assertEquals("CXF in Action", book.getName());
-        
+    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
@@ -1539,20 +1540,6 @@ public class JAXBElementProviderTest ext
         }
     }
     
-    public static class BookJAXBElement extends JAXBElement<Book> {
-        protected static final QName NAME = new QName("Book");
-
-        private static final long serialVersionUID = -7388721095437704766L;
-        
-        public BookJAXBElement(Book value) {
-            super(NAME, Book.class, null, value);
-        }
-
-        public BookJAXBElement() {
-            super(NAME, Book.class, null, null);
-        }
-    }
-    
     private Message createMessage() {
         ProviderFactory factory = ProviderFactory.getInstance();
         Message m = new MessageImpl();



Mime
View raw message