cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
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 GMT
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 extends Book> 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 extends Book> 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"
 	<import resource="classpath:/META-INF/cxf/cxf.xml"/>
 
     <jaxrs:server id="bookservice"
-                  address="/">
+                  address="/store1">
         <jaxrs:serviceBeans>
-            <ref bean="petstore"/>
             <ref bean="bookstore"/>
         </jaxrs:serviceBeans>
         <jaxrs:providers>
-            <bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
+            <ref bean="jackson"/>
         </jaxrs:providers>
     </jaxrs:server>
-    <bean id="bookstore" scope="prototype" class="org.apache.cxf.systest.jaxrs.BookStore"/>
-    <bean id="petstore" scope="prototype" class="org.apache.cxf.systest.jaxrs.PetStore"/>
+    
+    <jaxrs:server id="bookservice2"
+                  address="/store2">
+        <jaxrs:serviceBeans>
+            <ref bean="bookstore2"/>
+        </jaxrs:serviceBeans>
+        <jaxrs:providers>
+            <ref bean="jackson"/>
+        </jaxrs:providers>
+    </jaxrs:server>
+    
+    <bean id="jackson" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
+    <bean id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStore"/>
+    <bean id="bookstore2" class="org.apache.cxf.systest.jaxrs.BookStoreSpring"/>
 </beans>



Mime
View raw message