You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2012/03/14 15:32:37 UTC
svn commit: r1300561 - in /cxf/branches/2.4.x-fixes: ./
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Author: sergeyb
Date: Wed Mar 14 14:32:37 2012
New Revision: 1300561
URL: http://svn.apache.org/viewvc?rev=1300561&view=rev
Log:
Merged revisions 1300560 via svnmerge from
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes
................
r1300560 | sergeyb | 2012-03-14 14:27:34 +0000 (Wed, 14 Mar 2012) | 9 lines
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.4.x-fixes/ (props changed)
cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 14 14:32:37 2012
@@ -1,2 +1,2 @@
-/cxf/branches/2.5.x-fixes:1299092,1299637,1299725,1300270,1300343,1300407-1300533,1300536
-/cxf/trunk:1298470,1298830,1298832,1299086,1299635,1299682,1299747,1300342,1300518,1300530
+/cxf/branches/2.5.x-fixes:1299092,1299637,1299725,1300270,1300343,1300407-1300533,1300536,1300560
+/cxf/trunk:1298470,1298830,1298832,1299086,1299635,1299682,1299747,1300342,1300518,1300530,1300555
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1300561&r1=1300560&r2=1300561&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Wed Mar 14 14:32:37 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.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1300561&r1=1300560&r2=1300561&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Wed Mar 14 14:32:37 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.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1300561&r1=1300560&r2=1300561&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Wed Mar 14 14:32:37 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 =