// 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);