Author: lmandel
Date: Tue Nov 29 02:17:20 2005
New Revision: 349695

URL: http://svn.apache.org/viewcvs?rev=349695&view=rev
Log:
Added initial validation logic.

Created document and component validators. Removed generic validator.

Added tests for initial tested assertions.

Added:
    
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java
    
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
    
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/TestErrorHandler.java
    
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
Removed:
    
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java
Modified:
    incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
    incubator/woden/java/src/org/apache/woden/internal/Messages.properties
    incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java

Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=349695&r1=349694&r2=349695&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java 
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Tue 
Nov 29 02:17:20 2005
@@ -42,6 +42,8 @@
 import org.apache.woden.internal.wsdl20.InterfaceFaultImpl;

 import org.apache.woden.internal.wsdl20.InterfaceMessageReferenceImpl;

 import org.apache.woden.internal.wsdl20.PropertyImpl;

+import org.apache.woden.internal.wsdl20.validation.WSDLComponentValidator;

+import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidator;

 import org.apache.woden.schema.ImportedSchema;

 import org.apache.woden.schema.InlinedSchema;

 import org.apache.woden.schema.Schema;

@@ -88,6 +90,16 @@
     //a map of imported schema definitions keyed by schema location URI

     private Map fImportedSchemas = new Hashtable();

     

+    /**

+     * WSDL document validator. Only one instance is needed.

+     */

+    private WSDLDocumentValidator docValidator = null;

+    

+    /**

+     * WSDL component validator. Only one instance is needed.

+     */

+    private WSDLComponentValidator compValidator = null;

+    

     public DOMWSDLReader() throws WSDLException {

         super();

     }

@@ -119,7 +131,19 @@
             // Validate the model if validation is enabled.

             if(features.getValue(ReaderFeatures.VALIDATION_FEATURE_ID))

             {

-               //TODO: Add call to validation logic.

+               if(docValidator == null)

+               {

+                       docValidator = new WSDLDocumentValidator();

+               }

+               if(docValidator.validate(desc, getErrorReporter()))

+               {

+                       if(compValidator == null)

+                       {

+                               compValidator = new WSDLComponentValidator();

+                       }

+                       compValidator.validate(desc.toComponent(), 
getErrorReporter());

+               }

+               

             }

             return desc;

             


Modified: incubator/woden/java/src/org/apache/woden/internal/Messages.properties
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/Messages.properties?rev=349695&r1=349694&r2=349695&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/Messages.properties 
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/Messages.properties Tue 
Nov 29 02:17:20 2005
@@ -71,58 +71,104 @@
 # TODO: Is this really a WSDL semantic error or just a parsing error?

 WSDL506=Could not create a URI from the string "{0}".

 

- 

-schema-0016 = 

-schema-0016.ref = 3.1

-schema-0016.assertion = A WSDL 2.0 document MUST NOT refer to XML Schema 
components in a given namespace unless an xs:import or xs:schema element 
information item for that namespace is present or the namespace is the XML 
Schema namespace which contains built-in types as defined in XML Schema Part 2: 
Datatypes Second Edition [XML Schema: Datatypes].

+# ---------------- WSDL Document Level Assertions -------------------

+

+Description-0025 = The target namespace '{0}' is not an absolute IRI. The 
target namespace must be an absolute IRI.

+Description-0025.assertion = The type of the targetNamespace attribute 
information item is xs:anyURI. Its value MUST be an absolute IRI (see [IETF RFC 
3987]).

+

+Import-0001 = 

+Import-0001.assertion =  However, any WSDL 2.0 document that contains 
component definitions that refer by QName to WSDL 2.0 components that belong to 
a different namespace MUST contain a wsdl:import element information item  for 
that namespace (see 4.2 Importing Descriptions).

+

+Import-0003 = The imported document located at '{0}' has the same namespace as 
this document. It must have a different namespace to be imported.

+Import-0003.assertion =  Imported components have different target namespace 
values from the WSDL 2.0 document that is importing them.

+

+Interface-0031 = The styleDefault attribute contains IRIs that are not 
absolute. All IRIs specified for styleDefault must be absolute.

+Interface-0031.assertion = The type of the styleDefault attribute information 
item is list of xs:anyURI. Its value, if present, MUST contain absolute IRIs 
(see [IETF RFC 3987]).

+

+MessageLabel-0004 = 

+MessageLabel-0004.assertion = The messageLabel attribute information item of 
an interface message reference element information item MUST be present if the 
message exchange pattern has more than one placeholder message with {direction} 
equal to the message direction.

+

+MessageLabel-0005 = 

+MessageLabel-0005.assertion = The messageLabel attribute information item of 
an interface fault reference element information item  MUST be present if the 
message exchange pattern has more than one placeholder message with {direction} 
equal to the message direction.

+

+MessageLabel-0006 = 

+MessageLabel-0006.assertion =  The messageLabel attribute information item  of 
a binding message reference element information item  MUST be present if the 
message exchange pattern has more than one placeholder message with {direction} 
equal to the message direction.

+

+MessageLabel-0007 = 

+MessageLabel-0007.assertion =  The messageLabel attribute information item  of 
a binding fault reference element information item  MUST be present if the 
message exchange pattern has more than one placeholder message with {direction} 
equal to the message direction.

+

+MessageLabel-0008 = 

+MessageLabel-0008.assertion =  If the messageLabel attribute information item  
of an interface message reference element information item  is present then its 
actual value MUST match the {message label} of some placeholder message with 
{direction} equal to the message direction.

+

+MessageLabel-0009 = 

+MessageLabel-0009.assertion =  If the messageLabel attribute information item  
of an interface fault reference element information item  is present then its 
actual value MUST match the {message label} of some placeholder message with 
{direction} equal to the message direction.

+

+MessageLabel-0010 = 

+MessageLabel-0010.assertion =  If the messageLabel attribute information item  
of a binding message reference element information item  is present then its 
actual value MUST match the {message label} of some placeholder message with 
{direction} equal to the message direction.

+

+MessageLabel-0011 = 

+MessageLabel-0011.assertion =  If the messageLabel attribute information item  
of a binding fault reference element information item  is present then its 
actual value MUST match the {message label} of some placeholder message with 
{direction} equal to the message direction.

+

+MessageLabel-0012 = 

+MessageLabel-0012.assertion =  If the messageLabel attribute information item  
of an interface message reference element information item  is absent then 
there MUST be a unique placeholder message with {direction} equal to the 
message direction.

+

+MessageLabel-0013 = 

+MessageLabel-0013.assertion =  If the messageLabel attribute information item  
of an interface fault reference element information item  is absent then there 
MUST be a unique placeholder message with {direction} equal to the message 
direction.

+

+MessageLabel-0014 = 

+MessageLabel-0014.assertion =  If the messageLabel attribute information item  
of a binding message reference element information item  is absent then there 
MUST be a unique placeholder message with {direction} equal to the message 
direction.

+

+MessageLabel-0015 = 

+MessageLabel-0015.assertion =  If the messageLabel attribute information item  
of a binding fault reference element information item  is absent then there 
MUST be a unique placeholder message with {direction} equal to the message 
direction.

+

+Schema-0016 = XML Schema component '{0}' has been referenced but its namespace 
is not available. In order to reference components from a XML Schema it must be 
imported or defined inline.

+Schema-0016.assertion = A WSDL 2.0 document MUST NOT refer to XML Schema 
components in a given namespace unless an xs:import or xs:schema element 
information item for that namespace is present or the namespace is the XML 
Schema namespace which contains built-in types as defined in XML Schema Part 2: 
Datatypes Second Edition [XML Schema: Datatypes].

 

 # schema-0017 is a replacement for WSDL501

 WSDL501=The XML schema imported from "{0}" must specify a target namespace.

-schema-0017 = The XML schema imported from "{0}" must specify a target 
namespace of "{1}".

-schema-0017.ref = 3.1.1.1

-schema-0017.assertion = The referenced schema MUST contain a targetNamespace 
attribute information item on its xs:schema element information item and the 
values of these two attribute information items MUST be identical.

-

+Schema-0017 = The XML schema imported from '{0}' must specify a target 
namespace.

+Schema-0017.assertion = The referenced schema MUST contain a targetNamespace 
attribute information item on its xs:schema element information item.

 

 #schema-0017b is a replacement for WSDL502

 WSDL502=The namespace "{0}" specified on a schema import element does not 
match the target namespace "{1}" of the schema at the schemaLocation "{2}".

-schema-0017b = The namespace "{0}" specified on the XML schema import element 
does not match the target namespace "{1}" specified in the XML schema document 
located at "{2}".

-schema-0017b.ref = 3.1.2.1

-schema-0017b.assertion = The targetNamespace attribute information item 
defines the namespace of the element declarations and type definitions inlined 
in its [owner element] xs:schema element information item. WSDL 2.0 modifies 
the XML Schema definition of the xs:schema element information item to make 
this attribute information item required.

-

-schema-0018 = 

-schema-0018.ref = 3.1.2

-schema-0018.assertion = For example, two or more inlined schemas may have the 
same targetNamespace provided that they do not define the same elements or 
types.

+

+Schema-0018 = The element '{0}' has already been defined in another inline XML 
Schema.

+Schema-0018.assertion = A WSDL 2.0 document MUST NOT define the same element 
or type in more than one inlined schema.

+

+Schema-0018b = The type '{0}' has already been defined in another inline XML 
Schema.

+Schema-0018b.assertion = A WSDL 2.0 document MUST NOT define the same element 
or type in more than one inlined schema.

 

 # error schema-0019 is a replacement for WSDL503

 WSDL503=An XML schema is missing its target namespace attribute. Schema id is 
"{0}"

-schema-0019 = The XML schema does not define a target namespace. WSDL 2.0 
modifies the XML Schema definition of the xs:schema element information item to 
make the targetNamespace attribute information item required.

-schema-0019.ref = 3.1.2.1

-schema-0019.assertion = The targetNamespace attribute information item defines 
the namespace of the element declarations and type definitions inlined in its 
[owner element] xs:schema element information item. WSDL 2.0 modifies the XML 
Schema definition of the xs:schema element information item to make this 
attribute information item required.

-

-schema-0020 = 

-schema-0020.ref = 3.1.3

-schema-0020.assertion = An element attribute information item MUST NOT refer 
to a global xs:simpleType or xs:complexType definition.

-

-schema-0021 = 

-schema-0021.ref = 3.2

-schema-0021.assertion = A specification of extension syntax for an alternative 
schema language MUST use a namespace that is different than the namespace of 
XML Schema. The namespace of the alternative schema language is used for 
element information items that are children of the wsdl:types element 
information item and for any extensibility attribute information items that 
appear on other components. The namespace MUST be an absolute IRI.

-

-schema-0022 = 

-schema-0022.ref = 3.3.3

-schema-0022.assertion = The wsdlx:interface and wsdlx:binding attributes may 
be used either independently or together. If they are used together then they 
MUST satisfy the same consistency rules that apply to the {interface} property 
of a Service component and the {binding} property of a nested Endpoint 
component, that is either the binding refers the interface or the binding 
refers to no interface.

-

-types-0023 = 

-types-0023.ref = 3.2

-types-0023.assertion = A specification of extension syntax for an alternative 
schema language MUST include the declaration of an element information item, 
intended to appear as a child of the wsdl:types element information item, which 
references, names, and locates the schema instance (an ?import? element 
information item).

+Schema-0019 = The XML schema does not define a target namespace. WSDL 2.0 
modifies the XML Schema definition of the xs:schema element making the 
targetNamespace attribute required.

+Schema-0019.assertion =  The xs:schema element information item MUST contain a 
targetNamespace attribute information item.

+

+# This assertion is for interface message reference or fault

+Schema-0020 = 

+Schema-0020.assertion = An element attribute information item MUST NOT refer 
to a global xs:simpleType or xs:complexType definition.

+

+Schema-0021 = The alternative schema language makes use of the XML Schema 
namespace.

+Schema-0021.assertion = A specification of extension syntax for an alternative 
schema language MUST use a namespace that is different than the namespace of 
XML Schema.

+

+Schema-0022 = The binding '{0}' specified is not consistent with the interface 
'{1}' specified. The binding must refer to the same interface as is specified 
by the interace attribute.

+Schema-0022.assertion = If wsdlx:interface and wsdlx:binding are used together 
then they MUST satisfy the same consistency rules that apply to the {interface} 
property of a Service component and the {binding} property of a nested Endpoint 
component, that is either the binding refers the interface of the service or 
the binding refers to no interface.

+

+Schema-0052 = The imported XML Schema is not defined with the namespace '{0}' 
that is specified on the import element.

+Schema-0052.assertion = The value of the targetNamespace attribute information 
item of the xs:schema element information item of an imported schema MUST equal 
the value of the namespace of the import element information item in the 
importing WSDL 2.0 document.

+

+Schema-0053 = The namespace '{0}' specified is not an absolute IRI.

+Schema-0053.assertion = The namespace used for an alternate schema language 
MUST be an absolute IRI.

+

+Types-0023 = The alternate schema language does not include a declaration of 
an element information item to appear as a child of the types element.

+Types-0023.assertion = A specification of extension syntax for an alternative 
schema language MUST include the declaration of an element information item, 
intended to appear as a child of the wsdl:types element information item, which 
references, names, and locates the schema instance (an "import" element 
information item).

+

+

+# ---------------- WSDL Component Level Assertions -------------------

 

 description-0024 = 

 description-0024.ref = 2.1.2

 description-0024.assertion = Each WSDL 2.0 or type system component MUST be 
uniquely identified by its qualified name. That is, if two distinct components 
of the same kind (Interface, Binding, etc.) are in the same target namespace, 
then their QNames MUST be unique. However, different kinds of components (e.g., 
an Interface component and a Binding component) MAY have the same QName. Thus, 
QNames of components must be unique within the space of those components in a 
given target namespace.

 

-description-0025 = 

-description-0025.ref = 2.1.2.1

-description-0025.assertion = The type of the targetNamespace attribute 
information item is xs:anyURI. Its value MUST be an absolute IRI (see [IETF RFC 
3987]).

-

 types-0026 = 

 types-0026.ref = 2.1.2.1

 types-0026.assertion = It is an error if there are multiple type definitions 
for each QName.

@@ -143,9 +189,6 @@
 interface-0030.ref = 2.2.1

 interface-0030.assertion = For each Interface component in the {interfaces} 
property of a Description component, the {name} property MUST be unique.

 

-interface-0031 = 

-interface-0031.ref = Section 2.2.2.3

-interface-0031.assertion = The type of the styleDefault attribute information 
item is list of xs:anyURI. Its value, if present, MUST contain absolute IRIs 
(see [IETF RFC 3987]).

 

 interface-fault-0032 = 

 interface-fault-0032.ref = 2.3.1


Added: 
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java?rev=349695&view=auto
==============================================================================
--- 
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java
 (added)
+++ 
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java
 Tue Nov 29 02:17:20 2005
@@ -0,0 +1,28 @@
+/**

+ * Copyright 2005 Apached Software Foundation 

+ *

+ * Licensed 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.

+ */

+package org.apache.woden.internal.wsdl20.validation;

+

+import org.apache.woden.ErrorReporter;

+import org.apache.woden.WSDLException;

+import org.apache.woden.wsdl20.Description;

+

+public class WSDLComponentValidator 

+{

+       public void validate(Description desc, ErrorReporter errorReporter) 
throws WSDLException

+       {

+               

+       }

+}


Added: 
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java?rev=349695&view=auto
==============================================================================
--- 
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
 (added)
+++ 
incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
 Tue Nov 29 02:17:20 2005
@@ -0,0 +1,204 @@
+/**

+ * Copyright 2005 Apached Software Foundation 

+ *

+ * Licensed 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.

+ */

+package org.apache.woden.internal.wsdl20.validation;

+

+import java.net.URI;

+import java.util.Collection;

+import java.util.Iterator;

+import java.util.Map;

+

+import org.apache.woden.ErrorReporter;

+import org.apache.woden.WSDLException;

+import org.apache.woden.internal.ErrorLocatorImpl;

+import org.apache.woden.internal.schema.ImportedSchemaImpl;

+import org.apache.woden.internal.schema.InlinedSchemaImpl;

+import org.apache.woden.wsdl20.xml.DescriptionElement;

+import org.apache.woden.wsdl20.xml.TypesElement;

+

+/**

+ * The WSDL document validator validates a WSDL XML model against the

+ * document assertions specified in the WSDL 2.0 specification.

+ */

+public class WSDLDocumentValidator 

+{

+  /**

+   * Validate the document representation of the WSDL document against

+   * the WSDL 2.0 specification.

+   * 

+   * @param descElement The WSDL 2.0 XML model description element.

+   * @param errorReporter The error reporter to use for any errors.

+   * @return True if the WSDL document representation is valid, false 
otherwise.

+   * @throws WSDLException

+   */

+  public boolean validate(DescriptionElement descElement, ErrorReporter 
errorReporter) throws WSDLException

+  {

+    boolean isValid = true;

+    isValid = testAssertionDescription0025(descElement, errorReporter);

+         

+       if(isValid)

+         isValid = validateTypes(descElement.getTypesElement(), errorReporter);

+               // 1. Call the validators for specific namespaces

+               //    - Does this need to be broken up into XML specific and 
compoent model?

+               // 2. Call post validators

+       //      validateTypes(descElement.getTypesElement(), errorReporter);

+//             Description descComponent = 
descElement.getDescriptionComponent();

+//             validateInterfaces(descComponent.getInterfaces(), 
errorReporter);

+//             

+               // TODO: validate bindings, services, and extension elements

+         

+    return isValid;

+  }

+       

+  protected boolean validateTypes(TypesElement types, ErrorReporter 
errorReporter) throws WSDLException

+  {

+       boolean isValid = true;

+       Map schemaMap = types.getSchemas();

+       Collection schemas = schemaMap.values();

+       Iterator schemaIter = schemas.iterator();

+       while(schemaIter.hasNext())

+       {

+         Object obj = schemaIter.next();

+         // Test imported schema assertions

+         if(obj instanceof ImportedSchemaImpl)

+         {

+               ImportedSchemaImpl schema = (ImportedSchemaImpl)obj;

+               

+               if(isValid)

+                 isValid = testAssertionSchema0017(schema, errorReporter);

+               else

+                 testAssertionSchema0017(schema, errorReporter);

+               

+               if(isValid)

+                 isValid = testAssertionSchema0052(schema, errorReporter);

+               else

+                 testAssertionSchema0052(schema, errorReporter);

+                 

+         }

+         else

+         {

+               InlinedSchemaImpl schema = (InlinedSchemaImpl)obj;

+                 

+         }

+       }

+         //Schema-0016 = XML Schema component '{0}' has been referenced but 
its namespace is not available. In order to reference components from a XML 
Schema it must be imported or defined inline.

+//             Schema-0016.ref = 3.1

+//             Schema-0016.assertion = A WSDL 2.0 document MUST NOT refer to 
XML Schema components in a given namespace unless an xs:import or xs:schema 
element information item for that namespace is present or the namespace is the 
XML Schema namespace which contains built-in types as defined in XML Schema 
Part 2: Datatypes Second Edition [XML Schema: Datatypes].

+       //

+

+//             

+//             

+//

+//             #schema-0017b is a replacement for WSDL502

+//             WSDL502=The namespace "{0}" specified on a schema import 
element does not match the target namespace "{1}" of the schema at the 
schemaLocation "{2}".

+//

+//             Schema-0018 = The element '{0}' has already been defined in 
another inline XML Schema.

+//             Schema-0018.ref = 3.1.2

+//             Schema-0018.assertion = A WSDL 2.0 document MUST NOT define the 
same element or type in more than one inlined schema.

+//

+//             Schema-0018b = The type '{0}' has already been defined in 
another inline XML Schema.

+//             Schema-0018b.ref = 3.1.2

+//             Schema-0018b.assertion = A WSDL 2.0 document MUST NOT define 
the same element or type in more than one inlined schema.

+//

+//             # error schema-0019 is a replacement for WSDL503

+//             WSDL503=An XML schema is missing its target namespace 
attribute. Schema id is "{0}"

+//             Schema-0019 = The XML schema does not define a target 
namespace. WSDL 2.0 modifies the XML Schema definition of the xs:schema element 
making the targetNamespace attribute required.

+//             Schema-0019.ref = 3.1.2.1

+//             Schema-0019.assertion =  The xs:schema element information item 
MUST contain a targetNamespace attribute information item.

+//

+//             # This assertion is for interface message reference or fault

+//             Schema-0020 = 

+//             Schema-0020.ref = 3.1.3

+//             Schema-0020.assertion = An element attribute information item 
MUST NOT refer to a global xs:simpleType or xs:complexType definition.

+//

+//             Schema-0021 = The alternative schema language makes use of the 
XML Schema namespace.

+//             Schema-0021.ref = 3.2

+//             Schema-0021.assertion = A specification of extension syntax for 
an alternative schema language MUST use a namespace that is different than the 
namespace of XML Schema.

+//

+//             Schema-0022 = The binding '{0}' specified is not consistent 
with the interface '{1}' specified. The binding must refer to the same 
interface as is specified by the interace attribute.

+//             Schema-0022.ref = 3.3.3

+//             Schema-0022.assertion = If wsdlx:interface and wsdlx:binding 
are used together then they MUST satisfy the same consistency rules that apply 
to the {interface} property of a Service component and the {binding} property 
of a nested Endpoint component, that is either the binding refers the interface 
of the service or the binding refers to no interface.

+//

+//             Schema-0053 = The namespace '{0}' specified is not an absolute 
IRI.

+//             Schema-0053.assertion = The namespace used for an alternate 
schema language MUST be an absolute IRI.

+//

+//             Types-0023 = The alternate schema language does not include a 
declaration of an element information item to appear as a child of the types 
element.

+//             Types-0023.ref = 3.2

+//             Types-0023.assertion = A specification of extension syntax for 
an alternative schema language MUST include the declaration of an element 
information item, intended to appear as a child of the wsdl:types element 
information item, which references, names, and locates the schema instance (an 
"import" element information item).

+               return isValid;

+  }

+       

+  /**

+   * Test assertion Description-0025. Tests whether the target namespace

+   * specified is an absolute IRI.

+   * 

+   * @param descElement The description element for which to check the target 
namespace.

+   * @param errorReporter The error reporter.

+   * @return True if the assertion passes, false otherwise.

+   * @throws WSDLException

+   */

+  protected boolean testAssertionDescription0025(DescriptionElement 
descElement, ErrorReporter errorReporter) throws WSDLException

+  {

+    URI targetNS = descElement.getTargetNamespace();

+    if(!targetNS.isAbsolute())

+    {

+      errorReporter.reportError(new ErrorLocatorImpl(), "Description-0025", 
new Object[]{targetNS}, ErrorReporter.SEVERITY_ERROR);

+      return false;

+       }

+    return true;

+  }

+

+  /**

+   * Test assertion Schema-0017. An imported schema must contain a

+   * target namespace.

+   * 

+   * @param schema The imported schema to check.

+   * @param errorReporter The error reporter.

+   * @return True if the assertion passes, false otherwise.

+   * @throws WSDLException

+   */

+  protected boolean testAssertionSchema0017(ImportedSchemaImpl schema, 
ErrorReporter errorReporter) throws WSDLException

+  {

+       String targetNS = schema.getSchemaDefinition().getTargetNamespace();

+       if(targetNS == null || targetNS.equals(""))

+       {

+         errorReporter.reportError(new ErrorLocatorImpl(), "Schema-0017", new 
Object[]{schema.getSchemaLocation()}, ErrorReporter.SEVERITY_ERROR);

+         return false;

+       }

+       return true;

+  }

+  

+  /**

+   * Test assertion Schema-0052. An imported schema must specify the

+   * same target namespace as the import element.

+   * 

+   * @param schema The imported schema to check.

+   * @param errorReporter The error reporter.

+   * @return True if the assertion passes, false otherwise.

+   * @throws WSDLException

+   */

+  protected boolean testAssertionSchema0052(ImportedSchemaImpl schema, 
ErrorReporter errorReporter) throws WSDLException

+  {

+       String importedSchemaTargetNS = 
schema.getSchemaDefinition().getTargetNamespace();

+       String specifiedTargetNS = schema.getNamespace().toString();

+       if(specifiedTargetNS != null && 
!specifiedTargetNS.equals(importedSchemaTargetNS))

+       {

+         errorReporter.reportError(new ErrorLocatorImpl(), "Schema-0052", new 
Object[]{specifiedTargetNS}, ErrorReporter.SEVERITY_ERROR);

+         return false;

+       }

+       return true;

+  }

+  

+}


Added: 
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/TestErrorHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/TestErrorHandler.java?rev=349695&view=auto
==============================================================================
--- 
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/TestErrorHandler.java
 (added)
+++ 
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/TestErrorHandler.java
 Tue Nov 29 02:17:20 2005
@@ -0,0 +1,75 @@
+/**

+ * Copyright 2005 Apache Software Foundation 

+ *

+ * Licensed 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.

+ */

+package org.apache.woden.internal.wsdl20.validation;

+

+import java.util.Hashtable;

+

+import org.apache.woden.ErrorHandler;

+import org.apache.woden.ErrorInfo;

+

+/**

+ * An error handler that will allow the test cases to get access to the

+ * errors and warnings reported by the validators.

+ */

+public class TestErrorHandler implements ErrorHandler 

+{

+  public Hashtable warnings = new Hashtable();

+  public Hashtable errors = new Hashtable();

+  public Hashtable fatalErrors = new Hashtable();

+

+  /**

+   * Reset the handler. Remove all messages stored in the handler.

+   */

+  public void reset()

+  {

+       warnings.clear();

+       errors.clear();

+       fatalErrors.clear();

+  }

+  

+  public boolean messageHasBeenReported()

+  {

+       if(warnings.size() > 0 || errors.size() > 0 || fatalErrors.size() > 0)

+         return true;

+       return false;

+  }

+  /* (non-Javadoc)

+   * @see org.apache.woden.ErrorHandler#warning(org.apache.woden.ErrorInfo)

+   */

+  public void warning(ErrorInfo errorInfo)

+  {

+    warnings.put(errorInfo.getKey(), errorInfo);

+  }

+

+  /* (non-Javadoc)

+   * @see org.apache.woden.ErrorHandler#error(org.apache.woden.ErrorInfo)

+   */

+  public void error(ErrorInfo errorInfo) 

+  {

+    errors.put(errorInfo.getKey(), errorInfo);

+  }

+

+  /* (non-Javadoc)

+   * @see org.apache.woden.ErrorHandler#fatalError(org.apache.woden.ErrorInfo)

+   */

+  public void fatalError(ErrorInfo errorInfo) 

+  {

+    fatalErrors.put(errorInfo.getKey(), errorInfo);

+  }

+  

+  

+

+}


Added: 
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java?rev=349695&view=auto
==============================================================================
--- 
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
 (added)
+++ 
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
 Tue Nov 29 02:17:20 2005
@@ -0,0 +1,354 @@
+/**

+ * Copyright 2005 Apache Software Foundation 

+ *

+ * Licensed 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.

+ */

+package org.apache.woden.internal.wsdl20.validation;

+

+import java.net.URI;

+import java.net.URISyntaxException;

+

+import junit.framework.Test;

+import junit.framework.TestCase;

+import junit.framework.TestSuite;

+

+import org.apache.woden.ErrorReporter;

+import org.apache.woden.WSDLException;

+import org.apache.woden.internal.DOMWSDLFactory;

+import org.apache.woden.internal.ErrorReporterImpl;

+import org.apache.woden.internal.schema.ImportedSchemaImpl;

+import org.apache.woden.wsdl20.xml.DescriptionElement;

+import org.apache.ws.commons.schema.XmlSchema;

+

+public class WSDLDocumentValidatorTest extends TestCase 

+{

+  private WSDLDocumentValidator val;

+  private ErrorReporter reporter;

+  private TestErrorHandler handler;

+  

+  public static Test suite()

+  {

+       return new TestSuite(WSDLDocumentValidatorTest.class);

+  }

+  

+  protected void setUp() throws Exception 

+  {

+    val = new WSDLDocumentValidator();

+    handler = new TestErrorHandler();

+    reporter = new ErrorReporterImpl();

+    reporter.setErrorHandler(handler);

+  }

+

+  protected void tearDown() throws Exception 

+  {

+    val = null;

+    reporter = null;

+    handler = null;

+  }

+  

+  /**

+   * Test that the testAssertionDescription0025 method returns

+   * true if given a description element with an absolute IRI,

+   * false otherwise.

+   */

+  public void testTestAssertionDescription0025()

+  {

+       // Test that no error is reported with an absolute IRI.

+       handler.reset();

+       try

+       {

+         DescriptionElement desc = new DOMWSDLFactory().newDescription();

+         desc.setTargetNamespace(new URI("http://www.sample.org";));

+         

+         if(!val.testAssertionDescription0025(desc, reporter))

+         {

+               fail("A message was reported for a description element with an 
absolute IRI.");

+         }

+       }

+       catch(Exception e)

+       {

+         fail("There was a problem while testing an absolute IRI.");

+       }

+       

+    // Test that error Description-0025 is reported for a relative IRI.

+       handler.reset();

+       try

+       {

+         DescriptionElement desc = new DOMWSDLFactory().newDescription();

+         desc.setTargetNamespace(new URI("//www.sample.org"));

+         boolean isValid = val.testAssertionDescription0025(desc, reporter);

+         if(isValid)

+         {

+               fail("No message was reported for a description element with 
the relative IRI //www.sample.org.");

+         }

+         else if(handler.warnings.size() > 0)

+         {

+               fail("A warning was reported for a description element with the 
relative IRI //www.sample.org.");

+         }

+         else if(handler.fatalErrors.size() > 0)

+         {

+               fail("A fatal error was reported for a description element with 
the relative IRI //www.sample.org.");

+         }

+         else if(handler.errors.size() != 1)

+         {

+               fail("More than one error was reported for a description 
element with the relative IRI //www.sample.org.");

+         }

+         else if(!handler.errors.containsKey("Description-0025"))

+         {

+               fail("The error for Description-0025 was not reported for a 
description element with the relative IRI //www.sample.org.");

+         }

+       }

+       catch(Exception e)

+       {

+         fail("There was a problem while testing an absolute IRI.");

+       }

+         

+  }

+  

+  /**

+   * Test assertion Schema-0052. An imported schema must contain the

+   * same target namespace as the import element.

+   */

+  public void testTestAssertionSchema0052()

+  {

+       // Test that no error is reported for an imported schema that has

+       // the same target namespace as the imported element.

+       handler.reset();

+       try

+       {

+         ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();

+       

+         importedSchema.setNamespace(new URI("http://www.sample.org";));

+       

+       

+         XmlSchema schema = new XmlSchema("http://www.sample.org";, null);

+         importedSchema.setSchemaDefinition(schema);

+         if(!val.testAssertionSchema0052(importedSchema, reporter))

+         {

+               fail("The testAssertionSchema0052 method returned false for a 
schema with the same target namespace as the import element.");

+         }

+       }

+       catch(URISyntaxException e)

+       {

+         fail("There was a problem setting the namespace of the imported 
schema: " + e);

+       }

+       catch(WSDLException e)

+       {

+         fail("There was a problem running the test assertion method " + e);

+    }

+       

+       // Test that an error is reported for an imported schema that has

+       // a different defined target namespace than the import element.

+       handler.reset();

+       try

+       {

+         ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();

+       

+         importedSchema.setNamespace(new URI("http://www.sample.org";));

+       

+       

+         XmlSchema schema = new 
XmlSchema("http://differentnamespace.sample.org";, null);

+         importedSchema.setSchemaDefinition(schema);

+         if(val.testAssertionSchema0052(importedSchema, reporter))

+         {

+               fail("There was no error reported for a schema with a different 
target namespace than the import element.");

+         }

+         else if(handler.errors.size() > 1)

+         {

+               fail("More than one error was reported for a schema with a 
different target namespace than the import element.");

+         }

+         else if(!handler.errors.containsKey("Schema-0052"))

+         {

+               fail("The error Schema-0052 was not reported for a schema with 
a different target namespace than the import element.");

+         }

+       }

+       catch(URISyntaxException e)

+       {

+         fail("There was a problem setting the namespace of the imported 
schema: " + e);

+       }

+       catch(WSDLException e)

+       {

+         fail("There was a problem running the test assertion method " + e);

+    }

+       

+    // Test that an error is reported for an imported schema that has

+       // no defined target namespace.

+       handler.reset();

+       try

+       {

+         ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();

+       

+         importedSchema.setNamespace(new URI("http://www.sample.org";));

+       

+       

+         XmlSchema schema = new XmlSchema(null, null);

+         importedSchema.setSchemaDefinition(schema);

+         if(val.testAssertionSchema0052(importedSchema, reporter))

+         {

+               fail("There was no error reported for a schema with a null 
target namespace.");

+         }

+         else if(handler.errors.size() > 1)

+         {

+               fail("More than one error was reported for a schema with a null 
target namespace.");

+         }

+         else if(!handler.errors.containsKey("Schema-0052"))

+         {

+               fail("The error Schema-0052 was not reported for a schema with 
a null target namespace.");

+         }

+       }

+       catch(URISyntaxException e)

+       {

+         fail("There was a problem setting the namespace of the imported 
schema: " + e);

+       }

+       catch(WSDLException e)

+       {

+         fail("There was a problem running the test assertion method " + e);

+    }

+       

+    // Test that an error is reported for an imported schema that has

+       // an empty defined target namespace.

+       handler.reset();

+       try

+       {

+         ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();

+       

+         importedSchema.setNamespace(new URI("http://www.sample.org";));

+       

+       

+         XmlSchema schema = new XmlSchema("", null);

+         importedSchema.setSchemaDefinition(schema);

+         if(val.testAssertionSchema0052(importedSchema, reporter))

+         {

+               fail("There was no error reported for a schema with an empty 
target namespace.");

+         }

+         else if(handler.errors.size() > 1)

+         {

+               fail("More than one error was reported for a schema with an 
empty target namespace.");

+         }

+         else if(!handler.errors.containsKey("Schema-0052"))

+         {

+               fail("The error Schema-0052 was not reported for a schema with 
an empty target namespace.");

+         }

+       }

+       catch(URISyntaxException e)

+       {

+         fail("There was a problem setting the namespace of the imported 
schema: " + e);

+       }

+       catch(WSDLException e)

+       {

+         fail("There was a problem running the test assertion method " + e);

+    }

+  }

+  

+  /**

+   * Test assertion Schema-0017. An imported schema must contain a

+   * target namespace.

+   */

+  public void testTestAssertionSchema0017()

+  {

+       // Test that no error is reported for an imported schema that has

+       // defined a target namespace.

+       handler.reset();

+       try

+       {

+         ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();

+       

+         importedSchema.setNamespace(new URI("http://www.sample.org";));

+       

+       

+         XmlSchema schema = new XmlSchema("http://www.sample.org";, null);

+         importedSchema.setSchemaDefinition(schema);

+         if(!val.testAssertionSchema0017(importedSchema, reporter))

+         {

+               fail("The testAssertionSchema0017 method returned false for a 
schema with a target namespace.");

+         }

+       }

+       catch(URISyntaxException e)

+       {

+         fail("There was a problem setting the namespace of the imported 
schema: " + e);

+       }

+       catch(WSDLException e)

+       {

+         fail("There was a problem running the test assertion method " + e);

+    }

+       

+    // Test that an error is reported for an imported schema that has

+       // no defined target namespace.

+       handler.reset();

+       try

+       {

+         ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();

+       

+         importedSchema.setNamespace(new URI("http://www.sample.org";));

+       

+       

+         XmlSchema schema = new XmlSchema(null, null);

+         importedSchema.setSchemaDefinition(schema);

+         if(val.testAssertionSchema0017(importedSchema, reporter))

+         {

+               fail("There was no error reported for a schema with a null 
target namespace.");

+         }

+         else if(handler.errors.size() > 1)

+         {

+               fail("More than one error was reported for a schema with a null 
target namespace.");

+         }

+         else if(!handler.errors.containsKey("Schema-0017"))

+         {

+               fail("The error Schema-0017 was not reported for a schema with 
a null target namespace.");

+         }

+       }

+       catch(URISyntaxException e)

+       {

+         fail("There was a problem setting the namespace of the imported 
schema: " + e);

+       }

+       catch(WSDLException e)

+       {

+         fail("There was a problem running the test assertion method " + e);

+    }

+       

+    // Test that an error is reported for an imported schema that has

+       // an empty defined target namespace.

+       handler.reset();

+       try

+       {

+         ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();

+       

+         importedSchema.setNamespace(new URI("http://www.sample.org";));

+       

+       

+         XmlSchema schema = new XmlSchema("", null);

+         importedSchema.setSchemaDefinition(schema);

+         if(val.testAssertionSchema0017(importedSchema, reporter))

+         {

+               fail("There was no error reported for a schema with an empty 
target namespace.");

+         }

+         else if(handler.errors.size() > 1)

+         {

+               fail("More than one error was reported for a schema with an 
empty target namespace.");

+         }

+         else if(!handler.errors.containsKey("Schema-0017"))

+         {

+               fail("The error Schema-0017 was not reported for a schema with 
an empty target namespace.");

+         }

+       }

+       catch(URISyntaxException e)

+       {

+         fail("There was a problem setting the namespace of the imported 
schema: " + e);

+       }

+       catch(WSDLException e)

+       {

+         fail("There was a problem running the test assertion method " + e);

+    }

+       

+  }

+}


Modified: incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java?rev=349695&r1=349694&r2=349695&view=diff
==============================================================================
--- incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java 
(original)
+++ incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java Tue Nov 
29 02:17:20 2005
@@ -23,6 +23,7 @@
 import org.apache.woden.WSDLFactoryTest;

 import org.apache.woden.WSDLReaderTest;

 import org.apache.woden.internal.ReaderFeaturesTest;

+import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidatorTest;

 import org.apache.woden.tests.wsdl20.W3CTestSuiteTest;

 

 public class AllWodenTests extends TestSuite 

@@ -60,6 +61,7 @@
        addTest(WSDLReaderTest.suite());

        addTest(W3CTestSuiteTest.suite());

        addTestSuite(ReaderFeaturesTest.class);

+       addTest(WSDLDocumentValidatorTest.suite());

   }

        

 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to