Search in sources :

Example 71 with SAXParseException

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

the class XMLFilterImplTest method testError.

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

Example 72 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 73 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 74 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 75 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)

Aggregations

SAXParseException (org.xml.sax.SAXParseException)206 SAXException (org.xml.sax.SAXException)109 IOException (java.io.IOException)75 DocumentBuilder (javax.xml.parsers.DocumentBuilder)53 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)47 Document (org.w3c.dom.Document)47 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)42 InputSource (org.xml.sax.InputSource)39 ErrorHandler (org.xml.sax.ErrorHandler)34 Test (org.junit.Test)28 Element (org.w3c.dom.Element)24 InputStream (java.io.InputStream)20 ArrayList (java.util.ArrayList)18 NodeList (org.w3c.dom.NodeList)18 FileInputStream (java.io.FileInputStream)17 FileNotFoundException (java.io.FileNotFoundException)17 File (java.io.File)16 Node (org.w3c.dom.Node)13 StringReader (java.io.StringReader)12 URL (java.net.URL)11