ws-woden-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sag...@apache.org
Subject svn commit: r809833 [3/10] - in /webservices/woden/trunk/java/woden-tests: ./ src/ src/main/ src/main/resources/ src/main/resources/META-INF/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/woden/ src/test...
Date Tue, 01 Sep 2009 05:50:51 GMT
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,1168 @@
+/**
+ * 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.
+ */
+package org.apache.woden.internal.wsdl20.validation;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+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;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+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.schema.ImportedSchema;
+import org.apache.woden.schema.InlinedSchema;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+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;
+import org.apache.xerces.xni.parser.XMLInputSource;
+import org.w3c.dom.Document;
+
+/**
+ * A test class to test the assertion tests in the WSDLDocumentValidator.
+ */
+public class WSDLDocumentValidatorTest extends TestCase 
+{
+  private WSDLDocumentValidator val;
+  private ErrorReporter reporter;
+  private TestErrorHandler handler;
+  
+  /**
+   * Create a test suite from this test class.
+   * 
+   * @return A test suite from this test class.
+   */
+  public static Test suite()
+  {
+	return new TestSuite(WSDLDocumentValidatorTest.class);
+  }
+  
+  /* (non-Javadoc)
+   * @see junit.framework.TestCase#setUp()
+   */
+  protected void setUp() throws Exception 
+  {
+    val = new WSDLDocumentValidator();
+    handler = new TestErrorHandler();
+    
+    reporter = WSDLFactory.newInstance().newWSDLReader().getErrorReporter();
+    reporter.setErrorHandler(handler);
+  }
+
+  /* (non-Javadoc)
+   * @see junit.framework.TestCase#tearDown()
+   */
+  protected void tearDown() throws Exception 
+  {
+    val = null;
+    reporter = null;
+    handler = null;
+  }
+  
+  /**
+   * Test that the testAssertionDescription1006 method returns
+   * true if given a description element with an absolute IRI,
+   * false otherwise.
+   */
+  public void testTestAssertionDescription1006()
+  {
+	// Test that no error is reported with an absolute IRI.
+	handler.reset();
+	try
+	{
+	  DescriptionElement desc = WSDLFactory.newInstance().newDescription();
+	  desc.setTargetNamespace(new URI("http://www.sample.org"));
+	  
+	  if(!val.testAssertionDescription1006(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-1006 is reported for a relative IRI.
+	handler.reset();
+	try
+	{
+	  DescriptionElement desc = WSDLFactory.newInstance().newDescription();
+	  desc.setTargetNamespace(new URI("//www.sample.org"));
+	  boolean isValid = val.testAssertionDescription1006(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-1006"))
+	  {
+		fail("The error for Description-1006 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-1070. An imported schema must contain the
+   * same target namespace as the import element.
+   */
+  public void testTestAssertionSchema1070()
+  {
+    // Test that no error is reported for an imported schema that has
+	// a null schema. This error should be caught elseware.
+	handler.reset();
+	try
+	{
+	  ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();
+	  importedSchema.setNamespace(new URI("http://www.sample.org"));
+	
+	  if(!val.testAssertionSchema1070(importedSchema, reporter))
+	  {
+		fail("The testAssertionSchema1070 method returned false for a null schema.");
+	  }
+	}
+	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 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.testAssertionSchema1070(importedSchema, reporter))
+	  {
+		fail("The testAssertionSchema1070 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.testAssertionSchema1070(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-1070"))
+	  {
+		fail("The error Schema-1070 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.testAssertionSchema1070(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-1070"))
+	  {
+		fail("The error Schema-1070 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.testAssertionSchema1070(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-1070"))
+	  {
+		fail("The error Schema-1070 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-1069. An imported schema must contain a
+   * target namespace.
+   */
+  public void testTestAssertionSchema1069()
+  {
+    // Test that no error is reported for an imported schema that has
+	// a null schema. This error should be caught elseware.
+	handler.reset();
+	try
+	{
+	  ImportedSchemaImpl importedSchema = new ImportedSchemaImpl();
+	  importedSchema.setNamespace(new URI("http://www.sample.org"));
+	
+	  if(!val.testAssertionSchema1069(importedSchema, reporter))
+	  {
+		fail("The testAssertionSchema0017 method returned false for a null schema.");
+	  }
+	}
+	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 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.testAssertionSchema1069(importedSchema, reporter))
+	  {
+		fail("The testAssertionSchema1069 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.testAssertionSchema1069(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-1069"))
+	  {
+		fail("The error Schema-1069 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.testAssertionSchema1069(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-1069"))
+	  {
+		fail("The error Schema-1069 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-1073. Inline schemas must not define an element with a name
+   * of an element that has already been defined in another inline schema with the same target namespace.
+   */
+  public void testTestAssertionSchema1073()
+  {
+	String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
+		  	+ "<element name=\"myElement\" type=\"string\"/></schema>";
+    String schemaStringNS2 = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample2.org\">"
+		  	+ "<element name=\"myElement\" type=\"string\"/></schema>";
+	// Test that the method returns true for an empty list of inline schemas.
+	handler.reset();
+	try
+	{
+      InlinedSchema[] emptySchemaList = new InlinedSchema[0];
+      if(!val.testAssertionSchema1073(emptySchemaList, reporter))
+	  {
+        fail("The testAssertionSchema1073 method returned false for an empty inline schema list.");
+	  }
+    }
+    catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+    
+	// Test that two inline schemas with the same target namespace
+	// that define the same element produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[2];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	  inlinedSchemas[1] = new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+	  inlinedSchemas[1].setNamespace(new URI("http://www.sample.org"));
+	  
+	  // Create DOM representation of schema, have XmlSchema parse it.
+	  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();
+      reader = new StringReader(schemaString);
+      is = new XMLInputSource(null,null,null,reader,null);
+      builder.parse(is);
+      Document schemaDoc2 = builder.getDocument();
+      XmlSchemaCollection xsc = new XmlSchemaCollection();
+      XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
+      XmlSchemaCollection xsc2 = new XmlSchemaCollection();
+      XmlSchema xs2 = xsc2.read(schemaDoc2.getDocumentElement());
+	  inlinedSchemas[0].setSchemaDefinition(xs1);
+	  inlinedSchemas[1].setSchemaDefinition(xs2);
+	  if(val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was no error reported for an inline schema that declares the same element as another inline schema with the same namespace.");
+	  }
+	}
+	catch(URISyntaxException e)
+	{
+	  fail("There was a problem setting the namespace of the imported schema: " + e);
+	}
+	catch(IOException e)
+	{
+	  fail("There was a problem parsing the test inline schema document");
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+
+	// Test that two inline schemas with the different target namespaces
+	// that define the same element do not produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[2];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	  inlinedSchemas[1] = new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+	  inlinedSchemas[1].setNamespace(new URI("http://www.sample2.org"));
+	  
+	  // Create DOM representation of schema, have XmlSchema parse it.
+	  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();
+      reader = new StringReader(schemaStringNS2);
+      is = new XMLInputSource(null,null,null,reader,null);
+      builder.parse(is);
+      Document schemaDoc2 = builder.getDocument();
+      XmlSchemaCollection xsc = new XmlSchemaCollection();
+      XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
+      XmlSchema xs2 = xsc.read(schemaDoc2.getDocumentElement());
+	  inlinedSchemas[0].setSchemaDefinition(xs1);
+	  inlinedSchemas[1].setSchemaDefinition(xs2);
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema that declares the same element as another inline schema but has a different target namespace.");
+	  }
+	}
+	catch(URISyntaxException e)
+	{
+	  fail("There was a problem setting the namespace of the imported schema: " + e);
+	}
+	catch(IOException e)
+	{
+	  fail("There was a problem parsing the test inline schema document");
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+    // Test that only one inline schema does not produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[1];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+	  
+	  // Create DOM representation of schema, have XmlSchema parse it.
+	  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());
+	  inlinedSchemas[0].setSchemaDefinition(xs1);
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema list that contains only one inline schema.");
+	  }
+	}
+	catch(URISyntaxException e)
+	{
+	  fail("There was a problem setting the namespace of the imported schema: " + e);
+	}
+	catch(IOException e)
+	{
+	  fail("There was a problem parsing the test inline schema document");
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+	// Test that an inline schema that can not be read (that's null) does not produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[1];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema list that contains a schema that couldn't be read (is null).");
+	  }
+	}
+	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 only one inline schema does not produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[1];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+	  
+	  // Create DOM representation of schema, have XmlSchema parse it.
+	  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());
+	  inlinedSchemas[0].setSchemaDefinition(xs1);
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema list that contains only one inline schema.");
+	  }
+	}
+	catch(URISyntaxException e)
+	{
+	  fail("There was a problem setting the namespace of the imported schema: " + e);
+	}
+	catch(IOException e)
+	{
+	  fail("There was a problem parsing the test inline schema document");
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+	// Test that an inline schema with no defined target namespace doesn't produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[1];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema that contains a null namespace.");
+	  }
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+  }
+  
+  /**
+   * Test assertion Schema-1073b. Inline schemas must not define a type with a name
+   * of an type that has already been defined in another inline schema with the same target namespace.
+   */
+  public void testTestAssertionSchema1073b()
+  {
+	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>"
+          + "</schema>";
+	String schemaStringNS2 = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample2.org\">"
+		  + "<complexType name=\"myType\">"     
+		  + "<sequence>"     
+        + "<element  name=\"element\" type=\"string\"/>"      
+        + "</sequence>"     
+        + "</complexType>"
+        + "</schema>";
+	// Test that the method returns true for an empty list of inline schemas.
+	handler.reset();
+	try
+	{
+      InlinedSchema[] emptySchemaList = new InlinedSchema[0];
+      if(!val.testAssertionSchema1073(emptySchemaList, reporter))
+	  {
+        fail("The testAssertionSchema1073b method returned false for an empty inline schema list.");
+	  }
+    }
+    catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+    
+	// Test that two inline schemas with the same target namespace
+	// that define the same type produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[2];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	  inlinedSchemas[1] = new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+	  inlinedSchemas[1].setNamespace(new URI("http://www.sample.org"));
+	  
+	  // Create DOM representation of schema, have XmlSchema parse it.
+	  
+	  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();
+      reader = new StringReader(schemaString);
+      is = new XMLInputSource(null,null,null,reader,null);
+      builder.parse(is);
+      Document schemaDoc2 = builder.getDocument();
+      XmlSchemaCollection xsc = new XmlSchemaCollection();
+      XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
+      XmlSchemaCollection xsc2 = new XmlSchemaCollection();
+      XmlSchema xs2 = xsc2.read(schemaDoc2.getDocumentElement());
+	  inlinedSchemas[0].setSchemaDefinition(xs1);
+	  inlinedSchemas[1].setSchemaDefinition(xs2);
+	  if(val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was no error reported for an inline schema that declares the same type as another inline schema with the same namespace.");
+	  }
+	}
+	catch(URISyntaxException e)
+	{
+	  fail("There was a problem setting the namespace of the imported schema: " + e);
+	}
+	catch(IOException e)
+	{
+	  fail("There was a problem parsing the test inline schema document");
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+
+	// Test that two inline schemas with different target namespaces
+	// that define the same type do not produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[2];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	  inlinedSchemas[1] = new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+	  inlinedSchemas[1].setNamespace(new URI("http://www.sample2.org"));
+	  
+	  // Create DOM representation of schema, have XmlSchema parse it.
+	  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();
+      reader = new StringReader(schemaStringNS2);
+      is = new XMLInputSource(null,null,null,reader,null);
+      builder.parse(is);
+      Document schemaDoc2 = builder.getDocument();
+      XmlSchemaCollection xsc = new XmlSchemaCollection();
+      XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
+      XmlSchema xs2 = xsc.read(schemaDoc2.getDocumentElement());
+	  inlinedSchemas[0].setSchemaDefinition(xs1);
+	  inlinedSchemas[1].setSchemaDefinition(xs2);
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema that declares the same element as another inline schema but has a different target namespace.");
+	  }
+	}
+	catch(URISyntaxException e)
+	{
+	  fail("There was a problem setting the namespace of the imported schema: " + e);
+	}
+	catch(IOException e)
+	{
+	  fail("There was a problem parsing the test inline schema document");
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+    // Test that only one inline schema does not produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[1];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+	  
+	  // Create DOM representation of schema, have XmlSchema parse it.
+	  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());
+	  inlinedSchemas[0].setSchemaDefinition(xs1);
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema list that contains only one inline schema.");
+	  }
+	}
+	catch(URISyntaxException e)
+	{
+	  fail("There was a problem setting the namespace of the imported schema: " + e);
+	}
+	catch(IOException e)
+	{
+	  fail("There was a problem parsing the test inline schema document");
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+	// Test that an inline schema that can not be read (that's null) does not produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[1];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	
+	  inlinedSchemas[0].setNamespace(new URI("http://www.sample.org"));
+
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema list that contains a schema that couldn't be read (is null).");
+	  }
+	}
+	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 inline schema with no defined target namespace doesn't produce an error.
+	handler.reset();
+	try
+	{
+	  InlinedSchema[] inlinedSchemas = new InlinedSchema[1];
+	  inlinedSchemas[0]= new InlinedSchemaImpl();
+	
+	  if(!val.testAssertionSchema1073(inlinedSchemas, reporter))
+	  {
+		fail("There was an error reported for an inline schema that contains a null namespace.");
+	  }
+	}
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+  }
+  
+  /**
+   * Test assertion Interface-1012. Style defaults specified on interface elements
+   * must all be absolute.
+   */
+  public void testTestAssertionInterface1012()
+  {
+	URI relativeURI = null;
+	URI relativeURI2 = null;
+	URI absoluteURI = null;
+	try
+	{
+	  relativeURI = new URI("relativeuri");
+	  relativeURI2 = new URI("relativeuri2");
+	  absoluteURI = new URI("http://absoluteuri");
+	}
+	catch(URISyntaxException e)
+	{
+	  fail("There was a problem creating the test URIs: " + e);
+	}
+
+    WSDLFactory factory = null;
+    try {
+        factory = WSDLFactory.newInstance();
+    } catch (WSDLException e) {
+        fail("Can't instantiate the WSDLFactory object.");
+    }
+    
+	// Test that a schema without any style defaults is valid.
+	handler.reset();
+    try
+	{
+      DescriptionElement desc = factory.newDescription();
+      InterfaceElement interfaceElem = desc.addInterfaceElement();
+	  if(!val.testAssertionInterface1012(interfaceElem, reporter))
+	  {
+	    fail("The testAssertionInterface1012 method returned false for an interface that specifies no style defaults.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+    // Test that a schema with an absolute style default is valid.
+	handler.reset();
+	try
+	{
+          DescriptionElement desc = factory.newDescription();
+      InterfaceElement interfaceElem = desc.addInterfaceElement();
+	  interfaceElem.addStyleDefaultURI(absoluteURI);
+	  if(!val.testAssertionInterface1012(interfaceElem, reporter))
+	  {
+	    fail("The testAssertionInterface1012 method returned false for an interface that specifies one absolute style default.");
+	  }
+    }
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+    // Test that a schema with a relative style default is not valid.
+	handler.reset();
+	try
+	{
+      DescriptionElement desc = factory.newDescription();
+	  InterfaceElement interfaceElem = desc.addInterfaceElement();
+	  interfaceElem.addStyleDefaultURI(relativeURI);
+	  if(val.testAssertionInterface1012(interfaceElem, reporter))
+	  {
+	    fail("The testAssertionInterface1012 method returned true for an interface that specifies one relative style default.");
+	  }
+    }
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+    // Test that a schema with an absolute style default and a relative sytle default is not valid.
+	handler.reset();
+	try
+	{
+      DescriptionElement desc = factory.newDescription();
+      InterfaceElement interfaceElem = desc.addInterfaceElement();
+	  interfaceElem.addStyleDefaultURI(absoluteURI);
+	  interfaceElem.addStyleDefaultURI(relativeURI);
+	  if(val.testAssertionInterface1012(interfaceElem, reporter))
+	  {
+	    fail("The testAssertionInterface1012 method returned true for an interface that specifies an absolute style default and a relative style default.");
+	  }
+    }
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+	
+    // Test that a schema with two relative style defaults returns two error messages
+	handler.reset();
+	try
+	{
+      DescriptionElement desc = factory.newDescription();
+      InterfaceElement interfaceElem = desc.addInterfaceElement();
+	  interfaceElem.addStyleDefaultURI(relativeURI);
+	  interfaceElem.addStyleDefaultURI(relativeURI2);
+	  val.testAssertionInterface1012(interfaceElem, reporter);
+	  if(handler.numErrors != 2)
+	  {
+	    fail("The testAssertionInterface1012 method only reported one error for an interface that specifies two relative style defaults.");
+	  }
+    }
+	catch(WSDLException e)
+	{
+	  fail("There was a problem running the test assertion method " + e);
+    }
+  }
+  
+  /**
+   * Test assertion Schema-1066. 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 testTestAssertionSchema1066()
+  {
+    WSDLFactory factory = null;
+    try {
+        factory = WSDLFactory.newInstance();
+    } catch (WSDLException e) {
+        fail("Can't instantiate the WSDLFactory object.");
+    }
+
+	// Create a schema for use in the tests and add it to a types section.
+    InlinedSchema schema = new InlinedSchemaImpl();
+    XmlSchema xs1 = null;
+    URI schemaNS = null;
+	try
+	{
+      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>";
+      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");
+      schema.setSchemaDefinition(xs1);
+      schema.setNamespace(schemaNS);
+      TypesElement types = factory.newDescription().addTypesElement();
+      types.addSchema(schema);
+	}
+	catch(Exception e)
+	{
+	  fail("An error occurred while creating the sample types section.");
+	}
+    
+    // Test that a null namespace returns true.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = factory.newDescription();
+      TypesElement types = descElem.addTypesElement();
+      types.addSchema(schema);
+      
+	  if(!val.testAssertionSchema1066(descElem, null, reporter))
+	  {
+	    fail("The testAssertionSchema1066 method returned false for a null namespace.");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+	// Test that a reference to a namespace that is defined inline
+	// does not return an error.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = factory.newDescription();
+      TypesElement types = descElem.addTypesElement();
+      types.addSchema(schema);
+      
+	  if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
+	  {
+	    fail("The testAssertionSchema1066 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 = factory.newDescription();
+      TypesElement typesImported = descElem.addTypesElement();
+      ImportedSchema importedSchema = new ImportedSchemaImpl();
+      importedSchema.setSchemaDefinition(xs1);
+      importedSchema.setNamespace(schemaNS);
+      typesImported.addSchema(importedSchema);
+      
+	  if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
+	  {
+	    fail("The testAssertionSchema1066 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 = factory.newDescription();
+      //descElem.setTypesElement(types);
+      
+	  if(!val.testAssertionSchema1066(descElem, new QName(Constants.TYPE_XSD_2001, "myElement"), reporter))
+	  {
+	    fail("The testAssertionSchema1066 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 = factory.newDescription();
+      //descElem.setTypesElement(types);
+      
+	  if(val.testAssertionSchema1066(descElem, new QName("http://www.sample2.org", "myElement"), reporter))
+	  {
+	    fail("The testAssertionSchema1066 method returned true for a namespace that is not available..");
+	  }
+	}
+	catch(WSDLException e)
+    {
+	  fail("There was a problem running the test assertion method " + e);
+	}
+	
+	// Test that a reference to an inline schema that does not define a 
+	// target namespace (the targetNamespace is null) does not return an
+	// error.
+	handler.reset();
+    try
+	{
+      DescriptionElement descElem = factory.newDescription();
+      TypesElement typesImported = descElem.addTypesElement();
+      InlinedSchema inlinedSchema = new InlinedSchemaImpl();
+      typesImported.addSchema(inlinedSchema);
+      InlinedSchema inlinedSchema2 = new InlinedSchemaImpl();
+      inlinedSchema2.setNamespace(schemaNS);
+      typesImported.addSchema(inlinedSchema2);
+      
+	  if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
+	  {
+	    fail("The testAssertionSchema1066 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 the validateTypes method.
+   */
+  public void testValidateTypes()
+  {
+	// Test that the method returns true when the type is null.
+	try
+	{
+	  if(!val.validateTypes(null, reporter))
+	  {
+		fail("The validateTypes method returned false for a null types element.");
+	  }
+	}
+	catch(WSDLException e)
+	{
+		fail("There was a problem running the test assertion method " + e);
+	}
+  }
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/resolver/SimpleURIResolverTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/resolver/SimpleURIResolverTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/resolver/SimpleURIResolverTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/resolver/SimpleURIResolverTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,236 @@
+/**
+ * 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.
+ */
+package org.apache.woden.resolver;
+
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Iterator;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.internal.resolver.SimpleURIResolver;
+import org.apache.woden.schema.ImportedSchema;
+import org.apache.woden.schema.InlinedSchema;
+import org.apache.woden.schema.Schema;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaExternal;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+
+/**
+ * Functional verification test of SimpleURIResolver.
+ * 
+ * @author Graham Turrell
+ */
+public class SimpleURIResolverTest extends TestCase 
+{
+    private Binding[] fBindings = null;
+    private Interface[] fInterfaces = null;
+    private Schema[] fSchemas = null;
+	private ImportedSchema[] fImportedSchemas = null;
+	private InlinedSchema[] fInlinedSchemas = null;
+    private String fCatalogPropValue = null;
+    private String fHttpProxyHostValue = null;
+    private String fHttpProxyHostProperty = "http.proxyHost";
+    private String fCatalogProperty = "org.apache.woden.resolver.simpleresolver.catalog";
+    private String fWsdlPath = "org/apache/woden/resolver/resources/woden14.wsdl";
+    private String fCatalogPath = "org/apache/woden/resolver/resources/simpleresolver.catalog";
+    
+    public static Test suite()
+    {
+        return new TestSuite(SimpleURIResolverTest.class);
+    }
+    
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+        
+        // disable external http connections to ensure that test resolves only to local files
+        // specify a fantasy proxy host server fo use by HttpURLConnection ...
+        fHttpProxyHostValue = System.setProperty(fHttpProxyHostProperty, "proxy.thedomainforthisproxydoesnotexist.com");
+        
+        // ensure any external (http) connection now fails
+    	URLConnection testConnection = null;
+    	try
+        {
+        	testConnection = new URL("www.apache.org").openConnection();
+        } 
+    	catch (IOException e){
+        	
+        }
+        assertNull("Expected no connection IOException due to non-existent HTTP Proxy.", testConnection);
+        
+        // locate catalog file and set org.apache.woden.resolver.simpleresolver.catalog
+        // property to be that file.
+        
+        URL catalogURL = getClass().getClassLoader().getResource(fCatalogPath);
+        assertNotNull("Failed to find the Resolver Catalog document on the classpath using the path: " + fCatalogPath + ".", 
+        		catalogURL);
+        // simulate the standard compiler "-D" option ...
+        fCatalogPropValue = System.setProperty(fCatalogProperty, catalogURL.toString()); 
+        
+        WSDLFactory factory = WSDLFactory.newInstance();
+        WSDLReader reader = factory.newWSDLReader();
+        ErrorHandler handler = new TestErrorHandler();
+        reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
+        reader.getErrorReporter().setErrorHandler(handler);
+        
+        URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath);
+        assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".", 
+                wsdlURL);
+        
+
+		// set the resolver explicitly, using the root as a base URL 
+		// (SimpleURIResolver() default constructor is the default behaviour)
+        
+        // Base/root URL property no longer required in this test - now uses classpath
+        //URL rootURL = getClass().getClassLoader().getResource(fResources);
+        //assertNotNull("Failed to find the Base URL document on the classpath using the path: " + fResources + ".", 
+        //        wsdlURL);
+        //System.setProperty(fCatalogBaseProperty, rootURL.toString());
+		reader.setURIResolver(new SimpleURIResolver());
+		
+		Description descComp = reader.readWSDL(wsdlURL.toString());
+        assertNotNull("The reader did not return a WSDL description.", descComp);
+        
+        fBindings = descComp.getBindings();
+        fInterfaces = descComp.getInterfaces();
+        
+        DescriptionElement descElem = descComp.toElement();
+        TypesElement types = descElem.getTypesElement();	
+		fSchemas = types.getSchemas();
+		fImportedSchemas = types.getImportedSchemas();
+		fInlinedSchemas = types.getInlinedSchemas();
+        
+        assertEquals("The Description should contain 1 Binding component.", 1, fBindings.length);
+        assertEquals("The Description should contain 1 Interface component.", 1, fInterfaces.length);
+        assertEquals("The Description should contain 1 imported schema.", 1, fImportedSchemas.length); //the schema for W3C XML Schema imported by the DOM impl
+        assertEquals("The Description should contain 1 included (inlined) schema.", 1, fInlinedSchemas.length);
+        assertEquals("The Description should contain total of 2 imported & inlined schema.", 2, fSchemas.length);
+    }
+    
+  /**
+  * Test that the included binding matches the expected value parsed from the WSDL.
+  */
+ public void testCheckWSDLInclude()
+ {
+     Binding binding1 = fBindings[0];
+    
+     assertEquals("Unexpected binding name.", "{http://example.com/bank}BankSOAPBinding", binding1.getName().toString());
+ }
+ 
+ /**
+  * Test that the imported interface matches the expected value parsed from the WSDL.
+  */
+ public void testCheckWSDLImport()
+ {
+     Interface interface1 = fInterfaces[0];
+    
+     assertEquals("Unexpected interface name.", "{http://example.com/bank}Bank", interface1.getName().toString());
+ }
+ 
+ /**
+  * Test that the imported schema document matches the expected value parsed from the WSDL.
+  */
+ public void testCheckSchemaImport()
+ {
+	 Schema schema1 = fSchemas[0];
+     XmlSchema xmlSchema = schema1.getSchemaDefinition();
+     assertEquals("Unexpected targetNamespace.", "http://example.org/getAccountDetails/", schema1.getNamespace().toString());
+     
+     XmlSchemaObjectCollection schemaIncludes = xmlSchema.getIncludes(); // returns both includes and imports
+	 Iterator schemaIterator = schemaIncludes.getIterator();
+	 while (schemaIterator.hasNext()) 
+	 {
+		XmlSchemaExternal xso = (XmlSchemaExternal) schemaIterator.next();
+		if (xso instanceof XmlSchemaImport) 
+		{
+			assertEquals("Unexpected namespace.", "http://example.org/getOverdraft", ((XmlSchemaImport)xso).getNamespace());
+			assertEquals("Unexpected schemaLocation.", "http://test.com/getOverdraft.xsd", xso.getSchemaLocation());
+		}
+	 }
+ }
+ 
+ /**
+  * Test that the included schema document matches the expected value parsed from the WSDL.
+  */
+ public void testCheckSchemaInclude()
+ {
+	 InlinedSchema schema1 = fInlinedSchemas[0];
+	 XmlSchema xmlSchema = schema1.getSchemaDefinition();
+	 assertEquals("Unexpected targetNamespace.", "http://example.org/getAccountDetails/", schema1.getNamespace().toString());
+	     
+	 XmlSchemaObjectCollection schemaIncludes = xmlSchema.getIncludes(); // returns both includes and imports
+     Iterator schemaIterator = schemaIncludes.getIterator();
+	 while (schemaIterator.hasNext()) 
+	 {
+		XmlSchemaExternal xso = (XmlSchemaExternal) schemaIterator.next();
+		if (xso instanceof XmlSchemaInclude) 
+		{
+			assertEquals("Unexpected schemaLocation.", "http://test.com/getBalance.xsd", xso.getSchemaLocation());
+		}
+	 }
+ }
+ 
+ 
+ protected void tearDown() throws Exception 
+ {
+	 Properties p = System.getProperties();
+	 if (fCatalogPropValue == null)
+	 {
+		 p.remove(fCatalogProperty);
+	 }
+	 else 
+	 {
+		 p.setProperty(fCatalogProperty, fCatalogPropValue);
+	 }
+	 
+	 if (fHttpProxyHostValue == null)
+	 {
+		 p.remove(fHttpProxyHostProperty);
+	 }
+	 else 
+	 {
+		 p.setProperty(fHttpProxyHostProperty, fHttpProxyHostValue);
+	 }
+
+	 // above required as following throws NPE when arg1 == null (contrary to spec)
+	 //System.setProperty(fCatalogProperty, fCatalogPropValue);
+	 //System.setProperty("http.proxyHost", fHttpProxyHostValue);
+	 
+	 System.setProperties(p);
+ }
+   
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/tests/W3CTestSuiteTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/tests/W3CTestSuiteTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/tests/W3CTestSuiteTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/tests/W3CTestSuiteTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,822 @@
+/**
+ * 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.
+ */
+package org.apache.woden.tests;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.wsdl20.Description;
+
+public class W3CTestSuiteTest extends TestCase 
+{
+  private WSDLFactory factory = null;
+  private WSDLReader reader = null;
+  private TestErrorHandler handler;
+	  
+  public static Test suite()
+  {
+	return new TestSuite(W3CTestSuiteTest.class);
+  }
+
+  protected void setUp() throws Exception 
+  {
+    try
+	{
+	  factory = WSDLFactory.newInstance();
+	  reader = factory.newWSDLReader();  
+	  reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
+	} 
+	catch (Exception e) 
+    {
+	}
+	handler = new TestErrorHandler();
+	reader.getErrorReporter().setErrorHandler(handler);
+  }
+ 
+  protected void tearDown() throws Exception 
+  {
+    factory = null;
+	reader = null;
+	handler = null;
+  }
+  
+  /**
+   * BAD TEST CASES
+   * All of the following test cases should report errors. 
+   * TODO: Add in error checks as the WSDL 2.0 validator is developed.
+   */
+  
+  /**
+   * Test for the test-suite/documents/bad/Chameleon-1B W3C test.
+   */
+  public void testChameleon1B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Chameleon-1B/getBalance.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Chameleon-2B W3C test.
+   */
+  public void testChameleon2B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Chameleon-2B/getBalance.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Import-1B W3C test.
+   */
+  public void testImport1B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Import-1B/XSDImport.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+	  
+  /**
+   * Test for the test-suite/documents/bad/Import-2B W3C test.
+   */
+  public void testImport2B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Import-2B/XSDImportInWSDL.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+	  
+  /**
+   * Test for the test-suite/documents/bad/Import-3B W3C test.
+   */
+  public void testImport3B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Import-3B/XSDImport2.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Interface-1B W3C test.
+   */
+  public void testInterface1B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Interface-1B/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Interface-2B W3C test.
+   */
+  public void testInterface2B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Interface-2B/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Interface-3B W3C test.
+   */
+  public void testInterface3B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Interface-3B/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Service-1B W3C test.
+   */
+  public void testService1B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-1B/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Service-2B W3C test.
+   */
+  public void testService2B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-2B/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+
+  /**
+   * Test for the test-suite/documents/bad/Service-12B W3C test.
+   */
+  public void testService12B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-12B/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Service-13B W3C test.
+   */
+  public void testService13B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-13B/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Service-14B W3C test.
+   */
+  public void testService14B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-14B/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/Service-15B W3C test.
+   */
+  public void testService15B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-15B/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/bad/TicketAgent-1B W3C test.
+   */
+  public void testTicketAgent1B()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/TicketAgent-1B/TicketAgent-bad.wsdl");
+	  assertNotNull("Description is null.", desc);
+      // TODO: determine the assertions that should fail for this test.
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * GOOD TEST CASES
+   * All of the following test cases shouldn't report errors. 
+   * TODO: Add in error checks as the WSDL 2.0 validator is developed.
+   */
+  
+  /**
+   * Test for the test-suite/documents/good/Chameleon-1G W3C test.
+   */
+  public void testChameleon1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-1G/getBalance.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Chameleon-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Chameleon-2G W3C test.
+   */
+  public void testChameleon2G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-2G/getBalance.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Chameleon-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Chameleon-3G W3C test.
+   */
+  public void testChameleon3G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-3G/getBalance.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Chameleon-3G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Chameleon-4G W3C test.
+   */
+  public void testChameleon4G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-4G/getBalance.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Chameleon-4G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/CreditCardFaults-1G W3C test.
+   */
+  public void testCreditCardFaults1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/CreditCardFaults-1G/use-credit-card-faults.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good CreditCardFaults-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/GreatH-1G W3C test.
+   */
+  public void testGreatH1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/GreatH-1G/primer-hotelReservationService.wsdl");
+      assertTrue("number of bindings isn't 1", desc.getBindings().length == 1);
+      assertTrue("interfacename is null", desc.getBindings()[0].getInterface()!=null);
+
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good GreatH-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Import-1G W3C test.
+   */
+  public void testImport1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Import-1G/XSDImport.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Import-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Import-2G W3C test.
+   */
+  public void testImport2G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Import-2G/XSDImport2.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Import-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/ImportedWSDL-1G W3C test.
+   */
+  public void testImportedWSDL1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/ImportedWSDL-1G/updateDetails.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good ImportedWSDL-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.errorMessageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Interface-1G W3C test.
+   */
+  public void testInterface1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-1G/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Interface-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Interface-2G W3C test.
+   */
+  public void testInterface2G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-2G/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Interface-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Interface-3G W3C test.
+   */
+  public void testInterface3G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-3G/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Interface-3G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Interface-4G W3C test.
+   */
+  public void testInterface4G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-4G/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Interface-4G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Interface-5G W3C test.
+   */
+  public void testInterface5G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-5G/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Interface-5G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Interface-6G W3C test.
+   */
+  public void testInterface6G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-6G/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Interface-6G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Interface-7G W3C test.
+   */
+  public void testInterface7G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-7G/Interface.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Interface-7G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/MultipleInlineSchemas-1G W3C test.
+   */
+  public void testMultipleInlineSchemas1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/MultipleInlineSchemas-1G/retrieveItems.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good MultipleInlineSchemas-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/SchemaId-1G W3C test.
+   */
+  public void testSchemaId1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/SchemaId-1G/schemaIds.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good SchemaId-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/SchemaLocationFragment-1G W3C test.
+   */
+  public void testSchemaLocationFragment1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/SchemaLocationFragment-1G/Items.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good SchemaLocationFragment-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Service-1G W3C test.
+   */
+  public void testService1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Service-1G/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Service-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Service-2G W3C test.
+   */
+  public void testService2G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Service-2G/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Service-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/Service-3G W3C test.
+   */
+  public void testService3G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Service-3G/Service.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good Service-3G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/ServiceReference-1G W3C test.
+   */
+  public void testServiceReference1G1()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/ServiceReference-1G/reservationList.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good ServiceReference-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/ServiceReference-1G W3C test.
+   */
+  public void testServiceReference1G2()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/ServiceReference-1G/reservationDetails.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good ServiceReference-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/TicketAgent-1G W3C test.
+   */
+  public void testTicketAgent1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/TicketAgent-1G/TicketAgent.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good TicketAgent-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/WeathSvc-1G W3C test.
+   */
+  public void testWeathSvc1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/WeathSvc-1G/WeathSvc.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good WeathSvc-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/XsImport-1G W3C test.
+   */
+  public void testXsImport1G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/XsImport-1G/reservation.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good XsImport-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/XsImport-2G W3C test.
+   */
+  public void testXsImport2G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/XsImport-2G/reservationDetails.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good XsImport-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+  
+  /**
+   * Test for the test-suite/documents/good/XsImport-3G W3C test.
+   */
+  public void testXsImport3G()
+  {
+	try
+	{
+	  Description desc = reader.readWSDL("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/XsImport-3G/reservationDetails.wsdl");
+	  assertNotNull("Description is null.", desc);
+	  assertFalse("The good XsImport-3G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported());
+	}
+	catch(Exception e)
+	{
+	  fail("Unable to read WSDL document because of " + e);
+	}
+  }
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/BindingFaultReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/BindingFaultReferenceTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/BindingFaultReferenceTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/BindingFaultReferenceTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,125 @@
+/**
+ * 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.
+ */
+package org.apache.woden.wsdl20;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.BindingFaultReferenceImpl;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+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.InterfaceFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+
+/**
+ * Unit tests for the BindingFaultReference class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingFaultReferenceTest extends TestCase {
+
+	private BindingFaultReferenceElement fFaultRefElement = null;
+	private BindingFaultReference fFaultRef = null;	
+
+	public static Test suite()
+	{
+	   return new TestSuite(BindingFaultReferenceTest.class);
+	   
+	}
+	   /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+    	super.setUp();
+    	fFaultRefElement = new BindingFaultReferenceImpl();
+		fFaultRef = (BindingFaultReference) fFaultRefElement;
+    }
+    
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+
+	/* 
+	 * Test that the (Mandatory) InterfaceFaultReference can be successfully retrieved.
+	 * The fault reference is to an Interface Fault associated with the grandparent BindingElement.
+	 */
+	public void testGetInterfaceFaultReference()
+	{
+        WSDLFactory factory = null;
+        try {
+            factory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+		DescriptionElement descriptionElement = factory.newDescription();
+
+		// Create the BindingElement<->InterfaceElement->InterfaceOperationElement->InterfaceFaultReferenceElement hierarchy
+		BindingElement bindingElement = descriptionElement.addBindingElement();
+		bindingElement.setInterfaceName(new QName("interface1"));
+		
+		InterfaceElement interfaceElement = descriptionElement.addInterfaceElement();
+		interfaceElement.setName(new NCName("interface1"));
+		InterfaceFaultElement ife = interfaceElement.addInterfaceFaultElement();
+		ife.setName(new NCName("Fault1Ref"));
+		
+		InterfaceOperationElement ifopElement = interfaceElement.addInterfaceOperationElement();
+		ifopElement.setName(new NCName("operation1"));
+		InterfaceFaultReferenceElement iffrElement = ifopElement.addInterfaceFaultReferenceElement();
+		iffrElement.setMessageLabel(new NCName("Fault1MessageLabel"));
+		iffrElement.setRef(new QName("Fault1Ref"));
+				
+		// Create the BindingOperationElement->BindingFaultReferenceElement hierarchy
+		BindingOperationElement bopElement = bindingElement.addBindingOperationElement();
+		bopElement.setRef(new QName("operation1"));
+		fFaultRefElement = bopElement.addBindingFaultReferenceElement();
+		fFaultRefElement.setMessageLabel(new NCName("Fault1MessageLabel"));
+		fFaultRefElement.setRef(new QName("Fault1Ref"));
+
+		Description descComp = descriptionElement.toComponent();
+		descComp.getBindings(); // this triggers setting the link to description in the binding
+		
+		fFaultRef = (BindingFaultReference) fFaultRefElement;
+		InterfaceFaultReference retrievedFault = fFaultRef.getInterfaceFaultReference();
+		assertEquals("The retrieved InterfaceFaultReference is not that which was set", 
+				iffrElement, retrievedFault);
+	}
+	
+	/*
+     * toElement()
+     */
+	public void testToElement() 
+	{	
+		assertEquals(fFaultRefElement, fFaultRef.toElement());
+	}
+}



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


Mime
View raw message