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 2011/06/08 16:06:46 UTC

svn commit: r1133406 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/

Author: sergeyb
Date: Wed Jun  8 14:06:45 2011
New Revision: 1133406

URL: http://svn.apache.org/viewvc?rev=1133406&view=rev
Log:
Merged revisions 1133405 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1133405 | sergeyb | 2011-06-08 15:03:57 +0100 (Wed, 08 Jun 2011) | 1 line
  
  [CXF-3578] Better checks for XmlJavaTypeAdapter annotation on input
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1133405

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1133406&r1=1133405&r2=1133406&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java (original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java Wed Jun  8 14:06:45 2011
@@ -520,8 +520,8 @@ public abstract class AbstractJAXBProvid
     }
     
     protected static Object checkAdapter(Object obj, Class<?> cls, Annotation[] anns, boolean marshal) {
-        return org.apache.cxf.jaxrs.utils.JAXBUtils.useAdapter(obj, getAdapter(obj.getClass(), anns), 
-                                                               marshal); 
+        XmlJavaTypeAdapter adapter = getAdapter(cls, anns);
+        return org.apache.cxf.jaxrs.utils.JAXBUtils.useAdapter(obj, adapter, marshal); 
     }
     
     protected static XmlJavaTypeAdapter getAdapter(Class<?> objectClass, Annotation[] anns) {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1133406&r1=1133405&r2=1133406&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java (original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java Wed Jun  8 14:06:45 2011
@@ -129,8 +129,8 @@ public class JAXBElementProvider extends
             checkContentLength();
             
             boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(type);
-            Class<?> theType = isCollection ? InjectionUtils.getActualType(genericType) : type;
-            theType = getActualType(theType, genericType, anns);
+            Class<?> theGenericType = isCollection ? InjectionUtils.getActualType(genericType) : type;
+            Class<?> theType = getActualType(theGenericType, genericType, anns);
 
             Unmarshaller unmarshaller = createUnmarshaller(theType, genericType, isCollection);
             addAttachmentUnmarshaller(unmarshaller);
@@ -150,7 +150,7 @@ public class JAXBElementProvider extends
             }
             if (isCollection) {
                 response = ((CollectionWrapper)response).getCollectionOrArray(theType, type, 
-                                                         getAdapter(theType, anns)); 
+                                                         getAdapter(theGenericType, anns)); 
             } else {
                 response = checkAdapter(response, type, anns, false);
             }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=1133406&r1=1133405&r2=1133406&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java (original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java Wed Jun  8 14:06:45 2011
@@ -180,8 +180,8 @@ public class JSONProvider extends Abstra
         
         try {
             boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(type);
-            Class<?> theType = isCollection ? InjectionUtils.getActualType(genericType) : type;
-            theType = getActualType(theType, genericType, anns);
+            Class<?> theGenericType = isCollection ? InjectionUtils.getActualType(genericType) : type;
+            Class<?> theType = getActualType(theGenericType, genericType, anns);
             
             Unmarshaller unmarshaller = createUnmarshaller(theType, genericType, isCollection);
             
@@ -201,7 +201,7 @@ public class JSONProvider extends Abstra
             }
             if (isCollection) {
                 response = ((CollectionWrapper)response).getCollectionOrArray(theType, type, 
-                                                         getAdapter(theType, anns)); 
+                                                         getAdapter(theGenericType, anns)); 
             } else {
                 response = checkAdapter(response, type, anns, false);
             }

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1133406&r1=1133405&r2=1133406&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Wed Jun  8 14:06:45 2011
@@ -588,6 +588,23 @@ public class BookStore {
         return new BookInfo2(doGetBook("123"));
     }
     
+    @GET
+    @Path("/books/interface/adapter-list")
+    public List<? extends BookInfoInterface> getBookAdapterInterfaceList() throws Exception {
+        List<BookInfoInterface> list = new ArrayList<BookInfoInterface>();
+        list.add(new BookInfo2(doGetBook("123")));
+        return list;
+    }
+    
+    @GET
+    @Path("/books/adapter-list")
+    @XmlJavaTypeAdapter(BookInfoAdapter.class)
+    public List<? extends BookInfo> getBookAdapterList() throws Exception {
+        List<BookInfo> list = new ArrayList<BookInfo>();
+        list.add(new BookInfo(doGetBook("123")));
+        return list;
+    }
+    
     @PathParam("bookId")
     public void setBookId(String id) {
         currentBookId = id;
@@ -928,8 +945,8 @@ public class BookStore {
         cds.put(cd1.getId(), cd1);
     }
     
-    @XmlJavaTypeAdapter(BookInfoAdapter.class)
-    private static interface BookInfoInterface {
+    @XmlJavaTypeAdapter(BookInfoAdapter2.class)
+    static interface BookInfoInterface {
         String getName();
         
         long getId();
@@ -977,6 +994,18 @@ public class BookStore {
         }
     }
         
+    public static class BookInfoAdapter2 extends XmlAdapter<Book, BookInfo2> {
+        @Override
+        public Book marshal(BookInfo2 v) throws Exception {
+            return new Book(v.getName(), v.getId());
+        }
+
+        @Override
+        public BookInfo2 unmarshal(Book b) throws Exception {
+            return new BookInfo2(b);
+        }
+    }
+    
     public static class BookInfoAdapter extends XmlAdapter<Book, BookInfo> {
 
         @Override

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1133406&r1=1133405&r2=1133406&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Wed Jun  8 14:06:45 2011
@@ -55,6 +55,8 @@ import org.apache.cxf.jaxrs.client.WebCl
 import org.apache.cxf.jaxrs.ext.xml.XMLSource;
 import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
 import org.apache.cxf.jaxrs.provider.XSLTJaxbProvider;
+import org.apache.cxf.systest.jaxrs.BookStore.BookInfo;
+import org.apache.cxf.systest.jaxrs.BookStore.BookInfoInterface;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.junit.BeforeClass;
@@ -1014,6 +1016,39 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testGetBookAdapterInterfaceList() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        List<? extends BookInfoInterface> list =  store.getBookAdapterInterfaceList();
+        assertEquals(1, list.size());
+        BookInfoInterface info = list.get(0);
+        assertEquals(123L, info.getId());
+    }
+    
+    @Test
+    public void testGetBookAdapterInterfaceProxy() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        WebClient.getConfig(store).getHttpConduit().getClient().setReceiveTimeout(10000000L);
+        BookInfoInterface info = store.getBookAdapterInterface();
+        assertEquals(123L, info.getId());
+    }
+    
+    @Test
+    public void testGetBookAdapterInfoList() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        List<? extends BookInfo> list =  store.getBookAdapterList();
+        assertEquals(1, list.size());
+        BookInfo info = list.get(0);
+        assertEquals(123L, info.getId());
+    }
+    
+    @Test
+    public void testGetBookAdapterInfoProxy() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        BookInfo info = store.getBookAdapter();
+        assertEquals(123L, info.getId());
+    }
+    
+    @Test
     public void testGetBook123FromSub() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/interface/subresource",
                                "resources/expected_get_book123.txt",