XmlValidation { public boolean validate(InputStream xmlInputStream) throws InvalidXmlDocumentException, XmlDocumentReadFailureException { Assert.notNull( this.validator, "There has been an error during XmlValidation initialization, the validator cannot be null."); try { validator.validate(new StreamSource(xmlInputStream)); } catch (final SAXException e) { logger.error(e.getMessage()); throw new InvalidXmlDocumentException(e); } catch (final IOException e) { logger.error(e.getMessage()); throw new XmlDocumentReadFailureException(e); } return true; } XmlValidation(InputStream xsdInputStream, String schemaBasePath); boolean validate(InputStream xmlInputStream); boolean validate(String xml); XmlValidationResult validateWithAllErrors(InputStream xmlInputStream); XmlValidationResult validateWithAllErrors(String xml);  }
@Test(expected = InvalidXmlDocumentException.class) public void testValidateInputStream() throws InvalidXmlDocumentException, XmlDocumentReadFailureException { assertFalse(sut.validate(invalidC32)); }
@Test public void testValidateString() throws InvalidXmlDocumentException, XmlDocumentReadFailureException { assertTrue(sut.validate(validC32)); }