FileDocCategorySizeDatePackage
DOMImplementationCreateDocument.javaAPI DocAndroid 1.5 API6001Wed May 06 22:41:06 BST 2009tests.org.w3c.dom

DOMImplementationCreateDocument

public final class DOMImplementationCreateDocument extends DOMTestCase
The createDocument method with valid arguments, should create a DOM Document of the specified type. Call the createDocument on this DOMImplementation with createDocument ("http://www.w3.org/DOMTest/L2",see the array below for valid QNames,null). Check if the returned Document object is is empty with no Document Element.
author
IBM
author
Neil Delima
see
http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument

Fields Summary
DOMDocumentBuilderFactory
factory
DocumentBuilder
builder
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
        try {
            factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
                    .getConfiguration1());
            builder = factory.getBuilder();
        } catch (Exception e) {
            fail("Unexpected exception" + e.getMessage());
        }
    
protected voidtearDown()

        factory = null;
        builder = null;
        super.tearDown();
    
public voidtestCreateDocument3()
Runs the test case.

throws
Throwable Any uncaught exception causes test to fail

        Document doc;
        DOMImplementation domImpl;
        Document newDoc;
        DocumentType docType = null;

        String namespaceURI = "http://www.w3.org/DOMTest/L2";
        String qualifiedName;
        List<String> qualifiedNames = new ArrayList<String>();
        qualifiedNames.add("_:_");
        qualifiedNames.add("_:h0");
        qualifiedNames.add("_:test");
        qualifiedNames.add("l_:_");
        qualifiedNames.add("ns:_0");
        qualifiedNames.add("ns:a0");
        qualifiedNames.add("ns0:test");
        qualifiedNames.add("a.b:c");
        qualifiedNames.add("a-b:c");
        qualifiedNames.add("a-b:c");

        doc = (Document) load("staffNS", builder);
        domImpl = doc.getImplementation();
        for (int indexN1006B = 0; indexN1006B < qualifiedNames.size(); indexN1006B++) {
            qualifiedName = (String) qualifiedNames.get(indexN1006B);
            newDoc = domImpl.createDocument(namespaceURI, qualifiedName,
                    docType);
            assertNotNull("domimplementationcreatedocument03", newDoc);
        }
    
public voidtestCreateDocument4()

        Document doc;
        DOMImplementation domImpl;

        String namespaceURI = null;

        String qualifiedName = "dom:root";
        DocumentType docType = null;

        doc = (Document) load("staffNS", builder);
        domImpl = doc.getImplementation();

        {
            boolean success = false;
            try {
                domImpl.createDocument(namespaceURI, qualifiedName, docType);
            } catch (DOMException ex) {
                success = (ex.code == DOMException.NAMESPACE_ERR);
            }
            assertTrue("domimplementationcreatedocument04", success);
        }
    
public voidtestCreateDocument5()

        Document doc;
        DOMImplementation domImpl;

        String namespaceURI = "http://www.w3.org/xml/1998/namespace";
        String qualifiedName = "xml:root";
        DocumentType docType = null;

        doc = (Document) load("staffNS", builder);
        domImpl = doc.getImplementation();

        {
            boolean success = false;
            try {
                domImpl.createDocument(namespaceURI, qualifiedName, docType);
            } catch (DOMException ex) {
                success = (ex.code == DOMException.NAMESPACE_ERR);
            }
            assertTrue("domimplementationcreatedocument05", success);
        }
    
public voidtestCreateDocument7()

        Document doc;
        DOMImplementation domImpl;

        String namespaceURI = "http://www.w3.org/DOMTest/level2";
        DocumentType docType = null;

        doc = (Document) load("staffNS", builder);
        domImpl = doc.getImplementation();

        {
            boolean success = false;
            try {
                domImpl.createDocument(namespaceURI, ":", docType);
            } catch (DOMException ex) {
                success = (ex.code == DOMException.NAMESPACE_ERR);
            }
            assertTrue("domimplementationcreatedocument07", success);
        }