You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by lm...@apache.org on 2005/12/04 22:32:35 UTC

svn commit: r353916 - in /incubator/woden/java: src/org/apache/woden/internal/Messages.properties src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java

Author: lmandel
Date: Sun Dec  4 13:32:27 2005
New Revision: 353916

URL: http://svn.apache.org/viewcvs?rev=353916&view=rev
Log:
Added validation and tests for assertions Schema-0016, Schema-0020, Schema-0020b.

Modified:
    incubator/woden/java/src/org/apache/woden/internal/Messages.properties
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
    incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java

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=353916&r1=353915&r2=353916&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/Messages.properties (original)
+++ incubator/woden/java/src/org/apache/woden/internal/Messages.properties Sun Dec  4 13:32:27 2005
@@ -124,7 +124,7 @@
 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 = A component in the XML Schema namespace '{0}' has been referenced but this namespace is not available. In order to reference components from a XML Schema namespace the namespace 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
@@ -146,9 +146,13 @@
 Schema-0019 = The XML schema does not define a target namespace. A target namespace must be defined on all WSDL 2.0 inlined XML Schemas.
 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 = 
+# This assertion is for interface message reference
+Schema-0020 = The message reference '{0}' refers to the type definition '{1}'. A message reference must refer to an element definition. 
 Schema-0020.assertion = An element attribute information item MUST NOT refer to a global xs:simpleType or xs:complexType definition.
+
+# This assertion is for interface fault
+Schema-0020b = The fault '{0}' refers to the type definition '{1}'. A fault must refer to an element definition. 
+Schema-0020b.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.

Modified: 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=353916&r1=353915&r2=353916&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java Sun Dec  4 13:32:27 2005
@@ -26,11 +26,16 @@
 import org.apache.woden.ErrorReporter;
 import org.apache.woden.WSDLException;
 import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.internal.wsdl20.Constants;
 import org.apache.woden.schema.ImportedSchema;
 import org.apache.woden.schema.InlinedSchema;
+import org.apache.woden.schema.Schema;
 import org.apache.woden.wsdl20.xml.DescriptionElement;
 import org.apache.woden.wsdl20.xml.ImportElement;
 import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
+import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
 import org.apache.woden.wsdl20.xml.TypesElement;
 import org.apache.ws.commons.schema.XmlSchemaObjectTable;
 
@@ -70,7 +75,7 @@
 	if(!validateTypes(descElement.getTypesElement(), errorReporter))
 	  isValid = false;
 	
-	if(!validateInterfaces(descElement.getInterfaceElements(), errorReporter))
+	if(!validateInterfaces(descElement, descElement.getInterfaceElements(), errorReporter))
 	  isValid = false;
 
 		// 1. Call the validators for specific namespaces
@@ -139,7 +144,7 @@
    * @return True if all the interface related assertions pass, false otherwise.
    * @throws WSDLException
    */
-  protected boolean validateInterfaces(InterfaceElement[] interfaces, ErrorReporter errorReporter) throws WSDLException
+  protected boolean validateInterfaces(DescriptionElement descElement, InterfaceElement[] interfaces, ErrorReporter errorReporter) throws WSDLException
   {
 	boolean isValid = true;
 	
@@ -150,12 +155,47 @@
 	  
 	  if(!testAssertionInterface0031(interfaceElem, errorReporter))
 		isValid = false;
+	  
+	  InterfaceFaultElement[] faultElements = interfaceElem.getInterfaceFaultElements();
+	  int numFaultElements = faultElements.length;
+	  for(int j = 0; j < numFaultElements; j++)
+	  {
+		InterfaceFaultElement faultElement = faultElements[j];
+		if(!testAssertionSchema0020b(descElement, faultElement, errorReporter))
+	      isValid = false;
+		if(!testAssertionSchema0016(descElement, faultElement.getElementName().getNamespaceURI(), errorReporter))
+	      isValid = false;
+	  }
+	  
+	  
+	  InterfaceOperationElement[] interfaceOperations = interfaceElem.getInterfaceOperationElements();
+	  int numInterfaceOperations = interfaceOperations.length;
+	  for(int j = 0; j < numInterfaceOperations; j++)
+	  {
+		InterfaceOperationElement interfaceOperation = interfaceOperations[j];
+		InterfaceMessageReferenceElement[] messageReferences = interfaceOperation.getMessageReferenceElements();
+		int numMessageReferences = messageReferences.length;
+		for(int k = 0; k < numMessageReferences; k++)
+		{
+	      InterfaceMessageReferenceElement messageReference = messageReferences[k];
+	      if(!testAssertionSchema0020(descElement, messageReference, errorReporter))
+	        isValid = false;
+	      if(!testAssertionSchema0016(descElement, messageReference.getElementName().getNamespaceURI(), errorReporter))
+	    	isValid = false;
+		}
+		
+//		FaultReferenceElement[] faultReferences = interfaceOperation.getFaultReferenceElements();
+//		int numFaultReferences = faultReferences.length;
+//		for(int k = 0; k < numFaultReferences; k++)
+//		{
+//	      FaultReferenceElement faultReference = faultReferences[k];
+//	      if(!testAssertionSchema0020b(descElement, faultReference, errorReporter))
+//	        isValid = false;
+//		}
+	  }
 	}
-//	# 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.
-//
+
+	// The message label assertions use MEP definitions.
 //	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.
 	//
@@ -397,8 +437,99 @@
 	}
 	return isValid;
   }
+  
+  /**
+   * Test assertion Schema-0020. An interface message reference element must
+   * not refer to an xs:simpleType or xs:complexType.
+   * 
+   * @param descElement The description element of the document.
+   * @param messageReference The message reference to check.
+   * @param errorReporter The error Reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionSchema0020(DescriptionElement descElement, InterfaceMessageReferenceElement messageReference, ErrorReporter errorReporter) throws WSDLException
+  {
+    if(messageReference.getElement() == null)
+    {
+      QName elementName = messageReference.getElementName();
+      if(descElement.toComponent().getTypeDefinition(elementName) != null)
+      {
+    	errorReporter.reportError(new ErrorLocatorImpl(), "Schema-0020", new Object[]{messageReference.getMessageLabel(), elementName}, ErrorReporter.SEVERITY_ERROR);
+  	    return false;
+      }
+    }
+    return true;
+  }
+  
+  /**
+   * Test assertion Schema-0020. An interface fault element must
+   * not refer to an xs:simpleType or xs:complexType.
+   * 
+   * @param descElement The description element of the document.
+   * @param faultElement The fault element to check.
+   * @param errorReporter The error Reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionSchema0020b(DescriptionElement descElement, InterfaceFaultElement faultElement, ErrorReporter errorReporter) throws WSDLException
+  {
+    if(faultElement.getElement() == null)
+    {
+      QName elementName = faultElement.getElementName();
+      if(descElement.toComponent().getTypeDefinition(elementName) != null)
+      {
+    	errorReporter.reportError(new ErrorLocatorImpl(), "Schema-0020b", new Object[]{faultElement.getName(), elementName}, ErrorReporter.SEVERITY_ERROR);
+  	    return false;
+      }
+    }
+    return true;
+  }
+  
+  /**
+   * Test assertion Schema-0016. References to XML schema components must only refer
+   * to elements and types in namespaces that have been imported or inlined or that
+   * are part of the XML schema namespace.
+   * 
+   * @param descElement The description element of the document.
+   * @param namespace Check this namespace to see if it has been defined.
+   * @param errorReporter The error Reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionSchema0016(DescriptionElement descElement, String namespace, ErrorReporter errorReporter) throws WSDLException
+  {
+    if(!namespace.equals(Constants.TYPE_XSD_2001))
+    {
+      TypesElement types = descElement.getTypesElement();
+      if(types == null)
+      {
+    	errorReporter.reportError(new ErrorLocatorImpl(), "Schema-0016", new Object[]{namespace}, ErrorReporter.SEVERITY_ERROR);
+        return false;
+      }
+      Schema[] schemas = types.getSchemas();
+      int numSchemas = schemas.length;
+      boolean schemaNotFound = true;
+      // TODO: This linear search should be improved for performance.
+      for(int i = 0; i < numSchemas; i++)
+      {
+    	if(schemas[i].getNamespace().toString().equals(namespace))
+    	{
+          schemaNotFound = false;
+    	  break;
+    	}
+      }
+      if(schemaNotFound)
+      {
+        errorReporter.reportError(new ErrorLocatorImpl(), "Schema-0016", new Object[]{namespace}, ErrorReporter.SEVERITY_ERROR);
+      	return false;
+      } 
+    }
+    return true;
+  }
 
-  //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.
+  // # may also be needed for binding.
+  //Schema-0016 = A component in the XML Schema namespace '{0}' has been referenced but this namespace is not available. In order to reference components from a XML Schema namespace the namespace 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].
 

Modified: 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=353916&r1=353915&r2=353916&view=diff
==============================================================================
--- incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java (original)
+++ incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java Sun Dec  4 13:32:27 2005
@@ -21,6 +21,8 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 
+import javax.xml.namespace.QName;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -31,10 +33,17 @@
 import org.apache.woden.internal.ErrorReporterImpl;
 import org.apache.woden.internal.schema.ImportedSchemaImpl;
 import org.apache.woden.internal.schema.InlinedSchemaImpl;
+import org.apache.woden.internal.wsdl20.Constants;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
 import org.apache.woden.internal.wsdl20.InterfaceImpl;
+import org.apache.woden.schema.ImportedSchema;
 import org.apache.woden.schema.InlinedSchema;
 import org.apache.woden.wsdl20.xml.DescriptionElement;
 import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
+import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.xerces.parsers.DOMParser;
@@ -884,5 +893,343 @@
     }
   }
   
+  /**
+   * Test assertion Schema-0020. An interface message reference must not refer
+   * to an xs:simpleType or xs:complexType.
+   */
+  public void testTestAssertionSchema0020()
+  {
+	// Create a schema for use in the tests and add it to a types section.
+	TypesElement types = new DescriptionImpl().createTypesElement();
+	String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
+		  + "<complexType name=\"myType\">"     
+		  + "<sequence>"     
+          + "<element  name=\"element\" type=\"string\"/>"      
+          + "</sequence>"     
+          + "</complexType>" 
+          +	"<element name=\"myElement\" type=\"string\"/>"
+          + "</schema>";
+	try
+	{
+	  DOMParser builder = new DOMParser();
+	  Reader reader = new StringReader(schemaString);
+      XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
+      builder.parse(is);
+      Document schemaDoc1 = builder.getDocument();
+      XmlSchemaCollection xsc = new XmlSchemaCollection();
+      XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
+      URI schemaNS = new URI("http://www.sample.org");
+      InlinedSchema schema = new InlinedSchemaImpl();
+      schema.setSchemaDefinition(xs1);
+      schema.setNamespace(schemaNS);
+      types.addSchema(schema);
+	}
+	catch(Exception e)
+	{
+	  fail("An error occurred while creating the sample types section.");
+	}
+    
+	// Test that an interface message reference with a reference to an element
+	// does not return an error.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      descElem.setTypesElement(types);
+      InterfaceElement interfaceElem = descElem.createInterfaceElement();
+      InterfaceOperationElement interfaceOperation = descElem.createInterfaceOperationElement();
+      InterfaceMessageReferenceElement messageRef = descElem.createInterfaceMessageReferenceElement();
+      messageRef.setElementName(new QName("http://www.sample.org", "myElement"));
+      interfaceOperation.addMessageReferenceElement(messageRef);
+      interfaceElem.addInterfaceOperationElement(interfaceOperation);
+      descElem.addInterfaceElement(interfaceElem);
+      
+	  if(!val.testAssertionSchema0020(descElem, messageRef, reporter))
+	  {
+	    fail("The testAssertionSchema0020 method returned false for an message reference that refers to a valid element.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+    // Test that an interface message reference with a reference to an element
+	// that has not been defined does not return an error. This problem is checked
+	// by another assertion.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      descElem.setTypesElement(types);
+      InterfaceElement interfaceElem = descElem.createInterfaceElement();
+      InterfaceOperationElement interfaceOperation = descElem.createInterfaceOperationElement();
+      InterfaceMessageReferenceElement messageRef = descElem.createInterfaceMessageReferenceElement();
+      messageRef.setElementName(new QName("http://www.sample.org", "myElement2"));
+      interfaceOperation.addMessageReferenceElement(messageRef);
+      interfaceElem.addInterfaceOperationElement(interfaceOperation);
+      descElem.addInterfaceElement(interfaceElem);
+      
+	  if(!val.testAssertionSchema0020(descElem, messageRef, reporter))
+	  {
+	    fail("The testAssertionSchema0020 method returned false for an message reference that refers to an element that has not been defined.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+    // Test that an interface message reference with a reference to a type
+	// returns an error. 
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      descElem.setTypesElement(types);
+      InterfaceElement interfaceElem = descElem.createInterfaceElement();
+      InterfaceOperationElement interfaceOperation = descElem.createInterfaceOperationElement();
+      InterfaceMessageReferenceElement messageRef = descElem.createInterfaceMessageReferenceElement();
+      messageRef.setElementName(new QName("http://www.sample.org", "myType"));
+      interfaceOperation.addMessageReferenceElement(messageRef);
+      interfaceElem.addInterfaceOperationElement(interfaceOperation);
+      descElem.addInterfaceElement(interfaceElem);
+      
+	  if(val.testAssertionSchema0020(descElem, messageRef, reporter))
+	  {
+	    fail("The testAssertionSchema0020 method returned true for an message reference that refers to a type.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+  }
   
+  /**
+   * Test assertion Schema-0020b. An interface fault must not refer
+   * to an xs:simpleType or xs:complexType.
+   */
+  public void testTestAssertionSchema0020b()
+  {
+	// Create a schema for use in the tests and add it to a types section.
+	TypesElement types = new DescriptionImpl().createTypesElement();
+	String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
+		  + "<complexType name=\"myType\">"     
+		  + "<sequence>"     
+          + "<element  name=\"element\" type=\"string\"/>"      
+          + "</sequence>"     
+          + "</complexType>" 
+          +	"<element name=\"myElement\" type=\"string\"/>"
+          + "</schema>";
+	try
+	{
+	  DOMParser builder = new DOMParser();
+	  Reader reader = new StringReader(schemaString);
+      XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
+      builder.parse(is);
+      Document schemaDoc1 = builder.getDocument();
+      XmlSchemaCollection xsc = new XmlSchemaCollection();
+      XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
+      URI schemaNS = new URI("http://www.sample.org");
+      InlinedSchema schema = new InlinedSchemaImpl();
+      schema.setSchemaDefinition(xs1);
+      schema.setNamespace(schemaNS);
+      types.addSchema(schema);
+	}
+	catch(Exception e)
+	{
+	  fail("An error occurred while creating the sample types section.");
+	}
+    
+	// Test that an interface fault with a reference to an element
+	// does not return an error.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      descElem.setTypesElement(types);
+      InterfaceElement interfaceElem = descElem.createInterfaceElement();
+      InterfaceFaultElement fault = descElem.createInterfaceFaultElement();
+      fault.setElementName(new QName("http://www.sample.org", "myElement"));
+      interfaceElem.addInterfaceFaultElement(fault);
+      descElem.addInterfaceElement(interfaceElem);
+      
+	  if(!val.testAssertionSchema0020b(descElem, fault, reporter))
+	  {
+	    fail("The testAssertionSchema0020b method returned false for a fault that refers to a valid element.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+    // Test that an interface fault with a reference to an element
+	// that has not been defined does not return an error. This problem is checked
+	// by another assertion.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      descElem.setTypesElement(types);
+      InterfaceElement interfaceElem = descElem.createInterfaceElement();
+      InterfaceFaultElement fault = descElem.createInterfaceFaultElement();
+      fault.setElementName(new QName("http://www.sample.org", "myElement2"));
+      interfaceElem.addInterfaceFaultElement(fault);
+      descElem.addInterfaceElement(interfaceElem);
+      
+	  if(!val.testAssertionSchema0020b(descElem, fault, reporter))
+	  {
+	    fail("The testAssertionSchema0020b method returned false for a fault that refers to an element that has not been defined.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+    // Test that an interface message reference with a reference to a type
+	// returns an error. 
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      descElem.setTypesElement(types);
+      InterfaceElement interfaceElem = descElem.createInterfaceElement();
+      InterfaceFaultElement fault = descElem.createInterfaceFaultElement();
+      fault.setElementName(new QName("http://www.sample.org", "myType"));
+      interfaceElem.addInterfaceFaultElement(fault);
+      descElem.addInterfaceElement(interfaceElem);
+      
+	  if(val.testAssertionSchema0020b(descElem, fault, reporter))
+	  {
+	    fail("The testAssertionSchema0020b method returned true for a fault that refers to a type.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+  }
+  
+
+  /**
+   * Test assertion Schema-0016. References to XML schema components must only refer
+   * to elements and types in namespaces that have been imported or inlined or that
+   * are part of the XML schema namespace.
+   * 
+   * TODO: Implement tests for specific elements that contain invalid references.
+   *       These tests should probably be contained in a test method for validateInterfaces, validateBindings, etc.
+   */
+  public void testTestAssertionSchema0016()
+  {
+	// Create a schema for use in the tests and add it to a types section.
+	TypesElement types = new DescriptionImpl().createTypesElement();
+	String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
+		  + "<complexType name=\"myType\">"     
+		  + "<sequence>"     
+          + "<element  name=\"element\" type=\"string\"/>"      
+          + "</sequence>"     
+          + "</complexType>" 
+          +	"<element name=\"myElement\" type=\"string\"/>"
+          + "</schema>";
+	XmlSchema xs1 = null;
+	URI schemaNS = null;
+	try
+	{
+	  DOMParser builder = new DOMParser();
+	  Reader reader = new StringReader(schemaString);
+      XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
+      builder.parse(is);
+      Document schemaDoc1 = builder.getDocument();
+      XmlSchemaCollection xsc = new XmlSchemaCollection();
+      xs1 = xsc.read(schemaDoc1.getDocumentElement());
+      schemaNS = new URI("http://www.sample.org");
+      InlinedSchema schema = new InlinedSchemaImpl();
+      schema.setSchemaDefinition(xs1);
+      schema.setNamespace(schemaNS);
+      types.addSchema(schema);
+	}
+	catch(Exception e)
+	{
+	  fail("An error occurred while creating the sample types section.");
+	}
+    
+	// Test that a reference to a namespace that is defined inline
+	// does not return an error.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      descElem.setTypesElement(types);
+      
+	  if(!val.testAssertionSchema0016(descElem, "http://www.sample.org", reporter))
+	  {
+	    fail("The testAssertionSchema0016 method returned false for a namespace that has been defined inline.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+    // Test that a reference to a namespace that is imported
+	// does not return an error.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      TypesElement typesImported = descElem.createTypesElement();
+      ImportedSchema importedSchema = new ImportedSchemaImpl();
+      importedSchema.setSchemaDefinition(xs1);
+      importedSchema.setNamespace(schemaNS);
+      typesImported.addSchema(importedSchema);
+      descElem.setTypesElement(typesImported);
+      
+	  if(!val.testAssertionSchema0016(descElem, "http://www.sample.org", reporter))
+	  {
+	    fail("The testAssertionSchema0016 method returned false for a namespace that has been imported.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+    // Test that a reference to the XML Schema namespace does not return an error.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      //descElem.setTypesElement(types);
+      
+	  if(!val.testAssertionSchema0016(descElem, Constants.TYPE_XSD_2001, reporter))
+	  {
+	    fail("The testAssertionSchema0016 method returned false for the XML Schema namespace.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+    // Test that a reference to a namespace that has not been defined inline or imported returns an error.
+	// This test also checks that the method functions correctly with no defined types element.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = new DescriptionImpl();
+      //descElem.setTypesElement(types);
+      
+	  if(val.testAssertionSchema0016(descElem, "http://www.sample2.org", reporter))
+	  {
+	    fail("The testAssertionSchema0016 method returned true for a namespace that is not available..");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+  }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org