cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1443983 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Date Fri, 08 Feb 2013 12:20:06 GMT
Author: sergeyb
Date: Fri Feb  8 12:20:05 2013
New Revision: 1443983

URL: http://svn.apache.org/r1443983
Log:
Merged revisions 1443515 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1443515 | sergeyb | 2013-02-07 14:51:17 +0000 (Thu, 07 Feb 2013) | 1 line
  
  [CXF-4799] Adding a test
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1443515

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

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1443983&r1=1443982&r2=1443983&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Fri Feb  8 12:20:05 2013
@@ -207,6 +207,43 @@ public class JAXBElementProviderTest ext
         testXmlList(provider);
     }
     
+    @Test
+    public void testGenericsAndSingleContext2() throws Exception {
+        ClassResourceInfo cri = 
+            ResourceUtils.createClassResourceInfo(XmlListResource.class, XmlListResource.class,
true, true);
+        JAXBElementProvider<?> provider = new JAXBElementProvider<Object>();
+        provider.setSingleJaxbContext(true);
+        provider.init(Collections.singletonList(cri));
+        
+        List<org.apache.cxf.jaxrs.fortest.jaxb.SuperBook> list = 
+            new ArrayList<org.apache.cxf.jaxrs.fortest.jaxb.SuperBook>();
+        for (int i = 0; i < 10; i++) {
+            org.apache.cxf.jaxrs.fortest.jaxb.SuperBook o = 
+                new org.apache.cxf.jaxrs.fortest.jaxb.SuperBook();
+            o.setName("name #" + i);
+            list.add(o);
+        }
+        XmlList<org.apache.cxf.jaxrs.fortest.jaxb.SuperBook> xmlList = 
+            new XmlList<org.apache.cxf.jaxrs.fortest.jaxb.SuperBook>(list);
+        
+        Method m = XmlListResource.class.getMethod("testJaxb2", new Class[]{});
+        JAXBContext context = provider.getJAXBContext(m.getReturnType(), m.getGenericReturnType());
+        
+        ByteArrayOutputStream os = new ByteArrayOutputStream(); 
+        context.createMarshaller().marshal(xmlList, os);
+        @SuppressWarnings("unchecked")
+        XmlList<org.apache.cxf.jaxrs.fortest.jaxb.SuperBook> list2 = 
+            (XmlList<org.apache.cxf.jaxrs.fortest.jaxb.SuperBook>)context.createUnmarshaller()
+                .unmarshal(new ByteArrayInputStream(os.toByteArray()));
+        
+        List<org.apache.cxf.jaxrs.fortest.jaxb.SuperBook> actualList = list2.getList();
+        assertEquals(10, actualList.size());
+        for (int i = 0; i < 10; i++) {
+            org.apache.cxf.jaxrs.fortest.jaxb.SuperBook object = actualList.get(i);
+            assertEquals("name #" + i, object.getName());
+        }
+    }
+    
     @SuppressWarnings("unchecked")
     private void testXmlList(JAXBElementProvider<?> provider) throws Exception {
         
@@ -218,7 +255,8 @@ public class JAXBElementProviderTest ext
         }
         XmlList<XmlObject> xmlList = new XmlList<XmlObject>(list);
         
-        JAXBContext context = provider.getJAXBContext(XmlList.class, XmlList.class);
+        Method m = XmlListResource.class.getMethod("testJaxb", new Class[]{});
+        JAXBContext context = provider.getJAXBContext(m.getReturnType(), m.getGenericReturnType());
         
         ByteArrayOutputStream os = new ByteArrayOutputStream(); 
         context.createMarshaller().marshal(xmlList, os);
@@ -1587,6 +1625,12 @@ public class JAXBElementProviderTest ext
         public XmlList<XmlObject> testJaxb() {
             return null;
         }
+        
+        @GET
+        @Path("/jaxb2")
+        public XmlList<org.apache.cxf.jaxrs.fortest.jaxb.SuperBook> testJaxb2() {
+            return null;
+        }
     }
     
     private Message createMessage() {



Mime
View raw message