cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1517537 - in /cxf/branches/2.6.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
Date Mon, 26 Aug 2013 13:25:23 GMT
Author: sergeyb
Date: Mon Aug 26 13:25:23 2013
New Revision: 1517537

URL: http://svn.apache.org/r1517537
Log:
Merged revisions 1517534 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

................
  r1517534 | sergeyb | 2013-08-26 14:05:18 +0100 (Mon, 26 Aug 2013) | 9 lines
  
  Merged revisions 1517531 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1517531 | sergeyb | 2013-08-26 13:55:39 +0100 (Mon, 26 Aug 2013) | 1 line
    
    [CXF-5065] Minor update for subresources not to lose their own Produces/Consumes annotations
  ........
................

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1517534
  Merged /cxf/trunk:r1517531

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

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=1517537&r1=1517536&r2=1517537&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
Mon Aug 26 13:25:23 2013
@@ -236,24 +236,24 @@ public class ClassResourceInfo extends A
     }
     
     public List<MediaType> getProduceMime() {
-        if (root || parent == null) {
-            if (producesTypes != null) {
-                return JAXRSUtils.parseMediaTypes(producesTypes);
-            }
-            return JAXRSUtils.getProduceTypes(
-                 AnnotationUtils.getClassAnnotation(getServiceClass(), Produces.class));
+        if (producesTypes != null) {
+            return JAXRSUtils.parseMediaTypes(producesTypes);
+        }
+        Produces produces = AnnotationUtils.getClassAnnotation(getServiceClass(), Produces.class);
+        if (produces != null || parent == null) {
+            return JAXRSUtils.getProduceTypes(produces);
         } else {
             return parent.getProduceMime();
         }
     }
     
     public List<MediaType> getConsumeMime() {
-        if (root || parent == null) {
-            if (consumesTypes != null) {
-                return JAXRSUtils.parseMediaTypes(consumesTypes);
-            }
-            return JAXRSUtils.getConsumeTypes(
-                 AnnotationUtils.getClassAnnotation(getServiceClass(), Consumes.class));
+        if (consumesTypes != null) {
+            return JAXRSUtils.parseMediaTypes(consumesTypes);
+        }
+        Consumes consumes = AnnotationUtils.getClassAnnotation(getServiceClass(), Consumes.class);
+        if (consumes != null || parent == null) {
+            return JAXRSUtils.getConsumeTypes(consumes);
         } else {
             return parent.getConsumeMime();
         }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java?rev=1517537&r1=1517536&r2=1517537&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
Mon Aug 26 13:25:23 2013
@@ -86,6 +86,24 @@ public class ClassResourceInfoTest exten
         }
     }
     
+    @Produces("test/foo")
+    static class TestClassWithProduces extends TestClass1 {
+        @GET
+        public void getIt() { 
+            
+        }
+      
+        @Path("/same")
+        public TestClassWithProduces getThis() { 
+            return this;
+        }
+        
+        @Path("sub")
+        public TestClass3 getTestClass3() { 
+            return new TestClass3();
+        }
+    }
+    
     static class TestClass3 {
         @Resource HttpServletRequest req;
         @Resource HttpServletResponse res;
@@ -215,4 +233,14 @@ public class ClassResourceInfoTest exten
         assertEquals("test/bar", sub.getProduceMime().get(0).toString());
     }
     
+    @Test
+    public void testSubresourceWithProduces() {
+        ClassResourceInfo parent = ResourceUtils.createClassResourceInfo(
+                                  TestClass2.class, TestClass2.class, true, true);
+        ClassResourceInfo c = ResourceUtils.createClassResourceInfo(
+                                  TestClassWithProduces.class, TestClassWithProduces.class,
true, true);
+        c.setParent(parent);
+        assertEquals("test/foo", c.getProduceMime().get(0).toString());
+    }
+    
 }



Mime
View raw message