GetElementsByTagNameNSpublic final class GetElementsByTagNameNS extends DOMTestCase The "getElementsByTagNameNS(namespaceURI,localName)" method for a Document
should return a new NodeList of all Elements that have a namespace when local
name is specified as ' '.
Invoke method getElementsByTagNameNS(namespaceURI,localName) on this document
with namespaceURI and localName as " ". Method should return a new NodeList
of 37 elements. |
Fields Summary |
---|
DOMDocumentBuilderFactory | factory | DocumentBuilder | builder |
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 | testGetElementsByTagNameNS1()
String namespaceURI = "*";
String localName = "*";
Document doc;
NodeList newList;
doc = (Document) load("staffNS", builder);
newList = doc.getElementsByTagNameNS(namespaceURI, localName);
// BEGIN android-changed: Was 37, but that assumed validation.
assertEquals("throw_Size", 36, newList.getLength());
// END android-changed
| public void | testGetElementsByTagNameNS10()
Document doc;
Element docElem;
NodeList elementList;
Node child;
String childName;
List<String> result = new ArrayList<String>();
List<String> expectedResult = new ArrayList<String>();
expectedResult.add("employee");
expectedResult.add("employeeId");
expectedResult.add("name");
expectedResult.add("position");
expectedResult.add("salary");
expectedResult.add("gender");
expectedResult.add("address");
expectedResult.add("emp:employee");
expectedResult.add("emp:employeeId");
expectedResult.add("emp:position");
expectedResult.add("emp:salary");
expectedResult.add("emp:gender");
expectedResult.add("emp:address");
expectedResult.add("address");
doc = (Document) load("staffNS", builder);
docElem = doc.getDocumentElement();
elementList = docElem
.getElementsByTagNameNS("http://www.nist.gov", "*");
for (int indexN1007E = 0; indexN1007E < elementList.getLength(); indexN1007E++) {
child = (Node) elementList.item(indexN1007E);
childName = child.getNodeName();
result.add(childName);
}
assertEquals("nodeNames", expectedResult, result);
| public void | testGetElementsByTagNameNS11()
Document doc;
Element docElem;
NodeList elementList;
Node child;
String childName;
List<String> result = new ArrayList<String>();
List<String> expectedResult = new ArrayList<String>();
expectedResult.add("address");
expectedResult.add("address");
expectedResult.add("address");
expectedResult.add("emp:address");
expectedResult.add("address");
doc = (Document) load("staffNS", builder);
docElem = doc.getDocumentElement();
elementList = docElem.getElementsByTagNameNS("*", "address");
for (int indexN1005E = 0; indexN1005E < elementList.getLength(); indexN1005E++) {
child = (Node) elementList.item(indexN1005E);
childName = child.getNodeName();
result.add(childName);
}
assertEquals("nodeNames", expectedResult, result);
| public void | testGetElementsByTagNameNS12()
Document doc;
Element docElem;
NodeList elementList;
doc = (Document) load("staffNS", builder);
docElem = doc.getDocumentElement();
elementList = docElem.getElementsByTagNameNS("http://www.nist.gov",
"nomatch");
assertEquals("size", 0, elementList.getLength());
| public void | testGetElementsByTagNameNS13()
Document doc;
Element docElem;
NodeList elementList;
doc = (Document) load("staffNS", builder);
docElem = doc.getDocumentElement();
elementList = docElem.getElementsByTagNameNS("http://www.nomatch.com",
"address");
assertEquals("matchSize", 0, elementList.getLength());
| public void | testGetElementsByTagNameNS14()
Document doc;
Element docElem;
NodeList elementList;
doc = (Document) load("staffNS", builder);
docElem = doc.getDocumentElement();
elementList = docElem.getElementsByTagNameNS("http://www.nist.gov",
"address");
assertEquals("addresses", 3, elementList.getLength());
| public void | testGetElementsByTagNameNS2()
Document doc;
NodeList newList;
Element newElement;
String prefix;
String lname;
doc = (Document) load("staffNS", builder);
newList = doc.getElementsByTagNameNS("*", "employee");
assertEquals("employeeCount", 5, newList.getLength());
newElement = (Element) newList.item(3);
prefix = newElement.getPrefix();
assertEquals("prefix", "emp", prefix);
lname = newElement.getLocalName();
assertEquals("lname", "employee", lname);
| public void | testGetElementsByTagNameNS3()
Document doc;
NodeList elementList;
Node child;
String childName;
List<String> result = new ArrayList<String>();
List<String> expectedResult = new ArrayList<String>();
expectedResult.add("employee");
expectedResult.add("employeeId");
expectedResult.add("name");
expectedResult.add("position");
expectedResult.add("salary");
expectedResult.add("gender");
expectedResult.add("address");
expectedResult.add("emp:employee");
expectedResult.add("emp:employeeId");
expectedResult.add("emp:position");
expectedResult.add("emp:salary");
expectedResult.add("emp:gender");
expectedResult.add("emp:address");
expectedResult.add("address");
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "*");
for (int indexN10076 = 0; indexN10076 < elementList.getLength(); indexN10076++) {
child = (Node) elementList.item(indexN10076);
childName = child.getNodeName();
result.add(childName);
}
assertEquals("nodeNames", expectedResult, result);
| public void | testGetElementsByTagNameNS4()
Document doc;
NodeList elementList;
Node child;
String childName;
List<String> result = new ArrayList<String>();
List<String> expectedResult = new ArrayList<String>();
expectedResult.add("address");
expectedResult.add("address");
expectedResult.add("address");
expectedResult.add("emp:address");
expectedResult.add("address");
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("*", "address");
for (int indexN10059 = 0; indexN10059 < elementList.getLength(); indexN10059++) {
child = (Node) elementList.item(indexN10059);
childName = child.getNodeName();
result.add(childName);
}
assertEquals("nodeNames", expectedResult, result);
| public void | testGetElementsByTagNameNS5()
String namespaceURI = "http://www.nist.gov";
String localName = "nomatch";
Document doc;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS(namespaceURI, localName);
assertEquals("throw_Size", 0, elementList.getLength());
| public void | testGetElementsByTagNameNS6()
Document doc;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nomatch.com",
"address");
assertEquals("matchSize", 0, elementList.getLength());
| public void | testGetElementsByTagNameNS7()
Document doc;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov",
"address");
assertEquals("addresses", 3, elementList.getLength());
| public void | testGetElementsByTagNameNS8()
Document doc;
Element docElem;
NodeList newList;
doc = (Document) load("staffNS", builder);
docElem = doc.getDocumentElement();
newList = docElem.getElementsByTagNameNS("*", "*");
assertEquals("listSize", 36, newList.getLength());
| public void | testGetElementsByTagNameNS9()
Document doc;
NodeList newList;
Element newElement;
String prefix;
String lname;
Element docElem;
doc = (Document) load("staffNS", builder);
docElem = doc.getDocumentElement();
newList = docElem.getElementsByTagNameNS("*", "employee");
assertEquals("employeeCount", 5, newList.getLength());
newElement = (Element) newList.item(3);
prefix = newElement.getPrefix();
assertEquals("prefix", "emp", prefix);
lname = newElement.getLocalName();
assertEquals("lname", "employee", lname);
|
|