// 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.");
}