cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1300560 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Wed, 14 Mar 2012 14:27:35 GMT
Author: sergeyb
Date: Wed Mar 14 14:27:34 2012
New Revision: 1300560

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

........
  r1300555 | sergeyb | 2012-03-14 14:22:09 +0000 (Wed, 14 Mar 2012) | 1 line
  
  Adding a typed version of the method posting the object and getting the collection to WebClient
........

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/client/WebClient.java
    cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 14 14:27:34 2012
@@ -1 +1 @@
-/cxf/trunk:1236902,1297296,1298470,1298601-1298624,1298830,1298832,1299086,1299635,1299682,1299707,1299747,1299900-1300084,1300342,1300509,1300518,1300523,1300530,1300541
+/cxf/trunk:1236902,1297296,1298470,1298601-1298624,1298830,1298832,1299086,1299635,1299682,1299707,1299747,1299900-1300084,1300342,1300509,1300518,1300523,1300530,1300541,1300555

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/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1300560&r1=1300559&r2=1300560&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
Wed Mar 14 14:27:34 2012
@@ -389,6 +389,20 @@ public class WebClient extends AbstractC
                               Collection.class, new ParameterizedCollectionType<T2>(responseClass));
         return CastUtils.cast((Collection)r.getEntity(), responseClass);
     }
+    
+    /**
+     * Posts the object and returns a collection of typed objects
+     * @param body request body
+     * @param memberClass type of collection member class
+     * @param responseClass expected type of response object
+     * @return JAX-RS Response
+     */
+    public <T> Collection<? extends T> postObjectGetCollection(Object body, 
+                                                                  Class<T> responseClass)
{
+        Response r = doInvoke("POST", body, null, Collection.class, 
+                              new ParameterizedCollectionType<T>(responseClass));
+        return CastUtils.cast((Collection<?>)r.getEntity(), responseClass);
+    }
         
     /**
      * Posts request body and returns a collection of typed objects 

Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1300560&r1=1300559&r2=1300560&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Wed Mar 14 14:27:34 2012
@@ -314,6 +314,16 @@ public class BookStore {
     }
     
     @POST
+    @Path("/collectionBook")
+    @Produces({"application/xml", "application/json" })
+    @Consumes({"application/xml", "application/json" })
+    public List<Book> postBookGetCollection(Book book) throws Exception {
+        List<Book> list = new ArrayList<Book>();
+        list.add(book);
+        return list;
+    }
+    
+    @POST
     @Path("/collections3")
     @Produces({"application/xml", "application/json" })
     @Consumes({"application/xml", "application/json" })

Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1300560&r1=1300559&r2=1300560&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Wed Mar 14 14:27:34 2012
@@ -249,6 +249,22 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testPostObjectGetCollection() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/bookstore/collectionBook"; 
+        WebClient wc = WebClient.create(endpointAddress);
+        wc.accept("application/xml").type("application/xml");
+        Book b1 = new Book("Book", 666L);
+        List<Book> books = new ArrayList<Book>(wc.postObjectGetCollection(b1,
Book.class));
+        assertNotNull(books);
+        assertEquals(1, books.size());
+        Book b = books.get(0);
+        assertEquals(666L, b.getId());
+        assertEquals("Book", b.getName());
+    }
+    
+    @Test
     public void testGetBookResponseAndETag() throws Exception {
         
         String endpointAddress =



Mime
View raw message