cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1097071 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Wed, 27 Apr 2011 10:33:03 GMT
Author: sergeyb
Date: Wed Apr 27 10:33:02 2011
New Revision: 1097071

URL: http://svn.apache.org/viewvc?rev=1097071&view=rev
Log:
[CXF-3470] Applying a patch on behalf of Carlos Marin

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/BookStore.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

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=1097071&r1=1097070&r2=1097071&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
Wed Apr 27 10:33:02 2011
@@ -30,6 +30,7 @@ import java.lang.reflect.ParameterizedTy
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -200,7 +201,15 @@ public final class InjectionUtils {
         if (!ParameterizedType.class.isAssignableFrom(genericType.getClass())) {
             if (genericType instanceof TypeVariable) {
                 genericType = getType(((TypeVariable)genericType).getBounds(), pos);
+            } else if (genericType instanceof WildcardType) { 
+                WildcardType wildcardType = (WildcardType)genericType;
+                Type[] bounds = wildcardType.getLowerBounds();
+                if (bounds.length == 0) { 
+                    bounds = wildcardType.getUpperBounds();
+                }
+                genericType = getType(bounds, pos);
             }
+
             Class<?> cls = (Class<?>)genericType;
             return cls.isArray() ? cls.getComponentType() : cls;
         }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1097071&r1=1097070&r2=1097071&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Wed
Apr 27 10:33:02 2011
@@ -526,6 +526,20 @@ public class BookStore {
                                      doGetBook("123"));
     }
     
+    @POST
+    @Path("/books/element/echo")
+    public JAXBElement<Book> echoBookElement(JAXBElement<Book> element) throws
Exception {
+        return element;
+    }
+    
+    @SuppressWarnings("unchecked")
+    @POST
+    @Path("/books/element/echo")
+    public JAXBElement<? super Book> echoBookElementWildcard(JAXBElement<? extends
Book> element) 
+        throws Exception {
+        return (JAXBElement<? super Book>)element;
+    }
+    
     @GET
     @Path("/books/adapter")
     @XmlJavaTypeAdapter(BookInfoAdapter.class)

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1097071&r1=1097070&r2=1097071&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Wed Apr 27 10:33:02 2011
@@ -33,6 +33,8 @@ import java.util.Map;
 
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
 
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
@@ -868,6 +870,29 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testEchoBookElement() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        JAXBElement<Book> element = store.echoBookElement(new JAXBElement<Book>(new
QName("", "Book"),
+                                     Book.class,
+                                     new Book("CXF", 123L)));
+        Book book = element.getValue();
+        assertEquals(123L, book.getId());
+        assertEquals("CXF", book.getName());
+    }
+    
+    @Test
+    public void testEchoBookElementWildcard() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        JAXBElement<? super Book> element = store.echoBookElementWildcard(
+                                        new JAXBElement<Book>(new QName("", "Book"),
+                                        Book.class,
+                                        new Book("CXF", 123L)));
+        Book book = (Book)element.getValue();
+        assertEquals(123L, book.getId());
+        assertEquals("CXF", book.getName());
+    }
+    
+    @Test
     public void testGetBookAdapter() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/adapter",
                                "resources/expected_get_book123.txt",



Mime
View raw message