cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5870] A quick fix to avoid duplicated inherited parameters added to the signature
Date Fri, 11 Jul 2014 21:57:32 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes bd5ba39e1 -> 76efa97cc


[CXF-5870] A quick fix to avoid duplicated inherited parameters added to the signature


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

Branch: refs/heads/2.7.x-fixes
Commit: 76efa97ccd729b875e8bda6301608c7481c35677
Parents: bd5ba39
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Jul 11 22:55:16 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Jul 11 22:57:08 2014 +0100

----------------------------------------------------------------------
 .../cxf/tools/wadlto/jaxrs/SourceGenerator.java | 13 +++++++++-
 .../tools/wadlto/jaxrs/JAXRSContainerTest.java  | 25 +++++++++++++++++++
 .../jaxrs/src/test/resources/wadl/test.xml      | 26 ++++++++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/76efa97c/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 a1259f4..a2ad31c 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
@@ -815,7 +815,18 @@ public class SourceGenerator {
             }
             inParamElements.add(el);
         }
-        inParamElements.addAll(inheritedParams);
+        for (Element inherited : inheritedParams) {
+            boolean duplicate = false;
+            for (Element in : inParamElements) {
+                if (in.getLocalName().equals(inherited.getLocalName())) {    
+                    duplicate = true;
+                    break;
+                }
+            }
+            if (!duplicate) {
+                inParamElements.add(inherited);
+            }
+        }
         inheritedParams.addAll(newInheritedParams);
         return inParamElements;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/76efa97c/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 7d58f4d..5d18ead 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
@@ -64,6 +64,31 @@ public class JAXRSContainerTest extends ProcessorTestBase {
     }
     
     @Test    
+    public void testInheritParameters() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/test.xml"));
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+            context.put(WadlToolConstants.CFG_INHERIT_PARAMS, "true");
+            
+            container.setContext(context);
+            container.execute();
+
+            assertNotNull(output.list());
+            
+            List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class"
+ "$");
+            assertEquals(1, files.size());
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
+    @Test    
     public void testCodeGenInterfacesMultipleInXmlReps() {
         try {
             JAXRSContainer container = new JAXRSContainer(null);

http://git-wip-us.apache.org/repos/asf/cxf/blob/76efa97c/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml b/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml
new file mode 100644
index 0000000..ef37ba1
--- /dev/null
+++ b/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml
@@ -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="Test" path="/repository">
+
+			<method name="GET" id="listRepositories">
+				<response>
+					<representation mediaType="application/json" />
+				</response>
+			</method>
+
+			<resource path="{name}">
+				<param name="name" style="template" type="xs:string"/>
+				<method name="PUT" id="createRepository" >
+					<request>
+					</request>
+					<response>
+					</response>
+				</method>
+				<method name="DELETE" id="deleteRepository">
+				</method>
+
+			</resource>
+		</resource>
+	</resources>
+</application>
\ No newline at end of file


Mime
View raw message