cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1207883 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Date Tue, 29 Nov 2011 14:24:47 GMT
Author: sergeyb
Date: Tue Nov 29 14:24:46 2011
New Revision: 1207883

URL: http://svn.apache.org/viewvc?rev=1207883&view=rev
Log:
[CXF-3941] Better support for Description annotations

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1207883&r1=1207882&r2=1207883&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Tue Nov 29 14:24:46 2011
@@ -686,6 +686,9 @@ public class WadlGenerator implements Re
             if (inbound) {
                 int index = getRequestBodyParam(ori).getIndex();
                 anns = opMethod.getParameterAnnotations()[index];
+                if (!isDocAvailable(anns)) {
+                    anns = opMethod.getAnnotations();
+                }
                 docCategory = DocTarget.PARAM;
             } else {
                 anns = opMethod.getAnnotations();

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java?rev=1207883&r1=1207882&r2=1207883&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
Tue Nov 29 14:24:46 2011
@@ -37,6 +37,7 @@ import javax.ws.rs.core.Response;
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.cxf.aegis.type.java5.IgnoreProperty;
+import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
 import org.apache.cxf.jaxrs.fortest.jaxb.packageinfo.Book2;
 import org.apache.cxf.jaxrs.model.wadl.jaxb.Book;
 import org.apache.cxf.jaxrs.model.wadl.jaxb.Chapter;
@@ -47,6 +48,15 @@ import org.apache.cxf.jaxrs.model.wadl.j
 @Description(lang = "en-us", title = "book store resource", value = "super resource")
 public class BookStore {
 
+    @Descriptions({ 
+        @Description(value = "Attachments", target = DocTarget.PARAM)
+    })
+    @POST 
+    @Consumes("multipart/form-data")
+    public void formdata(MultipartBody body) {
+        
+    }
+    
     @GET 
     @Produces("text/plain")
     public String getName(@PathParam("id") Long id, @QueryParam("") QueryBean query) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=1207883&r1=1207882&r2=1207883&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Tue Nov 29 14:24:46 2011
@@ -402,8 +402,8 @@ public class WadlGeneratorTest extends A
         // must have a single template parameter
         verifyParameters(resource, 1, new Param("id", "template", "xs:long"));
         
-        // must have 2 methods, GET and PUT
-        List<Element> methodEls = getElements(resource, "method", 2);
+        // must have 3 methods, GET, POST and PUT
+        List<Element> methodEls = getElements(resource, "method", 3);
         
         // verify GET
         assertEquals("GET", methodEls.get(0).getAttribute("name"));
@@ -425,11 +425,16 @@ public class WadlGeneratorTest extends A
         //check response
         verifyRepresentation(methodEls.get(0), "response", "text/plain", "");
         
+        // verify POST
+        assertEquals("POST", methodEls.get(1).getAttribute("name"));
+        Element formRep = verifyRepresentation(methodEls.get(1), "request", "multipart/form-data",
"");
+        checkDocs(formRep, "", "Attachments", "");
+        
         // verify PUT
-        assertEquals("PUT", methodEls.get(1).getAttribute("name"));
-        verifyRepresentation(methodEls.get(1), "request", "text/plain", "");
+        assertEquals("PUT", methodEls.get(2).getAttribute("name"));
+        verifyRepresentation(methodEls.get(2), "request", "text/plain", "");
         
-        verifyResponseWithStatus(methodEls.get(1), "204");
+        verifyResponseWithStatus(methodEls.get(2), "204");
         
         // verify resource starting with /book2
         verifyGetResourceMethod(resourceEls.get(0), book2El, null);
@@ -576,7 +581,7 @@ public class WadlGeneratorTest extends A
             WadlGenerator.WADL_NS, "representation").size());
     }
     
-    private void verifyRepresentation(Element element, 
+    private Element verifyRepresentation(Element element, 
                                       String name, 
                                       String mediaType,
                                       String elementValue) {
@@ -591,6 +596,7 @@ public class WadlGeneratorTest extends A
             String pName = "request".equals(name) ? "request" : "result";
             verifyParameters(representationEls.get(0), 1, new Param(pName, "plain", "xs:string"));
         }
+        return representationEls.get(0);
     }
     
     private void verifyXmlJsonRepresentations(Element element, String type, String docs)
{



Mime
View raw message