@Test public void shouldTranslateSAXParseExceptionDuringParseToValidationError() throws Exception { doThrow(new SAXParseException("foo", new LocatorImpl())) .when(parser).parse(any(InputSource.class), any(DefaultHandler.class)); ParsingValidator v = new ParsingValidator(Languages.XML_DTD_NS_URI); v.setSchemaSource(new StreamSource(new File(BOOK_DTD))); ValidationResult r = v.validateInstance(new StreamSource(new File(TEST_RESOURCE_DIR + "BookWithDoctype.xml")), fac); assertFalse(r.isValid()); assertTrue(r.getProblems().iterator().hasNext()); }
@Override public ValidationResult validateInstance(Source s) { return validateInstance(s, SAXParserFactory.newInstance()); }
ParsingValidator extends Validator { @Override public ValidationResult validateInstance(Source s) { return validateInstance(s, SAXParserFactory.newInstance()); } }
ParsingValidator extends Validator { @Override public ValidationResult validateInstance(Source s) { return validateInstance(s, SAXParserFactory.newInstance()); } ParsingValidator(String language); }
ParsingValidator extends Validator { @Override public ValidationResult validateInstance(Source s) { return validateInstance(s, SAXParserFactory.newInstance()); } ParsingValidator(String language); void setSchemaURI(String uri); @Override ValidationResult validateSchema(); @Override ValidationResult validateInstance(Source s); ValidationResult validateInstance(Source s, SAXParserFactory factory); }
ParsingValidator extends Validator { @Override public ValidationResult validateInstance(Source s) { return validateInstance(s, SAXParserFactory.newInstance()); } ParsingValidator(String language); void setSchemaURI(String uri); @Override ValidationResult validateSchema(); @Override ValidationResult validateInstance(Source s); ValidationResult validateInstance(Source s, SAXParserFactory factory);  }