Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 47B4710011 for ; Mon, 22 Jul 2013 14:43:08 +0000 (UTC) Received: (qmail 92297 invoked by uid 500); 22 Jul 2013 14:43:07 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 92176 invoked by uid 500); 22 Jul 2013 14:43:07 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 92169 invoked by uid 99); 22 Jul 2013 14:43:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jul 2013 14:43:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jul 2013 14:43:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4DDE923888E4; Mon, 22 Jul 2013 14:42:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1505696 - in /cxf/branches/2.6.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/ Date: Mon, 22 Jul 2013 14:42:45 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130722144245.4DDE923888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sergeyb Date: Mon Jul 22 14:42:44 2013 New Revision: 1505696 URL: http://svn.apache.org/r1505696 Log: Merged revisions 1505692 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes ................ r1505692 | sergeyb | 2013-07-22 15:39:12 +0100 (Mon, 22 Jul 2013) | 9 lines Merged revisions 1505686 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1505686 | sergeyb | 2013-07-22 14:59:19 +0100 (Mon, 22 Jul 2013) | 1 line [CXF-5146] Updating RS proxy code to unwrap TypeVariables ........ ................ 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/client/ClientProxyImpl.java cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/branches/2.7.x-fixes:r1505692 Merged /cxf/trunk:r1505686 Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1505696&r1=1505695&r2=1505696&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java Mon Jul 22 14:42:44 2013 @@ -24,6 +24,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -578,9 +579,18 @@ public class ClientProxyImpl extends Abs && ((InputStream)r.getEntity()).available() == 0)) { return r; } + + Type genericType = method.getGenericReturnType(); + if (genericType instanceof TypeVariable) { + genericType = InjectionUtils.getSuperType(method.getDeclaringClass(), + (TypeVariable)genericType); + } - return readBody(r, outMessage, method.getReturnType(), - method.getGenericReturnType(), method.getDeclaredAnnotations()); + return readBody(r, + outMessage, + method.getReturnType(), + genericType, + method.getDeclaredAnnotations()); } finally { ProviderFactory.getInstance(outMessage).clearThreadLocalProxies(); } Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java?rev=1505696&r1=1505695&r2=1505696&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java (original) +++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java Mon Jul 22 14:42:44 2013 @@ -29,7 +29,11 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.xml.bind.annotation.XmlRootElement; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.As; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +@JsonTypeInfo(use = Id.CLASS, include = As.PROPERTY, property = "class") @XmlRootElement(name = "Book") public class Book { private String name; Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java?rev=1505696&r1=1505695&r2=1505696&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java (original) +++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java Mon Jul 22 14:42:44 2013 @@ -87,6 +87,25 @@ public class BookStoreSpring { return new SuperBook("SuperBook", 999L); } + @SuppressWarnings("unchecked") + @GET + @Path("/books/superbook") + @Produces("application/json") + public T getSuperBookJson() { + SuperBook book = new SuperBook("SuperBook", 999L); + + return (T)book; + } + + @SuppressWarnings("unchecked") + @POST + @Path("/books/superbook") + @Consumes("application/json") + @Produces("application/json") + public T echoSuperBookJson(T book) { + return (T)(SuperBook)book; + } + @POST @Path("/books/xsitype") @Produces("application/xml") Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java?rev=1505696&r1=1505695&r2=1505696&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java (original) +++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java Mon Jul 22 14:42:44 2013 @@ -28,6 +28,7 @@ import java.util.Collections; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; import org.apache.cxf.helpers.IOUtils; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.cxf.jaxrs.model.AbstractResourceInfo; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; @@ -50,7 +51,7 @@ public class JAXRSClientServerResourceJa public void testGetBook123() throws Exception { String endpointAddress = - "http://localhost:" + PORT + "/webapp/bookstore/books/123"; + "http://localhost:" + PORT + "/webapp/store1/bookstore/books/123"; URL url = new URL(endpointAddress); URLConnection connect = url.openConnection(); connect.addRequestProperty("Accept", "application/json"); @@ -58,15 +59,37 @@ public class JAXRSClientServerResourceJa assertNotNull(in); assertEquals("Jackson output not correct", - "{\"name\":\"CXF in Action\",\"id\":123}", + "{\"class\":\"org.apache.cxf.systest.jaxrs.Book\",\"name\":\"CXF in Action\",\"id\":123}", getStringFromInputStream(in).trim()); } @Test + public void testGetSuperBookProxy() throws Exception { + + String endpointAddress = + "http://localhost:" + PORT + "/webapp/store2"; + BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, BookStoreSpring.class, + Collections.singletonList(new JacksonJsonProvider())); + SuperBook book = proxy.getSuperBookJson(); + assertEquals(999L, book.getId()); + } + + @Test + public void testEchoSuperBookProxy() throws Exception { + + String endpointAddress = + "http://localhost:" + PORT + "/webapp/store2"; + BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, BookStoreSpring.class, + Collections.singletonList(new JacksonJsonProvider())); + SuperBook book = proxy.echoSuperBookJson(new SuperBook("Super", 124L)); + assertEquals(124L, book.getId()); + } + + @Test public void testGetCollectionOfBooks() throws Exception { String endpointAddress = - "http://localhost:" + PORT + "/webapp/bookstore/collections"; + "http://localhost:" + PORT + "/webapp/store1/bookstore/collections"; WebClient wc = WebClient.create(endpointAddress, Collections.singletonList(new JacksonJsonProvider())); wc.accept("application/json"); Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml?rev=1505696&r1=1505695&r2=1505696&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml (original) +++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml Mon Jul 22 14:42:44 2013 @@ -28,15 +28,26 @@ http://cxf.apache.org/schemas/jaxrs.xsd" + address="/store1"> - - + - - + + + + + + + + + + + + +