cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1037709 - 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/
Date Mon, 22 Nov 2010 13:19:23 GMT
Author: sergeyb
Date: Mon Nov 22 13:19:23 2010
New Revision: 1037709

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

........
  r1037707 | sergeyb | 2010-11-22 13:14:14 +0000 (Mon, 22 Nov 2010) | 1 line
  
  [CXF-3110] Minor update for xml adapters with parameterized types work better
........

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/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 (original)
+++ svn:mergeinfo Mon Nov 22 13:19:23 2010
@@ -1 +1 @@
-/cxf/trunk:1036840,1036917
+/cxf/trunk:1036840,1036917,1037707

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=1037709&r1=1037708&r2=1037709&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
Mon Nov 22 13:19:23 2010
@@ -358,8 +358,10 @@ public abstract class AbstractJAXBProvid
             JAXBContext context = packageContexts.get(packageName);
             if (context == null) {
                 try {
-                    context = JAXBContext.newInstance(packageName, type.getClassLoader(),
cProperties);
-                    packageContexts.put(packageName, context);
+                    if (type.getClassLoader() != null) { 
+                        context = JAXBContext.newInstance(packageName, type.getClassLoader(),
cProperties);
+                        packageContexts.put(packageName, context);
+                    }
                 } catch (JAXBException ex) {
                     LOG.fine("Error creating a JAXBContext using ObjectFactory : " 
                                 + ex.getMessage());
@@ -447,7 +449,7 @@ public abstract class AbstractJAXBProvid
             } else {
                 Type[] types = InjectionUtils.getActualTypes(adapter.value().getGenericSuperclass());
                 if (types != null && types.length == 2) {
-                    theType = (Class)types[0];
+                    theType = InjectionUtils.getActualType(types[0]);
                 }
             }
         }

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=1037709&r1=1037708&r2=1037709&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
Mon Nov 22 13:19:23 2010
@@ -25,12 +25,16 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -453,6 +457,17 @@ public class BookStore {
         return new BookInfo(doGetBook("123"));
     }
     
+    @POST
+    @Path("/books/adapter-list")
+    @XmlJavaTypeAdapter(BookInfoAdapterList.class)
+    public Set<Book> getBookAdapterList(Set<Book> collection) 
+        throws Exception {
+        if (collection.size() != 1) {
+            throw new WebApplicationException(400);
+        }
+        return Collections.singleton(doGetBook(Long.toString(collection.iterator().next().getId())));
+    }
+    
     @GET
     @Path("/books/interface/adapter")
     public BookInfoInterface getBookAdapter2() throws Exception {
@@ -805,6 +820,18 @@ public class BookStore {
         }
     }
     
+    public static class BookInfoAdapterList extends XmlAdapter<List<Book>, Set<Book>>
{
+
+        public List marshal(Set<Book> set) throws Exception {
+            return new ArrayList<Book>(set);
+        }
+
+        public Set<Book> unmarshal(List<Book> list) throws Exception {
+            return new HashSet<Book>(list);
+        }
+        
+    }
+    
     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=1037709&r1=1037708&r2=1037709&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
Mon Nov 22 13:19:23 2010
@@ -26,7 +26,9 @@ import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
@@ -45,8 +47,10 @@ import org.apache.cxf.jaxrs.client.JAXRS
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 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.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.http.HTTPConduit;
 
 import org.junit.BeforeClass;
 import org.junit.Ignore;
@@ -653,6 +657,25 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testPostGetBookAdapterList() throws Exception {
+        JAXBElementProvider provider = new JAXBElementProvider();
+        Map<String, String> outMap = new HashMap<String, String>();
+        outMap.put("Books", "CollectionWrapper");
+        outMap.put("books", "Book");
+        provider.setOutTransformElements(outMap);
+        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",
+                                        Collections.singletonList(provider));
+        
+        HTTPConduit conduit = WebClient.getConfig(wc).getHttpConduit();
+        conduit.getClient().setReceiveTimeout(1000000);
+        conduit.getClient().setConnectionTimeout(1000000);
+        Collection<? extends Book> books = wc.type("application/xml").accept("application/xml")
+            .postAndGetCollection(new Books(new Book("CXF", 123L)), Book.class);
+        assertEquals(1, books.size());
+        assertEquals(123L, books.iterator().next().getId());
+    }
+    
+    @Test
     public void testGetBookAdapterInterface() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/interface/adapter",
                                "resources/expected_get_book123.txt",



Mime
View raw message