use of android.sax.RootElement in project android_frameworks_base by ParanoidAndroid.
the class SafeSaxTest method testListener.
@SmallTest
public void testListener() throws Exception {
String xml = "<feed xmlns='http://www.w3.org/2005/Atom'>\n" + "<entry>\n" + "<id>a</id>\n" + "</entry>\n" + "<entry>\n" + "<id>b</id>\n" + "</entry>\n" + "</feed>\n";
RootElement root = new RootElement(ATOM_NAMESPACE, "feed");
Element entry = root.requireChild(ATOM_NAMESPACE, "entry");
Element id = entry.requireChild(ATOM_NAMESPACE, "id");
ElementCounter rootCounter = new ElementCounter();
ElementCounter entryCounter = new ElementCounter();
TextElementCounter idCounter = new TextElementCounter();
root.setElementListener(rootCounter);
entry.setElementListener(entryCounter);
id.setTextElementListener(idCounter);
Xml.parse(xml, root.getContentHandler());
assertEquals(1, rootCounter.starts);
assertEquals(1, rootCounter.ends);
assertEquals(2, entryCounter.starts);
assertEquals(2, entryCounter.ends);
assertEquals(2, idCounter.starts);
assertEquals("ab", idCounter.bodies);
}
use of android.sax.RootElement in project android_frameworks_base by ParanoidAndroid.
the class SafeSaxTest method testMissingRequiredChild.
@SmallTest
public void testMissingRequiredChild() throws Exception {
String xml = "<feed></feed>";
RootElement root = new RootElement("feed");
root.requireChild("entry");
try {
Xml.parse(xml, root.getContentHandler());
fail("expected exception not thrown");
} catch (SAXException e) {
// Expected.
}
}
use of android.sax.RootElement in project android_frameworks_base by ResurrectionRemix.
the class SafeSaxTest method testMissingRequiredChild.
@SmallTest
public void testMissingRequiredChild() throws Exception {
String xml = "<feed></feed>";
RootElement root = new RootElement("feed");
root.requireChild("entry");
try {
Xml.parse(xml, root.getContentHandler());
fail("expected exception not thrown");
} catch (SAXException e) {
// Expected.
}
}
use of android.sax.RootElement in project android_frameworks_base by ResurrectionRemix.
the class SafeSaxTest method testListener.
@SmallTest
public void testListener() throws Exception {
String xml = "<feed xmlns='http://www.w3.org/2005/Atom'>\n" + "<entry>\n" + "<id>a</id>\n" + "</entry>\n" + "<entry>\n" + "<id>b</id>\n" + "</entry>\n" + "</feed>\n";
RootElement root = new RootElement(ATOM_NAMESPACE, "feed");
Element entry = root.requireChild(ATOM_NAMESPACE, "entry");
Element id = entry.requireChild(ATOM_NAMESPACE, "id");
ElementCounter rootCounter = new ElementCounter();
ElementCounter entryCounter = new ElementCounter();
TextElementCounter idCounter = new TextElementCounter();
root.setElementListener(rootCounter);
entry.setElementListener(entryCounter);
id.setTextElementListener(idCounter);
Xml.parse(xml, root.getContentHandler());
assertEquals(1, rootCounter.starts);
assertEquals(1, rootCounter.ends);
assertEquals(2, entryCounter.starts);
assertEquals(2, entryCounter.ends);
assertEquals(2, idCounter.starts);
assertEquals("ab", idCounter.bodies);
}
use of android.sax.RootElement in project android_frameworks_base by DirtyUnicorns.
the class SafeSaxTest method testMissingRequiredChild.
@SmallTest
public void testMissingRequiredChild() throws Exception {
String xml = "<feed></feed>";
RootElement root = new RootElement("feed");
root.requireChild("entry");
try {
Xml.parse(xml, root.getContentHandler());
fail("expected exception not thrown");
} catch (SAXException e) {
// Expected.
}
}
Aggregations