cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6668] Fixing the case of independent query parameters assumed to be multipart params, patch from Alexei Marchenko applied with thanks
Date Fri, 06 Nov 2015 10:51:09 GMT
Repository: cxf
Updated Branches:
  refs/heads/master a261507eb -> f02749d14


[CXF-6668] Fixing the case of independent query parameters assumed to be multipart params,
patch from Alexei Marchenko applied with thanks


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f02749d1
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f02749d1
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f02749d1

Branch: refs/heads/master
Commit: f02749d14aae91698010ba79cc26749b68436838
Parents: a261507
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Nov 6 10:50:50 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Nov 6 10:50:50 2015 +0000

----------------------------------------------------------------------
 .../cxf/tools/wadlto/jaxrs/SourceGenerator.java |  7 +++---
 .../tools/wadlto/jaxrs/JAXRSContainerTest.java  | 25 +++++++++++++++++++
 .../resources/wadl/testQueryMultipartParam.wadl | 26 ++++++++++++++++++++
 3 files changed, 55 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f02749d1/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
index c8e034d..285f85f 100644
--- a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
+++ b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
@@ -1201,15 +1201,16 @@ public class SourceGenerator {
         boolean multipart = false;
         boolean formOrMultipartParamsAvailable = false;
         String requestMediaType = null;
+        int currentSize = 0;
         if (requestEl != null) {
             inParamEls.addAll(getWadlElements(requestEl, "param"));
-            int currentSize = inParamEls.size();
+            currentSize = inParamEls.size();
             List<Element> repElements = getWadlElements(requestEl, "representation");
             form = addFormParameters(inParamEls, requestEl, repElements);
             if (form) {
                 formOrMultipartParamsAvailable = currentSize < inParamEls.size();
                 requestMediaType = repElements.get(0).getAttribute("mediaType");
-                multipart = form && requestMediaType.startsWith("multipart/");
+                multipart = requestMediaType.startsWith("multipart/");
             }
         }
                   
@@ -1218,7 +1219,7 @@ public class SourceGenerator {
             Element paramEl = inParamEls.get(i);
             
             Class<?> paramAnn = getParamAnnotation(paramEl.getAttribute("style"));
-            if (paramAnn == QueryParam.class && formOrMultipartParamsAvailable) {
+            if (i >= currentSize && paramAnn == QueryParam.class && formOrMultipartParamsAvailable)
{
                 paramAnn = !multipart ? FormParam.class : Multipart.class; 
             } 
             String name = paramEl.getAttribute("name");

http://git-wip-us.apache.org/repos/asf/cxf/blob/f02749d1/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
index 7c3e826..e4ad62d 100644
--- a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
+++ b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
@@ -314,6 +314,31 @@ public class JAXRSContainerTest extends ProcessorTestBase {
         }
     }
     
+    @Test
+    public void testQueryMultipartParam() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/testQueryMultipartParam.wadl"));
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+
+            container.setContext(context);
+            container.execute();
+
+            assertNotNull(output.list());
+            
+            List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class"
+ "$");
+            assertEquals(2, files.size());
+            assertTrue(checkContains(files, "application.Test1.class"));
+            assertTrue(checkContains(files, "application.Test2.class"));
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
     @Test    
     public void testCodeGenWithImportedSchemaAndResourceSet() {
         try {

http://git-wip-us.apache.org/repos/asf/cxf/blob/f02749d1/tools/wadlto/jaxrs/src/test/resources/wadl/testQueryMultipartParam.wadl
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/test/resources/wadl/testQueryMultipartParam.wadl b/tools/wadlto/jaxrs/src/test/resources/wadl/testQueryMultipartParam.wadl
new file mode 100644
index 0000000..914e68f
--- /dev/null
+++ b/tools/wadlto/jaxrs/src/test/resources/wadl/testQueryMultipartParam.wadl
@@ -0,0 +1,26 @@
+<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
+	<grammars />
+	<resources>
+		<resource id="Test1" path="/1">
+			<method name="PUT" >
+				<request>
+					<param name="standalone" style="query" type="xs:boolean" />
+					<representation mediaType="multipart/mixed">
+						<param name="action" style="query" type="xs:anyType" />
+						<param name="sources" style="query" type="xs:anyType" required="false" />
+					</representation>
+				</request>
+			</method>
+		</resource>
+		<resource id="Test2" path="/2">
+			<method name="PUT" >
+				<request>
+					<param name="snapshot" style="query" type="xs:boolean" required="true" />
+					<representation mediaType="application/json">
+						<param name="flow" style="plain" type="xs:anyType" required="true" />
+					</representation>
+				</request>
+			</method>
+		</resource>
+	</resources>
+</application>


Mime
View raw message