NamedNodeMapRemoveNamedItemNSpublic final class NamedNodeMapRemoveNamedItemNS extends DOMTestCase The method removeNamedItemNS removes a node specified by local name and
namespace
Retreive an attribute node and then remove from the NamedNodeMap. Verify if
the attribute node was actually remove from the node map. |
Fields Summary |
---|
DOMDocumentBuilderFactory | factory | DocumentBuilder | builder |
Methods Summary |
---|
public void | _testRemoveNamedItemNS4()
Document doc;
NamedNodeMap attributes;
Node element;
Attr attribute;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("*", "employee");
element = elementList.item(0);
attributes = element.getAttributes();
attributes.removeNamedItemNS("http://www.w3.org/2000/xmlns/", "xmlns");
attribute = (Attr) attributes.getNamedItemNS(
"http://www.w3.org/2000/xmlns/", "xmlns");
assertNull("namednodemapremovenameditemns04_1", attribute);
attributes.removeNamedItemNS("http://www.w3.org/2000/xmlns/", "dmstc");
attribute = (Attr) attributes.getNamedItemNS(
"http://www.w3.org/2000/xmlns/", "dmstc");
assertNull("namednodemapremovenameditemns04_2", attribute);
| 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 | testRemoveNamedItemNS1()Runs the test case.
Document doc;
NamedNodeMap attributes;
Node element;
Attr attribute;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov",
"address");
element = elementList.item(1);
attributes = element.getAttributes();
attribute = (Attr) attributes.removeNamedItemNS("http://www.nist.gov",
"domestic");
attribute = (Attr) attributes.getNamedItemNS("http://www.nist.gov",
"domestic");
assertNull("namednodemapremovenameditemns01", attribute);
| public void | testRemoveNamedItemNS3()
Document doc;
NamedNodeMap attributes;
Node element;
Attr attribute;
Attr attribute1;
Attr attribute2;
String nodeName;
doc = (Document) load("staffNS", builder);
element = doc.createElementNS("http://www.w3.org/DOM/Test", "root");
attribute1 = doc
.createAttributeNS("http://www.w3.org/DOM/L1", "L1:att");
((Element) /* Node */element).setAttributeNodeNS(attribute1);
attribute2 = doc
.createAttributeNS("http://www.w3.org/DOM/L2", "L2:att");
((Element) /* Node */element).setAttributeNodeNS(attribute2);
attributes = element.getAttributes();
attribute = (Attr) attributes.removeNamedItemNS(
"http://www.w3.org/DOM/L1", "att");
attribute = (Attr) attributes.getNamedItemNS(
"http://www.w3.org/DOM/L2", "att");
nodeName = attribute.getNodeName();
assertEquals("namednodemapremovenameditemns02", "L2:att", nodeName);
| public void | testRemoveNamedItemNS6()
Document doc;
NamedNodeMap attributes;
Node element;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov",
"employee");
element = elementList.item(1);
attributes = element.getAttributes();
{
boolean success = false;
try {
attributes.removeNamedItemNS("http://www.Nist.gov", "domestic");
} catch (DOMException ex) {
success = (ex.code == DOMException.NOT_FOUND_ERR);
}
assertTrue("throw_NOT_FOUND_ERR", success);
}
| public void | testRemoveNamedItemNS7()
Document doc;
NamedNodeMap attributes;
Node element;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov",
"employee");
element = elementList.item(1);
attributes = element.getAttributes();
{
boolean success = false;
try {
attributes.removeNamedItemNS("http://www.nist.gov", "domestic");
} catch (DOMException ex) {
success = (ex.code == DOMException.NOT_FOUND_ERR);
}
assertTrue("throw_NOT_FOUND_ERR", success);
}
| public void | testRemoveNamedItemNS8()
Document doc;
NamedNodeMap attributes;
Element element;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov",
"address");
element = (Element) elementList.item(1);
attributes = element.getAttributes();
element.removeAttributeNS("http://www.nist.gov", "domestic");
{
boolean success = false;
try {
attributes.removeNamedItemNS("http://www.nist.gov", "domestic");
} catch (DOMException ex) {
success = (ex.code == DOMException.NOT_FOUND_ERR);
}
assertTrue("throw_NOT_FOUND_ERR", success);
}
| public void | testRemoveNamedItemNS9()
Document doc;
NamedNodeMap attributes;
NamedNodeMap newAttributes;
Element element;
Attr attribute;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov",
"address");
element = (Element) elementList.item(1);
attributes = element.getAttributes();
attribute = (Attr) attributes.removeNamedItemNS("http://www.nist.gov",
"domestic");
newAttributes = element.getAttributes();
attribute = (Attr) newAttributes.getNamedItemNS("http://www.nist.gov",
"domestic");
assertNull("namednodemapremovenameditemns09", attribute);
|
|