cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1039198 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Thu, 25 Nov 2010 22:13:49 GMT
Author: sergeyb
Date: Thu Nov 25 22:13:49 2010
New Revision: 1039198

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

........
  r1039197 | sergeyb | 2010-11-25 22:08:44 +0000 (Thu, 25 Nov 2010) | 1 line
  
  [CXF-3149] Making WebClient.invokeAndGetCollections work better with 3rd party providers
- patch on behalf of Dobes Vandermeer has been applied
........

Added:
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java
      - copied unchanged from r1039197, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.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/client/WebClient.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
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 25 22:13:49 2010
@@ -1 +1 @@
-/cxf/trunk:1038206,1038374,1038386,1038722,1038746,1039039
+/cxf/trunk:1038206,1038374,1038386,1038722,1038746,1039039,1039197

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/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1039198&r1=1039197&r2=1039198&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
Thu Nov 25 22:13:49 2010
@@ -53,6 +53,7 @@ import org.apache.cxf.jaxrs.model.Parame
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ParameterizedCollectionType;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.phase.Phase;
@@ -339,8 +340,8 @@ public class WebClient extends AbstractC
      */
     public <T> Collection<? extends T> invokeAndGetCollection(String httpMethod,
Object body, 
                                                     Class<T> memberClass) {
-        
-        Response r = doInvoke(httpMethod, body, Collection.class, memberClass);
+        Response r = doInvoke(httpMethod, body, Collection.class,
+                              new ParameterizedCollectionType<T>(memberClass));
         
         if (r.getStatus() >= 400) {
             throw new WebApplicationException(r);

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=1039198&r1=1039197&r2=1039198&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
Thu Nov 25 22:13:49 2010
@@ -221,8 +221,8 @@ public class BookStore {
     
     @POST
     @Path("/collections")
-    @Produces("application/xml")
-    @Consumes("application/xml")
+    @Produces({"application/xml", "application/json" })
+    @Consumes({"application/xml", "application/json" })
     public List<Book> getBookCollection(List<Book> bs) throws Exception {
         if (bs == null || bs.size() != 2) {
             throw new RuntimeException();
@@ -230,6 +230,13 @@ public class BookStore {
         return bs;
     }
     
+    @GET
+    @Path("/collections")
+    @Produces({"application/xml", "application/json" })
+    public List<Book> getBookCollection() throws Exception {
+        return new ArrayList<Book>(books.values());
+    }
+    
     @POST
     @Path("/array")
     @Produces("application/xml")

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=1039198&r1=1039197&r2=1039198&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
Thu Nov 25 22:13:49 2010
@@ -64,6 +64,20 @@ public class JAXRSClientServerBookTest e
                    launchServer(BookServer.class));
     }
     
+
+    @Test
+    public void testGetCollectionOfBooks() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/bookstore/collections"; 
+        WebClient wc = WebClient.create(endpointAddress);
+        wc.accept("application/xml");
+        Collection<? extends Book> collection = wc.getCollection(Book.class);
+        assertEquals(1, collection.size());
+        Book book = collection.iterator().next();
+        assertEquals(123L, book.getId());
+    }
+    
     
     @Test
     public void testOnewayWebClient() throws Exception {

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java?rev=1039198&r1=1039197&r2=1039198&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
Thu Nov 25 22:13:49 2010
@@ -26,8 +26,11 @@ import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.Collection;
+import java.util.Collections;
 
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.junit.BeforeClass;
@@ -59,6 +62,20 @@ public class JAXRSClientServerResourceJa
     }
     
     @Test
+    public void testGetCollectionOfBooks() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/webapp/bookstore/collections"; 
+        WebClient wc = WebClient.create(endpointAddress,
+            Collections.singletonList(new org.codehaus.jackson.jaxrs.JacksonJsonProvider()));
+        wc.accept("application/json");
+        Collection<? extends Book> collection = wc.getCollection(Book.class);
+        assertEquals(1, collection.size());
+        Book book = collection.iterator().next();
+        assertEquals(123L, book.getId());
+    }
+    
+    @Test
     public void testPostPetStatus() throws Exception {
         
         String endpointAddress =



Mime
View raw message