cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r540014 - in /incubator/cxf/trunk/tools/validator/src: main/java/org/apache/cxf/tools/validator/internal/ test/java/org/apache/cxf/tools/validator/internal/ test/java/org/apache/cxf/tools/validator/internal/resources/
Date Mon, 21 May 2007 04:10:55 GMT
Author: mmao
Date: Sun May 20 21:10:54 2007
New Revision: 540014

URL: http://svn.apache.org/viewvc?view=rev&rev=540014
Log:
CXF-645
* WSDLRefValidator support validating the logical wsdl
* If there is no services/bindings, just add as warnings, not errors
* Add user tests


Added:
    incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/resources/nobinding.wsdl
Modified:
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidationResult.java
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
    incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
    incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidationResult.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidationResult.java?view=diff&rev=540014&r1=540013&r2=540014
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidationResult.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidationResult.java
Sun May 20 21:10:54 2007
@@ -43,11 +43,19 @@
         this.errors.push(error);
     }
 
+    public void addWarning(final Message msg) {
+        addWarning(msg.toString());
+    }
+
     public void addWarning(final String warning) {
         this.warnings.push(warning);
     }
 
+    public boolean hasWarnings() {
+        return warnings.size() > 0;
+    }
+    
     public boolean isSuccessful() {
-        return errors.size() == 0 && warnings.size() == 0;
+        return errors.size() == 0;
     }
 }

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java?view=diff&rev=540014&r1=540013&r2=540014
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
Sun May 20 21:10:54 2007
@@ -327,8 +327,17 @@
 
     private void collectValidationPoints() {
         if (getServices().size() == 0) {
-            throw new ToolException("WSDL document does not define any services");
+            vResults.addWarning("WSDL document does not define any services");
+            portTypeRefNames.addAll(this.definition.getAllPortTypes().keySet());
+        } else {
+            collectValidationPointsForBindings();
         }
+
+        collectValidationPointsForPortTypes();
+        collectValidationPointsForMessages();
+    }
+
+    private void collectValidationPointsForBindings() {
         Map<QName, XNode> vBindingNodes = new HashMap<QName, XNode>();
         for (Service service : getServices().values()) {
             vBindingNodes.putAll(getBindings(service));
@@ -376,9 +385,6 @@
                 }
             }
         }
-
-        collectValidationPointsForPortTypes();
-        collectValidationPointsForMessages();        
     }
 
     private void collectValidationPointsForMessages() {

Modified: incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java?view=diff&rev=540014&r1=540013&r2=540014
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
Sun May 20 21:10:54 2007
@@ -35,7 +35,6 @@
         try {
             assertFalse(validator.isValid());
         } catch (Exception e) {
-            System.err.println(e.getMessage());
             assertTrue(e.getMessage().indexOf("Caused by {http://apache.org/hello_world/messages}"
                                               + "[portType:GreeterA][operation:sayHi] not
exist.") != -1);
         }

Modified: incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java?view=diff&rev=540014&r1=540013&r2=540014
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
Sun May 20 21:10:54 2007
@@ -36,8 +36,8 @@
         WSDLRefValidator validator = new WSDLRefValidator(wsdl);
         assertFalse(validator.isValid());
         ValidationResult results = validator.getValidationResults();
-        assertEquals(1, results.getErrors().size());
-        String t = results.getErrors().pop();
+        assertEquals(1, results.getWarnings().size());
+        String t = results.getWarnings().pop();
         assertEquals("WSDL document does not define any services", t);
     }
 
@@ -90,5 +90,27 @@
             + " referenced Type <{http://apache.org/samples/headers}SOAPHeaderInfo>
"
             + "can not be found in the schemas";
         assertEquals(expected, t);
+    }
+
+    @Test
+    public void testNoBindingWSDL() throws Exception {
+        String wsdl = getClass().getResource("resources/nobinding.wsdl").toURI().toString();
+        WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+        validator.isValid();
+        ValidationResult results = validator.getValidationResults();
+
+        assertEquals(1, results.getWarnings().size());
+        String t = results.getWarnings().pop();
+        assertEquals("WSDL document does not define any services", t);
+
+        assertEquals(1, results.getErrors().size());
+        String text = "{http://schemas.apache.org/yoko/idl/OptionsPT}[message:getEmployee]";
+        Message msg = new Message("FAILED_AT_POINT",
+                                  WSDLRefValidator.LOG,
+                                  23,
+                                  6,
+                                  new File(new java.net.URI(wsdl)).toString(),
+                                  text);
+        assertEquals(msg.toString(), results.getErrors().pop());
     }
 }

Added: incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/resources/nobinding.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/resources/nobinding.wsdl?view=auto&rev=540014
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/resources/nobinding.wsdl
(added)
+++ incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/resources/nobinding.wsdl
Sun May 20 21:10:54 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/OptionsPT" 
+		  xmlns:tns="http://schemas.apache.org/yoko/idl/OptionsPT" 
+		  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
+		  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
+		  xmlns:xsd1="http://schemas.apache.org/yoko/idl/OptionsPT-types" 
+		  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+    <wsdl:types>
+	<xsd:schema>
+	    <xsd:import namespace="http://schemas.apache.org/yoko/idl/OptionsPT-types" schemaLocation="schemapt.xsd"/>
+	</xsd:schema>
+    </wsdl:types>
+    <wsdl:message name="getEmployeeA">
+	<wsdl:part name="inparameter" element="xsd1:getEmployee">
+	</wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="getEmployeeResponse">
+	<wsdl:part name="outparameter" element="xsd1:getEmployeeResponse">
+	</wsdl:part>
+    </wsdl:message>
+    <wsdl:portType name="foo.bar">
+	<wsdl:operation name="getEmployee">
+	    <wsdl:input name="getEmployeeRequest" message="tns:getEmployee">
+	    </wsdl:input>
+	    <wsdl:output name="getEmployeeResponse" message="tns:getEmployeeResponse">
+	    </wsdl:output>
+	</wsdl:operation>
+    </wsdl:portType>
+</wsdl:definitions>
\ No newline at end of file



Mime
View raw message