Search in sources :

Example 1 with XMLHandler

use of org.apache.jena.rdfxml.xmlinput.impl.XMLHandler in project jena by apache.

the class TestPropEltErrorMsg method runTest.

@Override
protected void runTest() {
    Attributes noAtts = new Atts();
    final StringBuffer buf = new StringBuffer();
    XMLHandler arp = new XMLHandler();
    arp.getHandlers().setErrorHandler(new ErrorHandler() {

        @Override
        public void warning(SAXParseException exception) {
            buf.append(exception.getMessage());
            buf.append("\n");
        }

        @Override
        public void error(SAXParseException e) {
            warning(e);
        }

        @Override
        public void fatalError(SAXParseException e) {
            warning(e);
        }
    });
    try {
        arp.initParse("http://example.org/", "");
        arp.startElement(RDF.getURI(), "RDF", "rdf:RDF", noAtts);
        arp.startElement(RDF.getURI(), "Description", "rdf:Description", noAtts);
        arp.startElement(RDF.getURI(), "value", "rdf:value", testAtts);
    } catch (SAXException e) {
    }
    //        System.err.println("===");
    //        System.err.println("\""+getName()+"\",");
    //        System.err.println("---");
    String contents = buf.toString();
    //        System.err.println("\""+(contents.length()>7?contents.substring(7).replace("\n","\\n"):"")+"\",");
    assertEquals("test data muddled", rslts[n * 2], getName());
    assertTrue("error message has changed.", contents.endsWith(rslts[n * 2 + 1]));
    contents = null;
}
Also used : ErrorHandler(org.xml.sax.ErrorHandler) XMLHandler(org.apache.jena.rdfxml.xmlinput.impl.XMLHandler) SAXParseException(org.xml.sax.SAXParseException) Attributes(org.xml.sax.Attributes) SAXException(org.xml.sax.SAXException)

Aggregations

XMLHandler (org.apache.jena.rdfxml.xmlinput.impl.XMLHandler)1 Attributes (org.xml.sax.Attributes)1 ErrorHandler (org.xml.sax.ErrorHandler)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1