Search in sources :

Example 16 with RootElement

use of android.sax.RootElement in project platform_frameworks_base by android.

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);
}
Also used : RootElement(android.sax.RootElement) Element(android.sax.Element) RootElement(android.sax.RootElement) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 17 with RootElement

use of android.sax.RootElement in project platform_frameworks_base by android.

the class SafeSaxTest method testMixedContent.

@SmallTest
public void testMixedContent() throws Exception {
    String xml = "<feed><entry></entry></feed>";
    RootElement root = new RootElement("feed");
    root.setEndTextElementListener(new EndTextElementListener() {

        public void end(String body) {
        }
    });
    try {
        Xml.parse(xml, root.getContentHandler());
        fail("expected exception not thrown");
    } catch (SAXException e) {
    // Expected.
    }
}
Also used : RootElement(android.sax.RootElement) EndTextElementListener(android.sax.EndTextElementListener) SAXException(org.xml.sax.SAXException) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 18 with RootElement

use of android.sax.RootElement in project android_frameworks_base by DirtyUnicorns.

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);
}
Also used : RootElement(android.sax.RootElement) Element(android.sax.Element) RootElement(android.sax.RootElement) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 19 with RootElement

use of android.sax.RootElement in project android_frameworks_base by DirtyUnicorns.

the class SafeSaxTest method testMixedContent.

@SmallTest
public void testMixedContent() throws Exception {
    String xml = "<feed><entry></entry></feed>";
    RootElement root = new RootElement("feed");
    root.setEndTextElementListener(new EndTextElementListener() {

        public void end(String body) {
        }
    });
    try {
        Xml.parse(xml, root.getContentHandler());
        fail("expected exception not thrown");
    } catch (SAXException e) {
    // Expected.
    }
}
Also used : RootElement(android.sax.RootElement) EndTextElementListener(android.sax.EndTextElementListener) SAXException(org.xml.sax.SAXException) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 20 with RootElement

use of android.sax.RootElement in project android_frameworks_base by AOSPA.

the class SafeSaxTest method testMixedContent.

@SmallTest
public void testMixedContent() throws Exception {
    String xml = "<feed><entry></entry></feed>";
    RootElement root = new RootElement("feed");
    root.setEndTextElementListener(new EndTextElementListener() {

        public void end(String body) {
        }
    });
    try {
        Xml.parse(xml, root.getContentHandler());
        fail("expected exception not thrown");
    } catch (SAXException e) {
    // Expected.
    }
}
Also used : RootElement(android.sax.RootElement) EndTextElementListener(android.sax.EndTextElementListener) SAXException(org.xml.sax.SAXException) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

RootElement (android.sax.RootElement)21 SmallTest (android.test.suitebuilder.annotation.SmallTest)18 SAXException (org.xml.sax.SAXException)12 Element (android.sax.Element)9 EndTextElementListener (android.sax.EndTextElementListener)9 EndElementListener (android.sax.EndElementListener)3 ArrayList (java.util.ArrayList)2 ContentValues (android.content.ContentValues)1 Message (android.os.Message)1 StartElementListener (android.sax.StartElementListener)1 SearchResult (com.battlelancer.seriesguide.items.SearchResult)1 FileInputStream (java.io.FileInputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Matcher (java.util.regex.Matcher)1 Nonnull (javax.annotation.Nonnull)1 DateTimeZone (org.joda.time.DateTimeZone)1 LocalTime (org.joda.time.LocalTime)1