@Test public void validateSchemaTranslatesSAXParseExceptionIntoValidationError() throws Exception { when(fac.newSchema(any(Source[].class))) .thenThrow(new SAXParseException("foo", new LocatorImpl())); JAXPValidator v = new JAXPValidator(Languages.W3C_XML_SCHEMA_NS_URI, fac); v.setSchemaSource(new StreamSource(BOOK_XSD)); ValidationResult r = v.validateSchema(); assertFalse(r.isValid()); assertTrue(r.getProblems().iterator().hasNext()); }
@Override public ValidationResult validateSchema() { ValidationHandler v = new ValidationHandler(); SchemaFactory f = getFactory(); f.setErrorHandler(v); try { f.newSchema(getSchemaSources()); } catch (SAXParseException e) { v.error((SAXParseException) e); } catch (SAXException e) { throw new XMLUnitException(e); } finally { f.setErrorHandler(null); } return v.getResult(); }
JAXPValidator extends Validator { @Override public ValidationResult validateSchema() { ValidationHandler v = new ValidationHandler(); SchemaFactory f = getFactory(); f.setErrorHandler(v); try { f.newSchema(getSchemaSources()); } catch (SAXParseException e) { v.error((SAXParseException) e); } catch (SAXException e) { throw new XMLUnitException(e); } finally { f.setErrorHandler(null); } return v.getResult(); } }
JAXPValidator extends Validator { @Override public ValidationResult validateSchema() { ValidationHandler v = new ValidationHandler(); SchemaFactory f = getFactory(); f.setErrorHandler(v); try { f.newSchema(getSchemaSources()); } catch (SAXParseException e) { v.error((SAXParseException) e); } catch (SAXException e) { throw new XMLUnitException(e); } finally { f.setErrorHandler(null); } return v.getResult(); } JAXPValidator(String language);  JAXPValidator(String language, SchemaFactory factory); }
JAXPValidator extends Validator { @Override public ValidationResult validateSchema() { ValidationHandler v = new ValidationHandler(); SchemaFactory f = getFactory(); f.setErrorHandler(v); try { f.newSchema(getSchemaSources()); } catch (SAXParseException e) { v.error((SAXParseException) e); } catch (SAXException e) { throw new XMLUnitException(e); } finally { f.setErrorHandler(null); } return v.getResult(); } JAXPValidator(String language);  JAXPValidator(String language, SchemaFactory factory); final void setSchema(Schema s); @Override ValidationResult validateSchema(); @Override ValidationResult validateInstance(Source s); }
JAXPValidator extends Validator { @Override public ValidationResult validateSchema() { ValidationHandler v = new ValidationHandler(); SchemaFactory f = getFactory(); f.setErrorHandler(v); try { f.newSchema(getSchemaSources()); } catch (SAXParseException e) { v.error((SAXParseException) e); } catch (SAXException e) { throw new XMLUnitException(e); } finally { f.setErrorHandler(null); } return v.getResult(); } JAXPValidator(String language);  JAXPValidator(String language, SchemaFactory factory); final void setSchema(Schema s); @Override ValidationResult validateSchema(); @Override ValidationResult validateInstance(Source s);  }