org.jdom2.test.cases.input.TestBuilderErrorHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdom Show documentation
Show all versions of jdom Show documentation
A complete, Java-based solution for accessing, manipulating,
and outputting XML data
package org.jdom2.test.cases.input;
import static org.junit.Assert.*;
import org.jdom2.input.sax.BuilderErrorHandler;
import org.junit.Test;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@SuppressWarnings("javadoc")
public class TestBuilderErrorHandler {
@Test
public void testWarning() {
BuilderErrorHandler handler = new BuilderErrorHandler();
try {
handler.warning(new SAXParseException(null, null, null, 0, 0));
} catch (Exception e) {
fail("Warning should not throw an exception, but got " + e.getClass() + ": " + e.getMessage());
}
}
@Test
public void testError() {
BuilderErrorHandler handler = new BuilderErrorHandler();
try {
handler.error(new SAXParseException(null, null, null, 0, 0));
fail("Error should throw a SAXException, but did not");
} catch (SAXException spe) {
//good
} catch (Exception e) {
fail("Error should throw a SAXException, but got " + e.getClass() + ": " + e.getMessage());
}
}
@Test
public void testFatalError() {
BuilderErrorHandler handler = new BuilderErrorHandler();
try {
handler.fatalError(new SAXParseException(null, null, null, 0, 0));
fail("Error should throw a SAXException, but did not");
} catch (SAXException spe) {
//good
} catch (Exception e) {
fail("Error should throw a SAXException, but got " + e.getClass() + ": " + e.getMessage());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy