Methods Summary |
---|
protected void | setUp()
super.setUp();
try {
factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
.getConfiguration2());
builder = factory.getBuilder();
} catch (Exception e) {
fail("Unexpected exception" + e.getMessage());
}
|
protected void | tearDown()
factory = null;
builder = null;
super.tearDown();
|
public void | testSetAttributeNode1()Runs the test case.
String namespaceURI = "http://www.newattr.com";
String qualifiedName = "emp:newAttr";
Document doc;
Element newElement;
Attr newAttr;
NodeList elementList;
Node testAddr;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull", testAddr);
newElement = doc.createElement("newElement");
testAddr.appendChild(newElement);
newAttr = doc.createAttributeNS(namespaceURI, qualifiedName);
newElement.setAttributeNodeNS(newAttr);
{
boolean success = false;
try {
((Element) /* Node */testAddr).setAttributeNodeNS(newAttr);
} catch (DOMException ex) {
success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR);
}
assertTrue("throw_INUSE_ATTRIBUTE_ERR", success);
}
|
public void | testSetAttributeNode3()
String namespaceURI = "http://www.newattr.com";
String qualifiedName = "emp:newAttr";
Document doc;
NodeList elementList;
Node testAddr;
Attr newAttr;
Attr newAddrAttr;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull", testAddr);
newAttr = doc.createAttributeNS(namespaceURI, qualifiedName);
newAddrAttr = ((Element) /* Node */testAddr)
.setAttributeNodeNS(newAttr);
assertNull("throw_Null", newAddrAttr);
|
public void | testSetAttributeNode4()
Document doc;
NodeList elementList;
Node testAddr;
Attr newAttr;
Attr newAddrAttr;
String newName;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull", testAddr);
newAttr = doc.createAttributeNS("http://www.nist.gov", "xxx:domestic");
newAddrAttr = ((Element) /* Node */testAddr)
.setAttributeNodeNS(newAttr);
newName = newAddrAttr.getNodeName();
assertEquals("nodeName", "emp:domestic", newName);
|
public void | testSetAttributeNode5()
String namespaceURI = "http://www.newattr.com";
String qualifiedName = "emp:newAttr";
Document doc1;
Document doc2;
Attr newAttr;
NodeList elementList;
Node testAddr;
doc1 = (Document) load("staffNS", builder);
doc2 = (Document) load("staffNS", builder);
newAttr = doc2.createAttributeNS(namespaceURI, qualifiedName);
elementList = doc1.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
{
boolean success = false;
try {
((Element) /* Node */testAddr).setAttributeNodeNS(newAttr);
} catch (DOMException ex) {
success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
}
assertTrue("throw_WRONG_DOCUMENT_ERR", success);
}
|