cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1351659 - in /cxf/branches/2.6.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:01:23 GMT
Author: sergeyb
Date: Tue Jun 19 12:01:22 2012
New Revision: 1351659

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

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

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jun 19 12:01:22 2012
@@ -1 +1 @@
-/cxf/trunk:1-1348209,1348845,1348862,1348866,1349016,1349264,1349307,1349406,1349549,1349714-1349717,1349723,1349825,1350114,1350141,1350186,1350215-1350303,1350305,1350318,1350582,1350617,1350633,1350739,1351410,1351418,1351586,1351617,1351626
+/cxf/trunk:1-1348209,1348845,1348862,1348866,1349016,1349264,1349307,1349406,1349549,1349714-1349717,1349723,1349825,1350114,1350141,1350186,1350215-1350303,1350305,1350318,1350582,1350617,1350633,1350739,1351410,1351418,1351586,1351617,1351626,1351657

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1351659&r1=1351658&r2=1351659&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Tue Jun 19 12:01:22 2012
@@ -171,9 +171,12 @@ public class JAXBElementProvider<T> exte
                 || !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.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1351659&r1=1351658&r2=1351659&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Tue Jun 19 12:01:22 2012
@@ -71,6 +71,8 @@ import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 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;
@@ -616,17 +618,15 @@ public class JAXBElementProviderTest ext
     }
     
     @Test
-    @Ignore
-    public void testReadBookJAXBElement() throws Exception {
-        String xml = "<Book><id>123</id><name>CXF in Action</name></Book>";
-        JAXBElementProvider<BookJAXBElement> provider = new JAXBElementProvider<BookJAXBElement>();
-        BookJAXBElement jaxbElement = provider.readFrom(BookJAXBElement.class, BookJAXBElement.class,
+    public void testReadParamJAXBElement() throws Exception {
+        String xml = "<param xmlns=\"http://jaxbelement/10\">"
+            + "<filter name=\"foo\"/><comment>a</comment></param>";
+        JAXBElementProvider<ParamJAXBElement> provider = new JAXBElementProvider<ParamJAXBElement>();
+        ParamJAXBElement jaxbElement = provider.readFrom(ParamJAXBElement.class, ParamJAXBElement.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());
-        
+        ParamType param = jaxbElement.getValue();
+        assertEquals("a", param.getComment());
     }
     
     @Test
@@ -1533,20 +1533,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