cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1515796 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/
Date Tue, 20 Aug 2013 12:21:41 GMT
Author: sergeyb
Date: Tue Aug 20 12:21:40 2013
New Revision: 1515796

URL: http://svn.apache.org/r1515796
Log:
[CXF-5204] Some more work to do with handling TypeVariable

Added:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractBookStoreSpring.java
  (with props)
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/GenericBookStoreSpring2.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1515796&r1=1515795&r2=1515796&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Tue Aug 20 12:21:40 2013
@@ -131,15 +131,18 @@ public final class InjectionUtils {
         }
         
         Type genericSubtype = serviceClass.getGenericSuperclass();
-        if (genericSubtype == Object.class) {
+        if (!(genericSubtype instanceof ParameterizedType)) {
             Type[] genInterfaces = serviceClass.getGenericInterfaces();
             for (Type t : genInterfaces) {
                 genericSubtype = t;
                 break;
             }
         }
-        Type result = genericSubtype != Object.class ? InjectionUtils.getActualType(genericSubtype,
pos)
-                                              : genericSubtype;
+        if (!(genericSubtype instanceof ParameterizedType)) {
+            genericSubtype = null;
+        }
+        Type result = InjectionUtils.getActualType(genericSubtype, pos);
+                                             
         if (result == null || result == Object.class) {
             Type[] bounds = var.getBounds();
             int boundPos = bounds.length > pos ? pos : 0; 
@@ -210,6 +213,9 @@ public final class InjectionUtils {
         if (genericType == null) {
             return null;
         }
+        if (genericType == Object.class) {
+            return (Class<?>)genericType;
+        }
         if (!ParameterizedType.class.isAssignableFrom(genericType.getClass())) {
             if (genericType instanceof TypeVariable) {
                 genericType = getType(((TypeVariable<?>)genericType).getBounds(), pos);

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractBookStoreSpring.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractBookStoreSpring.java?rev=1515796&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractBookStoreSpring.java
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractBookStoreSpring.java
Tue Aug 20 12:21:40 2013
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs;
+
+
+
+public abstract class AbstractBookStoreSpring {
+}
+
+

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractBookStoreSpring.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractBookStoreSpring.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/GenericBookStoreSpring2.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/GenericBookStoreSpring2.java?rev=1515796&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/GenericBookStoreSpring2.java
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/GenericBookStoreSpring2.java
Tue Aug 20 12:21:40 2013
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs;
+
+
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+
+import org.apache.cxf.annotations.Logging;
+
+@Path("/")
+@Produces("application/json")
+@Consumes("application/json")
+@Logging
+public class GenericBookStoreSpring2 extends AbstractBookStoreSpring {
+    @POST
+    @Path("/books/superbook")
+    public <T extends Book> T echoSuperBookJson(T book) {
+        if (((SuperBook)book).isSuperBook()) {
+            return book;
+        }
+        throw new WebApplicationException(400);
+    }
+    
+    @POST
+    @Path("/books/superbooks")
+    public <T extends Book> List<T> echoSuperBookCollectionJson(List<T>
book) {
+        if (((SuperBook)book.get(0)).isSuperBook()) {
+            return book;
+        }
+        throw new WebApplicationException(400);
+    }
+    
+    
+}
+
+

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/GenericBookStoreSpring2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/GenericBookStoreSpring2.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java?rev=1515796&r1=1515795&r2=1515796&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
Tue Aug 20 12:21:40 2013
@@ -133,12 +133,39 @@ public class JAXRSClientServerResourceJa
             "http://localhost:" + PORT + "/webapp/genericstore";
         GenericBookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, 
             GenericBookStoreSpring.class, Collections.singletonList(new JacksonJsonProvider()));
+        WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L);
         SuperBook book = proxy.echoSuperBookJson(new SuperBook("Super", 124L, true));
         assertEquals(124L, book.getId());
         assertTrue(book.isSuperBook());
     }
     
     @Test
+    public void testEchoGenericSuperBookProxy2() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/webapp/genericstore2";
+        GenericBookStoreSpring2 proxy = JAXRSClientFactory.create(endpointAddress, 
+            GenericBookStoreSpring2.class, Collections.singletonList(new JacksonJsonProvider()));
+        WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L);
+        SuperBook book = proxy.echoSuperBookJson(new SuperBook("Super", 124L, true));
+        assertEquals(124L, book.getId());
+        assertTrue(book.isSuperBook());
+    }
+    
+    @Test
+    public void testEchoGenericSuperBookCollectionProxy2() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/webapp/genericstore2";
+        GenericBookStoreSpring2 proxy = JAXRSClientFactory.create(endpointAddress, 
+            GenericBookStoreSpring2.class, Collections.singletonList(new JacksonJsonProvider()));
+        List<SuperBook> books = 
+            proxy.echoSuperBookCollectionJson(Collections.singletonList(new SuperBook("Super",
124L, true)));
+        assertEquals(124L, books.get(0).getId());
+        assertTrue(books.get(0).isSuperBook());
+    }
+    
+    @Test
     public void testEchoGenericSuperBookWebClient() throws Exception {
         
         String endpointAddress = 

Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml?rev=1515796&r1=1515795&r2=1515796&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml Tue
Aug 20 12:21:40 2013
@@ -57,8 +57,19 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
         </jaxrs:providers>
     </jaxrs:server>
     
+    <jaxrs:server id="genericBookStore2"
+                  address="/genericstore2">
+        <jaxrs:serviceBeans>
+            <ref bean="gBookStore2"/>
+        </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"/>
     <bean id="gBookStore" class="org.apache.cxf.systest.jaxrs.GenericBookStoreSpring"/>
+    <bean id="gBookStore2" class="org.apache.cxf.systest.jaxrs.GenericBookStoreSpring2"/>
 </beans>



Mime
View raw message