cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1103909 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Mon, 16 May 2011 21:31:42 GMT
Author: sergeyb
Date: Mon May 16 21:31:41 2011
New Revision: 1103909

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

........
  r1103904 | sergeyb | 2011-05-16 22:28:29 +0100 (Mon, 16 May 2011) | 1 line
  
  [CXF-3525] Fixing JAXB provider for explicit collections of JAXB unqualified beans be read
........

Added:
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookNoXmlRootElement.java
      - copied unchanged from r1103904, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookNoXmlRootElement.java
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 21:31:41 2011
@@ -1 +1 @@
-/cxf/trunk:1099767,1100898,1101399,1102198
+/cxf/trunk:1099767,1100898,1101399,1102198,1103904

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

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1103909&r1=1103908&r2=1103909&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Mon May 16 21:31:41 2011
@@ -136,8 +136,8 @@ public class JAXBElementProvider extends
             addAttachmentUnmarshaller(unmarshaller);
             Object response = null;
             if (JAXBElement.class.isAssignableFrom(type) 
-                || unmarshalAsJaxbElement 
-                || jaxbElementClassMap != null && jaxbElementClassMap.containsKey(theType.getName()))
{
+                || !isCollection && (unmarshalAsJaxbElement  
+                || jaxbElementClassMap != null && jaxbElementClassMap.containsKey(theType.getName())))
{
                 XMLStreamReader reader = getStreamReader(is, type, mt);
                 response = unmarshaller.unmarshal(
                      createNewReaderIfNeeded(reader, is), 

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java?rev=1103909&r1=1103908&r2=1103909&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
Mon May 16 21:31:41 2011
@@ -21,12 +21,15 @@ package org.apache.cxf.systest.jaxrs;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.provider.BinaryDataProvider;
+import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
     
@@ -43,8 +46,13 @@ public class BookServer extends Abstract
         BinaryDataProvider p = new BinaryDataProvider();
         p.setProduceMediaTypes(Collections.singletonList("application/bar"));
         p.setEnableBuffering(true);
-        
         providers.add(p);
+        JAXBElementProvider jaxbProvider = new JAXBElementProvider();
+        Map<String, String> jaxbElementClassMap = new HashMap<String, String>();

+        jaxbElementClassMap.put(BookNoXmlRootElement.class.getName(), "BookNoXmlRootElement");
+        jaxbProvider.setJaxbElementClassMap(jaxbElementClassMap);
+        providers.add(jaxbProvider);
+        
         providers.add(new GenericHandlerWriter());
         providers.add(new FaultyRequestHandler());
         sf.setProviders(providers);

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1103909&r1=1103908&r2=1103909&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Mon May 16 21:31:41 2011
@@ -265,6 +265,17 @@ public class BookStore {
         return bs;
     }
     
+    @POST
+    @Path("/collections2")
+    @Produces({"application/xml", "application/json" })
+    @Consumes({"application/xml", "application/json" })
+    public List<BookNoXmlRootElement> getBookCollection2(List<BookNoXmlRootElement>
bs) throws Exception {
+        if (bs == null || bs.size() != 2) {
+            throw new RuntimeException();
+        }
+        return bs;
+    }
+    
     @GET
     @Path("/collections")
     @Produces({"application/xml", "application/json" })

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1103909&r1=1103908&r2=1103909&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon May 16 21:31:41 2011
@@ -66,7 +66,7 @@ public class JAXRSClientServerBookTest e
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly",
-                   launchServer(BookServer.class));
+                   launchServer(BookServer.class, true));
     }
     
     @Test
@@ -373,6 +373,32 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test 
+    public void testGetBookCollection2() throws Exception {
+        JAXBElementProvider provider = new JAXBElementProvider();
+        provider.setMarshallAsJaxbElement(true);
+        provider.setUnmarshallAsJaxbElement(true);
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT,
+                                                    BookStore.class,
+                                                    Collections.singletonList(provider));
+        BookNoXmlRootElement b1 = new BookNoXmlRootElement("CXF in Action", 123L);
+        BookNoXmlRootElement b2 = new BookNoXmlRootElement("CXF Rocks", 124L);
+        List<BookNoXmlRootElement> books = new ArrayList<BookNoXmlRootElement>();
+        books.add(b1);
+        books.add(b2);
+        WebClient.getConfig(store).getHttpConduit().getClient().setReceiveTimeout(10000000L);
+        List<BookNoXmlRootElement> books2 = store.getBookCollection2(books);
+        assertNotNull(books2);
+        assertNotSame(books, books2);
+        assertEquals(2, books2.size());
+        BookNoXmlRootElement b11 = books.get(0);
+        assertEquals(123L, b11.getId());
+        assertEquals("CXF in Action", b11.getName());
+        BookNoXmlRootElement b22 = books.get(1);
+        assertEquals(124L, b22.getId());
+        assertEquals("CXF Rocks", b22.getName());
+    }
+    
+    @Test 
     public void testGetBookArray() throws Exception {
         BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
         Book b1 = new Book("CXF in Action", 123L);



Mime
View raw message