use of org.xml.sax.helpers.LocatorImpl in project robovm by robovm.
the class XMLReaderAdapterTest method testSetDocumentLocator.
public void testSetDocumentLocator() {
// Ordinary case
LocatorImpl locator = new LocatorImpl();
adapter.setDocumentLocator(locator);
assertEquals("setDocumentLocator", logger.getMethod());
assertEquals(new Object[] { locator }, logger.getArgs());
// null case (for the DocumentHandler itself!)
adapter.setDocumentHandler(null);
adapter.setDocumentLocator(locator);
}
use of org.xml.sax.helpers.LocatorImpl in project robovm by robovm.
the class Locator2ImplTest method testLocatorImplLocator.
public void testLocatorImplLocator() {
Locator2Impl inner = new Locator2Impl();
inner.setPublicId(PUB);
inner.setSystemId(SYS);
inner.setLineNumber(ROW);
inner.setColumnNumber(COL);
inner.setEncoding(ENC);
inner.setXMLVersion(XML);
// Ordinary case
Locator2Impl outer = new Locator2Impl(inner);
assertEquals(PUB, outer.getPublicId());
assertEquals(SYS, outer.getSystemId());
assertEquals(ROW, outer.getLineNumber());
assertEquals(COL, outer.getColumnNumber());
assertEquals(ENC, outer.getEncoding());
assertEquals(XML, outer.getXMLVersion());
// Instance of old locator
outer = new Locator2Impl(new LocatorImpl(inner));
assertEquals(PUB, outer.getPublicId());
assertEquals(SYS, outer.getSystemId());
assertEquals(ROW, outer.getLineNumber());
assertEquals(COL, outer.getColumnNumber());
assertEquals(null, outer.getEncoding());
assertEquals(null, outer.getXMLVersion());
// No locator
try {
outer = new Locator2Impl(null);
fail("NullPointerException expected");
} catch (NullPointerException e) {
// Expected
}
}
use of org.xml.sax.helpers.LocatorImpl 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
}
}
use of org.xml.sax.helpers.LocatorImpl 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());
}
use of org.xml.sax.helpers.LocatorImpl in project jPOS by jpos.
the class GenericPackagerTest method testGenericContentHandlerFatalErrorThrowsSAXParseException.
@Test
public void testGenericContentHandlerFatalErrorThrowsSAXParseException() throws Throwable {
SAXParseException ex2 = new SAXParseException("testGenericContentHandlerParam1", new LocatorImpl());
try {
new GenericPackager().new GenericContentHandler().fatalError(ex2);
fail("Expected SAXParseException to be thrown");
} catch (SAXParseException ex) {
assertEquals("ex.getMessage()", "testGenericContentHandlerParam1", ex.getMessage());
assertNull("ex.getPublicId()", ex.getPublicId());
assertNull("ex.getSystemId()", ex.getSystemId());
assertEquals("ex.getLineNumber()", 0, ex.getLineNumber());
assertEquals("ex.getColumnNumber()", 0, ex.getColumnNumber());
assertNull("ex.getException()", ex.getException());
}
}
Aggregations