FileDocCategorySizeDatePackage
SchemaImportTestCase.javaAPI DocApache Axis 1.43474Sat Apr 22 18:57:28 BST 2006test.wsdl.schemaImport

SchemaImportTestCase

public class SchemaImportTestCase extends TestCase
This class contains the methods necessary for testing that the XML Schema import support is functional within WSDL2Java. This test will generate a WSDL file and then validate that the schema has been appropriate imported into said WSDL.
version
1.00 01 Nov 2002
author
Doug Bitting (douglas.bitting@agile.com)

Fields Summary
Constructors Summary
public SchemaImportTestCase(String name)

        super(name);
    
Methods Summary
public voidtestSchemaImport()

        String path = "build" + File.separator + "work" + File.separator +
                "test" + File.separator + "wsdl" + File.separator +
                "schemaImport" + File.separator + "foo.wsdl";
        Document doc = null;
        Definition def = null;

        // Make sure that the WSDL appears to be valid
        try {
            doc = XMLUtils.newDocument(path);
            assertNotNull("Unable to locate WSDL file: " + path, doc);
            WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
            def = reader.readWSDL(path, doc);
            assertNotNull("unable to generate WSDL definition from document: " 
                          + path, def);
            assertEquals("Expected xmlns:foo to be set to urn:ImportSchemaTest",
                         "urn:ImportSchemaTest", def.getNamespace("foo"));
        } catch (Exception e) {
            throw new junit.framework.AssertionFailedError("Exception caught: "
                                                           + e);
        }

        // Now check that the schema was properly imported.  It is assumed
        // that WSDL generation is validated in other unit tests.  Here, we
        // are only interested in the schema importing functionality.
        NodeList typeList = doc.getElementsByTagName("wsdl:types");
        Node typeNode = typeList.item(0);
        assertNotNull("types section of the WSDL document", typeNode);
        Element typeElem = (Element) typeNode;

        NodeList nodeList = typeElem.getElementsByTagName("xs:complexType");
        assertTrue("Could not located imported schema", 
                   nodeList.getLength() > 0);
        Element elt = (Element) nodeList.item(0);
        assertEquals("Unexpected complexType", "foo", elt.getAttribute("name"));
        nodeList = elt.getElementsByTagName("xs:documentation");
        assertTrue("Could not find schema documentation",
                   nodeList.getLength() > 0);