@Test public void testValidateWithAllErrors() throws XmlDocumentReadFailureException{ XmlValidationResult result = sut.validateWithAllErrors(invalidC32); assertEquals(2, result.getExceptions().size()); for(SAXParseException e: result.getExceptions()){ assertTrue(e.getMessage().contains("noSuchElement") || e.getMessage().contains("noSuchElement2")); } }
public XmlValidationResult validateWithAllErrors(InputStream xmlInputStream) throws XmlDocumentReadFailureException { Validator validatorWithAllErrors = null; XmlValidationResult result = null; try { validatorWithAllErrors = createValidator(this.schema); Assert.notNull( validatorWithAllErrors, "There has been an error during XmlValidation initialization, the validatorWithAllErrors cannot be null."); result = new XmlValidationResult(); validatorWithAllErrors .setErrorHandler(new ErrorHandlerImpl(result)); validatorWithAllErrors.validate(new StreamSource(xmlInputStream)); } catch (final XmlSchemaFailureException e) { logger.error("XmlValidation initialization is failed: the schema cannot be loaded."); } catch (final SAXException e) { } catch (final IOException e) { logger.error(e.getMessage()); throw new XmlDocumentReadFailureException(e); } return result; }
XmlValidation { public XmlValidationResult validateWithAllErrors(InputStream xmlInputStream) throws XmlDocumentReadFailureException { Validator validatorWithAllErrors = null; XmlValidationResult result = null; try { validatorWithAllErrors = createValidator(this.schema); Assert.notNull( validatorWithAllErrors, "There has been an error during XmlValidation initialization, the validatorWithAllErrors cannot be null."); result = new XmlValidationResult(); validatorWithAllErrors .setErrorHandler(new ErrorHandlerImpl(result)); validatorWithAllErrors.validate(new StreamSource(xmlInputStream)); } catch (final XmlSchemaFailureException e) { logger.error("XmlValidation initialization is failed: the schema cannot be loaded."); } catch (final SAXException e) { } catch (final IOException e) { logger.error(e.getMessage()); throw new XmlDocumentReadFailureException(e); } return result; } }
XmlValidation { public XmlValidationResult validateWithAllErrors(InputStream xmlInputStream) throws XmlDocumentReadFailureException { Validator validatorWithAllErrors = null; XmlValidationResult result = null; try { validatorWithAllErrors = createValidator(this.schema); Assert.notNull( validatorWithAllErrors, "There has been an error during XmlValidation initialization, the validatorWithAllErrors cannot be null."); result = new XmlValidationResult(); validatorWithAllErrors .setErrorHandler(new ErrorHandlerImpl(result)); validatorWithAllErrors.validate(new StreamSource(xmlInputStream)); } catch (final XmlSchemaFailureException e) { logger.error("XmlValidation initialization is failed: the schema cannot be loaded."); } catch (final SAXException e) { } catch (final IOException e) { logger.error(e.getMessage()); throw new XmlDocumentReadFailureException(e); } return result; } XmlValidation(InputStream xsdInputStream, String schemaBasePath); }
XmlValidation { public XmlValidationResult validateWithAllErrors(InputStream xmlInputStream) throws XmlDocumentReadFailureException { Validator validatorWithAllErrors = null; XmlValidationResult result = null; try { validatorWithAllErrors = createValidator(this.schema); Assert.notNull( validatorWithAllErrors, "There has been an error during XmlValidation initialization, the validatorWithAllErrors cannot be null."); result = new XmlValidationResult(); validatorWithAllErrors .setErrorHandler(new ErrorHandlerImpl(result)); validatorWithAllErrors.validate(new StreamSource(xmlInputStream)); } catch (final XmlSchemaFailureException e) { logger.error("XmlValidation initialization is failed: the schema cannot be loaded."); } catch (final SAXException e) { } catch (final IOException e) { logger.error(e.getMessage()); throw new XmlDocumentReadFailureException(e); } return result; } XmlValidation(InputStream xsdInputStream, String schemaBasePath); boolean validate(InputStream xmlInputStream); boolean validate(String xml); XmlValidationResult validateWithAllErrors(InputStream xmlInputStream); XmlValidationResult validateWithAllErrors(String xml); }
XmlValidation { public XmlValidationResult validateWithAllErrors(InputStream xmlInputStream) throws XmlDocumentReadFailureException { Validator validatorWithAllErrors = null; XmlValidationResult result = null; try { validatorWithAllErrors = createValidator(this.schema); Assert.notNull( validatorWithAllErrors, "There has been an error during XmlValidation initialization, the validatorWithAllErrors cannot be null."); result = new XmlValidationResult(); validatorWithAllErrors .setErrorHandler(new ErrorHandlerImpl(result)); validatorWithAllErrors.validate(new StreamSource(xmlInputStream)); } catch (final XmlSchemaFailureException e) { logger.error("XmlValidation initialization is failed: the schema cannot be loaded."); } catch (final SAXException e) { } catch (final IOException e) { logger.error(e.getMessage()); throw new XmlDocumentReadFailureException(e); } return result; } XmlValidation(InputStream xsdInputStream, String schemaBasePath); boolean validate(InputStream xmlInputStream); boolean validate(String xml); XmlValidationResult validateWithAllErrors(InputStream xmlInputStream); XmlValidationResult validateWithAllErrors(String xml);  }