cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1517534 - in /cxf/branches/2.7.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:05:19 GMT
Author: sergeyb
Date: Mon Aug 26 13:05:18 2013
New Revision: 1517534

URL: http://svn.apache.org/r1517534
Log:
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.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java

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

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/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=1517534&r1=1517533&r2=1517534&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
Mon Aug 26 13:05:18 2013
@@ -240,24 +240,24 @@ public class ClassResourceInfo extends B
     }
     
     public List<MediaType> getProduceMime() {
-        if (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 (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.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java?rev=1517534&r1=1517533&r2=1517534&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
Mon Aug 26 13:05:18 2013
@@ -94,6 +94,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;
@@ -220,6 +238,16 @@ public class ClassResourceInfoTest exten
     }
     
     @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());
+    }
+    
+    @Test
     public void testNameBindings() {
         Application app = new TestApplication();
         JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, true, true);



Mime
View raw message