cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1333498 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/model/wadl/ test/java/org/apache/cxf/jaxrs/model/wadl/ test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/
Date Thu, 03 May 2012 15:17:30 GMT
Author: sergeyb
Date: Thu May  3 15:17:29 2012
New Revision: 1333498

URL: http://svn.apache.org/viewvc?rev=1333498&view=rev
Log:
[CXF-4285] Checking form parameters after all other JAX-RS parameters have been checked

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/FormInterface.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.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=1333498&r1=1333497&r2=1333498&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
Thu May  3 15:17:29 2012
@@ -413,14 +413,19 @@ public class WadlGenerator implements Re
         if (getMethod(ori).getParameterTypes().length != 0 || classParams.size() != 0) {
             sb.append("<request>");
             handleDocs(anns, sb, DocTarget.REQUEST, false, isJson);
-            if (isFormRequest(ori)) {
+            
+            boolean isForm = isFormRequest(ori);
+            
+            doHandleClassParams(sb, classParams, isJson, ParameterType.QUERY, ParameterType.HEADER);
+            for (Parameter p : ori.getParameters()) {
+                if (isForm && p.getType() == ParameterType.REQUEST_BODY) {
+                    continue;
+                }
+                handleParameter(sb, jaxbTypes, qnameResolver, clsMap, ori, p, isJson);
+            }
+            if (isForm) {
                 handleFormRepresentation(sb, jaxbTypes, qnameResolver, clsMap, ori, getFormClass(ori),

                         isJson);
-            } else {
-                doHandleClassParams(sb, classParams, isJson, ParameterType.QUERY, ParameterType.HEADER);
-                for (Parameter p : ori.getParameters()) {
-                    handleParameter(sb, jaxbTypes, qnameResolver, clsMap, ori, p, isJson);
-                }
             }
             sb.append("</request>");
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java?rev=1333498&r1=1333497&r2=1333498&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java
Thu May  3 15:17:29 2012
@@ -20,6 +20,7 @@ package org.apache.cxf.jaxrs.model.wadl;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.FormParam;
+import javax.ws.rs.HeaderParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -44,7 +45,8 @@ public interface FormInterface {
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces(MediaType.TEXT_PLAIN)
-    String form3(@PathParam("id") String id, 
+    String form3(@HeaderParam("headerId") String headerId,
+                 @PathParam("id") String id, 
                  @FormParam("field1") String f1, @FormParam("field2") String f2);
     
     @Path("/form4/{id}")

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=1333498&r1=1333497&r2=1333498&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
Thu May  3 15:17:29 2012
@@ -458,7 +458,20 @@ public class WadlGeneratorTest extends A
         // verify book-subresource /book resource
         // GET 
         verifyGetResourceMethod(subResourceEls.get(0), bookEl, null);
-        // verify book-subresource /form1 resource
+        
+        verifyFormSubResources(subResourceEls);
+        
+        // verify subresource /chapter/{id}
+        List<Element> chapterMethodEls = getElements(subResourceEls.get(5), "resource",
1);
+        assertEquals("/id", chapterMethodEls.get(0).getAttribute("path"));
+        verifyParameters(subResourceEls.get(5), 1, 
+                         new Param("cid", "template", "xs:int"));
+        // GET
+        verifyGetResourceMethod(chapterMethodEls.get(0), chapterEl, "Get the chapter");
+    }
+    
+    private void verifyFormSubResources(List<Element> subResourceEls) {
+     // verify book-subresource /form1 resource
         List<Element> form1MethodEls = getElements(subResourceEls.get(1), "method",
1);
         
         assertEquals("POST", form1MethodEls.get(0).getAttribute("name"));
@@ -477,14 +490,17 @@ public class WadlGeneratorTest extends A
                          new Param("field1", "query", "xs:string"),
                          new Param("field2", "query", "xs:string"));
         
-        
-        // verify subresource /chapter/{id}
-        List<Element> chapterMethodEls = getElements(subResourceEls.get(5), "resource",
1);
-        assertEquals("/id", chapterMethodEls.get(0).getAttribute("path"));
-        verifyParameters(subResourceEls.get(5), 1, 
-                         new Param("cid", "template", "xs:int"));
-        // GET
-        verifyGetResourceMethod(chapterMethodEls.get(0), chapterEl, "Get the chapter");
+        // verify book-subresource /form2 resource
+        verifyParameters(subResourceEls.get(3), 1, 
+                         new Param("id", "template", "xs:string"));
+        List<Element> form3MethodEls = getElements(subResourceEls.get(3), "method",
1);
+        List<Element> form3RequestEls = getElements(form3MethodEls.get(0), "request",
1);
+        verifyParameters(form3RequestEls.get(0), 1, 
+                         new Param("headerId", "header", "xs:string"));
+        List<Element> form3RequestRepEls = getElements(form3RequestEls.get(0), "representation",
1);
+        verifyParameters(form3RequestRepEls.get(0), 2, 
+                         new Param("field1", "query", "xs:string"),
+                         new Param("field2", "query", "xs:string"));
     }
     
     private List<Element> getElements(Element resource, String name, int expectedSize)
{

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java?rev=1333498&r1=1333497&r2=1333498&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java
Thu May  3 15:17:29 2012
@@ -76,7 +76,7 @@ public class Book implements FormInterfa
         return "";
     }
 
-    public String form3(String identificator, String f1, String f2) {
+    public String form3(String headerId, String identificator, String f1, String f2) {
         return "";
     }
 



Mime
View raw message