cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject cxf git commit: add WSI-BP R2209 check in WSIBPValidator
Date Thu, 27 Nov 2014 17:23:09 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 3f7c187b5 -> 8e378c3d5


add WSI-BP R2209 check in WSIBPValidator


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

Branch: refs/heads/3.0.x-fixes
Commit: 8e378c3d50f53aaacb8550bf96489bc820ff2458
Parents: 3f7c187
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Thu Nov 27 17:05:23 2014 +0100
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Thu Nov 27 18:22:51 2014 +0100

----------------------------------------------------------------------
 .../validator/internal/WSIBPValidator.java      | 12 +++++
 .../cxf/tools/validator/WSDLValidationTest.java |  8 ++++
 .../hello_world_unbound_porttype_elements.wsdl  | 47 ++++++++++++++++++++
 3 files changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8e378c3d/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
----------------------------------------------------------------------
diff --git a/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
b/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
index cb4a413..fc70e91 100644
--- a/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
+++ b/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
@@ -235,6 +235,17 @@ public class WSIBPValidator extends AbstractDefinitionValidator {
         return true;
     }
 
+    private boolean checkR2209(final Operation operation,
+                               final BindingOperation bop) {
+        if ((bop.getBindingInput() == null && operation.getInput() != null) 
+            || (bop.getBindingOutput() == null && operation.getOutput() != null))
{
+            addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2209") 
+                            + "Unbound PortType elements in Operation '" + operation.getName()
+ "'");
+            return false;
+        }
+        return true;
+    }
+
     public boolean checkBinding() {
         for (PortType portType : wsdlHelper.getPortTypes(def)) {
             Iterator<?> ite = portType.getOperations().iterator();
@@ -258,6 +269,7 @@ public class WSIBPValidator extends AbstractDefinitionValidator {
                 if ("DOCUMENT".equalsIgnoreCase(style) || StringUtils.isEmpty(style)) {
                     boolean passed = checkR2201Input(operation, bop)
                         && checkR2201Output(operation, bop)
+                        && checkR2209(operation, bop)
                         && checkR2716(bop);
                     if (!passed) {
                         return false;

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e378c3d/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
----------------------------------------------------------------------
diff --git a/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
b/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
index f8361c6..9093221 100644
--- a/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
+++ b/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
@@ -175,6 +175,14 @@ public class WSDLValidationTest extends ToolTestBase {
     }
 
     @Test
+    public void testWSIBPR2209() throws Exception {
+        String[] args = new String[] {"-verbose",
+                                      getLocation("/validator_wsdl/hello_world_unbound_porttype_elements.wsdl")};
+        WSDLValidator.main(args);
+        assertTrue(getStdErr().indexOf("WSI-BP-1.0 R2209") > -1);
+    }
+
+    @Test
     public void testBPR2717() throws Exception {
         try {
             String[] args = new String[] {"-verbose",

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e378c3d/tools/validator/src/test/resources/validator_wsdl/hello_world_unbound_porttype_elements.wsdl
----------------------------------------------------------------------
diff --git a/tools/validator/src/test/resources/validator_wsdl/hello_world_unbound_porttype_elements.wsdl
b/tools/validator/src/test/resources/validator_wsdl/hello_world_unbound_porttype_elements.wsdl
new file mode 100644
index 0000000..b99c74d
--- /dev/null
+++ b/tools/validator/src/test/resources/validator_wsdl/hello_world_unbound_porttype_elements.wsdl
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://apache.org/hello_world_doc_lit" xmlns:x1="http://apache.org/hello_world_doc_lit/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://apache.org/hello_world_doc_lit" name="HelloWorld">
+    <wsdl:message name="sayHiRequest">
+        <wsdl:part name="in" type="xsd:string"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part name="out" type="xsd:int"/>
+    </wsdl:message>
+    <wsdl:portType name="Greeter">
+        <wsdl:operation name="sayHi">
+            <wsdl:input name="sayHiRequest" message="tns:sayHiRequest"/>
+            <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+    <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="sayHi">
+            <soap:operation style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="SOAPService">
+        <wsdl:port name="SoapPort" binding="tns:Greeter_SOAPBinding">
+            <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>


Mime
View raw message