Search in sources :

Example 36 with SAXParseException

use of org.xml.sax.SAXParseException in project robovm by robovm.

the class XMLFilterImplTest method testFatalError.

public void testFatalError() {
    SAXParseException exception = new SAXParseException("Oops!", null);
    try {
        parent.fatalError(exception);
    } catch (SAXException e) {
        throw new RuntimeException("Unexpected exception", e);
    }
    assertEquals(logger.size(), 1);
    assertEquals("fatalError", logger.getMethod());
    assertEquals(new Object[] { exception }, logger.getArgs());
}
Also used : SAXParseException(org.xml.sax.SAXParseException) SAXException(org.xml.sax.SAXException)

Example 37 with SAXParseException

use of org.xml.sax.SAXParseException in project robovm by robovm.

the class DefaultHandlerTest method testFatalError.

public void testFatalError() {
    // Ordinary case
    try {
        h.fatalError(new SAXParseException("Foo", new LocatorImpl()));
        fail("SAXException expected");
    } catch (SAXException e) {
    // Expected
    }
    // No exception
    try {
        h.fatalError(null);
        fail("NullPointerException expected");
    } catch (SAXException e) {
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    // Expected
    }
}
Also used : SAXParseException(org.xml.sax.SAXParseException) LocatorImpl(org.xml.sax.helpers.LocatorImpl) SAXException(org.xml.sax.SAXException)

Example 38 with SAXParseException

use of org.xml.sax.SAXParseException in project robovm by robovm.

the class SAXExceptionTest method testSAXException_String_Exception.

public void testSAXException_String_Exception() {
    Exception c = new Exception();
    // Ordinary case
    SAXException e = new SAXException(ERR, c);
    assertEquals(ERR, e.getMessage());
    assertEquals(c, e.getException());
    // No message
    e = new SAXException(null, c);
    assertNull(e.getMessage());
    assertEquals(c, e.getException());
    // No cause
    e = new SAXParseException(ERR, null);
    assertEquals(ERR, e.getMessage());
    assertNull(e.getException());
}
Also used : SAXParseException(org.xml.sax.SAXParseException) SAXParseException(org.xml.sax.SAXParseException) SAXException(org.xml.sax.SAXException) SAXException(org.xml.sax.SAXException)

Example 39 with SAXParseException

use of org.xml.sax.SAXParseException in project robovm by robovm.

the class SAXParseExceptionTest method testSAXParseException_String_Locator_Exception.

public void testSAXParseException_String_Locator_Exception() {
    LocatorImpl l = new LocatorImpl();
    l.setPublicId(PUB);
    l.setSystemId(SYS);
    l.setLineNumber(ROW);
    l.setColumnNumber(COL);
    Exception c = new Exception();
    // Ordinary case
    SAXParseException e = new SAXParseException(ERR, l, c);
    assertEquals(ERR, e.getMessage());
    assertEquals(c, e.getException());
    assertEquals(PUB, e.getPublicId());
    assertEquals(SYS, e.getSystemId());
    assertEquals(ROW, e.getLineNumber());
    assertEquals(COL, e.getColumnNumber());
    // No message
    e = new SAXParseException(null, l, c);
    assertNull(e.getMessage());
    assertEquals(c, e.getException());
    assertEquals(PUB, e.getPublicId());
    assertEquals(SYS, e.getSystemId());
    assertEquals(ROW, e.getLineNumber());
    assertEquals(COL, e.getColumnNumber());
    // No locator
    e = new SAXParseException(ERR, null, c);
    assertEquals(ERR, e.getMessage());
    assertEquals(c, e.getException());
    assertNull(e.getPublicId());
    assertNull(e.getSystemId());
    assertEquals(-1, e.getLineNumber());
    assertEquals(-1, e.getColumnNumber());
    // No cause
    e = new SAXParseException(ERR, l, null);
    assertEquals(ERR, e.getMessage());
    assertNull(e.getException());
    assertEquals(PUB, e.getPublicId());
    assertEquals(SYS, e.getSystemId());
    assertEquals(ROW, e.getLineNumber());
    assertEquals(COL, e.getColumnNumber());
}
Also used : SAXParseException(org.xml.sax.SAXParseException) LocatorImpl(org.xml.sax.helpers.LocatorImpl) SAXParseException(org.xml.sax.SAXParseException)

Example 40 with SAXParseException

use of org.xml.sax.SAXParseException in project robovm by robovm.

the class SAXParseExceptionTest method testSAXParseException_String_String_String_int_int_Exception.

public void testSAXParseException_String_String_String_int_int_Exception() {
    Exception c = new Exception();
    // Ordinary case
    SAXParseException e = new SAXParseException(ERR, PUB, SYS, ROW, COL, c);
    assertEquals(ERR, e.getMessage());
    assertEquals(c, e.getException());
    assertEquals(PUB, e.getPublicId());
    assertEquals(SYS, e.getSystemId());
    assertEquals(ROW, e.getLineNumber());
    assertEquals(COL, e.getColumnNumber());
    // No message
    e = new SAXParseException(null, PUB, SYS, ROW, COL, c);
    assertNull(e.getMessage());
    assertEquals(c, e.getException());
    assertEquals(PUB, e.getPublicId());
    assertEquals(SYS, e.getSystemId());
    assertEquals(ROW, e.getLineNumber());
    assertEquals(COL, e.getColumnNumber());
    // No locator
    e = new SAXParseException(ERR, null, null, -1, -1, c);
    assertEquals(ERR, e.getMessage());
    assertEquals(c, e.getException());
    assertNull(e.getPublicId());
    assertNull(e.getSystemId());
    assertEquals(-1, e.getLineNumber());
    assertEquals(-1, e.getColumnNumber());
    // No cause
    e = new SAXParseException(ERR, PUB, SYS, ROW, COL, null);
    assertEquals(ERR, e.getMessage());
    assertNull(e.getException());
    assertEquals(PUB, e.getPublicId());
    assertEquals(SYS, e.getSystemId());
    assertEquals(ROW, e.getLineNumber());
    assertEquals(COL, e.getColumnNumber());
}
Also used : SAXParseException(org.xml.sax.SAXParseException) SAXParseException(org.xml.sax.SAXParseException)

Aggregations

SAXParseException (org.xml.sax.SAXParseException)365 SAXException (org.xml.sax.SAXException)170 IOException (java.io.IOException)131 DocumentBuilder (javax.xml.parsers.DocumentBuilder)73 InputSource (org.xml.sax.InputSource)69 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)68 Document (org.w3c.dom.Document)64 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)56 ErrorHandler (org.xml.sax.ErrorHandler)52 InputStream (java.io.InputStream)36 File (java.io.File)34 ArrayList (java.util.ArrayList)33 FileInputStream (java.io.FileInputStream)31 FileNotFoundException (java.io.FileNotFoundException)31 Element (org.w3c.dom.Element)30 StringReader (java.io.StringReader)21 NodeList (org.w3c.dom.NodeList)21 URL (java.net.URL)20 Test (org.junit.jupiter.api.Test)19 Node (org.w3c.dom.Node)19