DocumentCreateElementNSpublic final class DocumentCreateElementNS extends DOMTestCase The method createElementNS creates an element of the given valid
qualifiedName and NamespaceURI.
Invoke the createElementNS method on this Document object with a valid
namespaceURI and qualifiedName. Check if a valid Element object is returned
with the same node attributes. |
Fields Summary |
---|
DOMDocumentBuilderFactory | factory | DocumentBuilder | builder |
Methods Summary |
---|
protected void | setUp()
super.setUp();
try {
factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
.getConfiguration1());
builder = factory.getBuilder();
} catch (Exception e) {
fail("Unexpected exception" + e.getMessage());
}
| protected void | tearDown()
factory = null;
builder = null;
super.tearDown();
| public void | testCreateElementNS1()Runs the test case.
Document doc;
Element element;
String namespaceURI = "http://www.w3.org/DOM/Test/level2";
String qualifiedName = "XML:XML";
String nodeName;
String nsURI;
String localName;
String prefix;
String tagName;
doc = (Document) load("staffNS", builder);
element = doc.createElementNS(namespaceURI, qualifiedName);
nodeName = element.getNodeName();
nsURI = element.getNamespaceURI();
localName = element.getLocalName();
prefix = element.getPrefix();
tagName = element.getTagName();
assertEquals("documentcreateelementNS01_nodeName", "XML:XML", nodeName);
assertEquals("documentcreateelementNS01_namespaceURI",
"http://www.w3.org/DOM/Test/level2", nsURI);
assertEquals("documentcreateelementNS01_localName", "XML", localName);
assertEquals("documentcreateelementNS01_prefix", "XML", prefix);
assertEquals("documentcreateelementNS01_tagName", "XML:XML", tagName);
| public void | testCreateElementNS2()
Document doc;
String namespaceURI = null;
String qualifiedName = "^^";
doc = (Document) load("staffNS", builder);
{
boolean success = false;
try {
doc.createElementNS(namespaceURI, qualifiedName);
} catch (DOMException ex) {
success = (ex.code == DOMException.INVALID_CHARACTER_ERR);
}
assertTrue("documentcreateelementNS02", success);
}
| public void | testCreateElementNS5()
Document doc;
String namespaceURI = null;
String qualifiedName = "null:xml";
doc = (Document) load("staffNS", builder);
{
boolean success = false;
try {
doc.createElementNS(namespaceURI, qualifiedName);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("documentcreateelementNS05", success);
}
| public void | testCreateElementNS6()
Document doc;
Document newDoc;
DocumentType docType = null;
DOMImplementation domImpl;
String namespaceURI = "http://www.w3.org/xml/1998/namespace ";
String qualifiedName = "xml:root";
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test",
"dom:doc", docType);
{
boolean success = false;
try {
newDoc.createElementNS(namespaceURI, qualifiedName);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("documentcreateelementNS06", success);
}
|
|