cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r806164 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/ systest...
Date Thu, 20 Aug 2009 13:31:29 GMT
Author: sergeyb
Date: Thu Aug 20 13:31:26 2009
New Revision: 806164

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

........
  r803419 | sergeyb | 2009-08-12 10:11:08 +0100 (Wed, 12 Aug 2009) | 1 line
  
  JAX-RS : Adding global marshalAsJaxbElement property, ignorable Aegis collection tests,
RuntimeExceptionMapper test 
........

Added:
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/RuntimeExceptionMapper.java
      - copied unchanged from r803419, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/RuntimeExceptionMapper.java
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/CollectionsResource.java
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 20 13:31:26 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
 4,798654,798748-798749,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803056,803129,803460,803493,803689,804002,804276,805784,805907,805909
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
 4,798654,798748-798749,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803056,803129,803419,803460,803493,803689,804002,804276,805784,805907,805909

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

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=806164&r1=806163&r2=806164&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Thu Aug 20 13:31:26 2009
@@ -85,6 +85,7 @@
     
     protected Map<String, String> jaxbElementClassMap;
     protected boolean unmarshalAsJaxbElement;
+    protected boolean marshalAsJaxbElement;
     
     private MessageContext mc;
     private Schema schema;
@@ -96,6 +97,10 @@
         unmarshalAsJaxbElement = value;
     }
     
+    public void setMarshallAsJaxbElement(boolean value) {
+        marshalAsJaxbElement = value;
+    }
+    
     public void setJaxbElementClassNames(List<String> names) {
         jaxbElementClassNames = names;
     }
@@ -107,17 +112,21 @@
     @SuppressWarnings("unchecked")
     protected Object convertToJaxbElementIfNeeded(Object obj, Class<?> cls, Type genericType)

         throws Exception {
+        
+        QName name = null;
         if (jaxbElementClassNames != null && jaxbElementClassNames.contains(cls.getName())

             || jaxbElementClassMap != null && jaxbElementClassMap.containsKey(cls.getName()))
{
-            QName name = null;
             if (jaxbElementClassMap != null) {
                 name = convertStringToQName(jaxbElementClassMap.get(cls.getName()));
             } else {
                 name = getJaxbQName(cls, genericType, obj, false);
             }
-            if (name != null) {
-                return new JAXBElement(name, cls, null, obj);
-            }
+        }
+        if (name == null && marshalAsJaxbElement) {
+            name = convertStringToQName(cls.getName());
+        }
+        if (name != null) {
+            return new JAXBElement(name, cls, null, obj);
         }
         return obj;
     }
@@ -249,7 +258,7 @@
     }
     
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType
mt) {
-        return isSupported(type, genericType, anns);
+        return marshalAsJaxbElement || isSupported(type, genericType, anns);
     }
 
     public void setSchemaLocations(List<String> locations) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=806164&r1=806163&r2=806164&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Thu Aug 20 13:31:26 2009
@@ -83,7 +83,7 @@
             }
         }
         
-        return isSupported(type, genericType, anns);
+        return super.isReadable(type, genericType, anns, mt);
     }
     
     @Context

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java?rev=806164&r1=806163&r2=806164&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisJSONProviderTest.java
Thu Aug 20 13:31:26 2009
@@ -21,7 +21,10 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.ws.rs.core.MediaType;
@@ -30,11 +33,13 @@
 
 import org.apache.cxf.jaxrs.fortest.AegisTestBean;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.jaxrs.resources.CollectionsResource;
 import org.apache.cxf.jaxrs.resources.ManyTags;
 import org.apache.cxf.jaxrs.resources.TagVO;
 import org.apache.cxf.jaxrs.resources.Tags;
 
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class AegisJSONProviderTest extends Assert {
@@ -129,6 +134,27 @@
     }
     
     @Test
+    @Ignore
+    public void testWriteCollection() throws Exception {
+        AegisJSONProvider p = new AegisJSONProvider();
+        AbstractAegisProvider.clearContexts();
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        AegisTestBean bean = new AegisTestBean();
+        bean.setBoolValue(Boolean.TRUE);
+        bean.setStrValue("hovercraft");
+        List<AegisTestBean> beans = new ArrayList<AegisTestBean>();
+        beans.add(bean);
+        Method m = CollectionsResource.class.getMethod("getAegisBeans", new Class[]{});
+        p.writeTo(beans, (Class)m.getReturnType(), m.getGenericReturnType(), 
+                  AegisTestBean.class.getAnnotations(), 
+                  MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
+        byte[] bytes = os.toByteArray();
+        String json = new String(bytes, "utf-8");
+        System.out.println(json);
+        //assertEquals(data, json);
+    }
+    
+    @Test
     public void testManyTags() throws Exception {
         AegisJSONProvider p = new AegisJSONProvider();
         AbstractAegisProvider.clearContexts();

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java?rev=806164&r1=806163&r2=806164&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
Thu Aug 20 13:31:26 2009
@@ -139,6 +139,11 @@
             return new Book();
         }
         
+//        @Path("/books/{bookId}/{new}")
+//        public List<Book> getNewBook3() {
+//            return null;
+//        }
+        
         @POST
         public void setNewBook(Book b) {
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=806164&r1=806163&r2=806164&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Thu Aug 20 13:31:26 2009
@@ -176,25 +176,35 @@
     
     @Test
     public void testWriteWithoutXmlRootElement() throws Exception {
-        doTestWriteWithoutXmlRootElement("SuperBook", false);
+        doTestWriteWithoutXmlRootElement("SuperBook", false, false);
     }
     
     @Test
     public void testWriteWithoutXmlRootElement2() throws Exception {
-        doTestWriteWithoutXmlRootElement("SuperBook", true);
+        doTestWriteWithoutXmlRootElement("SuperBook", true, false);
     }
     
     @Test
     public void testWriteWithoutXmlRootElement3() throws Exception {
-        doTestWriteWithoutXmlRootElement("{http://books}SuperBook", false);
+        doTestWriteWithoutXmlRootElement("{http://books}SuperBook", false, false);
     }
     
-    public void doTestWriteWithoutXmlRootElement(String name, boolean unmarshalAsJaxbElement)

+    @Test
+    public void testWriteWithoutXmlRootElement4() throws Exception {
+        doTestWriteWithoutXmlRootElement("SuperBook", true, true);
+    }
+    
+    public void doTestWriteWithoutXmlRootElement(String name, boolean unmarshalAsJaxbElement,
+                                                 boolean marshalAsJaxbElement) 
         throws Exception {
         JAXBElementProvider provider = new JAXBElementProvider();
-        provider.setJaxbElementClassMap(Collections.singletonMap(
-            org.apache.cxf.jaxrs.fortest.jaxb.SuperBook.class.getName(), 
-            name));
+        if (!marshalAsJaxbElement) {
+            provider.setJaxbElementClassMap(Collections.singletonMap(
+                org.apache.cxf.jaxrs.fortest.jaxb.SuperBook.class.getName(), 
+                name));
+        } else {
+            provider.setMarshallAsJaxbElement(marshalAsJaxbElement);
+        }
         org.apache.cxf.jaxrs.fortest.jaxb.SuperBook b = 
             new org.apache.cxf.jaxrs.fortest.jaxb.SuperBook("CXF in Action", 123L, 124L);
         

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/CollectionsResource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/CollectionsResource.java?rev=806164&r1=806163&r2=806164&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/CollectionsResource.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/CollectionsResource.java
Thu Aug 20 13:31:26 2009
@@ -26,7 +26,15 @@
 import javax.ws.rs.POST;
 import javax.xml.bind.JAXBElement;
 
+import org.apache.cxf.jaxrs.fortest.AegisTestBean;
+
 public class CollectionsResource {
+    
+    @GET
+    public List<AegisTestBean> getAegisBeans() {
+        return null;
+    }
+    
     @GET
     public List<Book> getBooks() {
         return null;

Modified: cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=806164&r1=806163&r2=806164&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
Thu Aug 20 13:31:26 2009
@@ -142,6 +142,23 @@
     }
     
     @Test
+    public void testGetBookNotExistent() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:9080/webapp/bookstore/nonexistent"; 
+        URL url = new URL(endpointAddress);
+        HttpURLConnection connect = (HttpURLConnection)url.openConnection();
+        connect.addRequestProperty("Accept", "application/xml");
+        assertEquals(405, connect.getResponseCode());
+        InputStream in = connect.getErrorStream();
+        assertNotNull(in);           
+
+        assertEquals("Exception is not mapped correctly", 
+                     "Nonexistent method",
+                     getStringFromInputStream(in).trim());
+    }
+    
+    @Test
     public void testPostPetStatus() throws Exception {
         
         String endpointAddress =

Modified: cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=806164&r1=806163&r2=806164&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
(original)
+++ cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
Thu Aug 20 13:31:26 2009
@@ -35,6 +35,7 @@
         <jaxrs:providers>
             <bean class="org.apache.cxf.systest.jaxrs.BadgerFishProvider"/>
             <ref bean="exceptionMapper"/>
+            <ref bean="exceptionMapper2"/>
         </jaxrs:providers>
     </jaxrs:server>
     <bean id="bookstore" scope="prototype" class="org.apache.cxf.systest.jaxrs.BookStore"/>
@@ -42,4 +43,5 @@
     <bean id="exceptionMapper" class="org.apache.cxf.systest.jaxrs.BookExceptionMapper">
         <property name="toHandle" value="true"/>
     </bean>   
+    <bean id="exceptionMapper2" class="org.apache.cxf.systest.jaxrs.RuntimeExceptionMapper"/>
 </beans>



Mime
View raw message