### Question:
RelaxNgValidator implements Validator { @Override public void validate(final InputStream stream, final Collection<Issue> issues) { javax.xml.validation.Validator validator = newValidator(); validator.setErrorHandler(new ErrorHandler() { @Override public void warning(SAXParseException exception) throws SAXException { issues.add(newIssue(Level.WARNING, exception)); } @Override public void fatalError(SAXParseException exception) throws SAXException { issues.add(newIssue(Level.ERROR, exception)); } @Override public void error(SAXParseException exception) throws SAXException { issues.add(newIssue(Level.ERROR, exception)); } }); try { validator.validate(new StreamSource(stream)); } catch (Exception e) { issues.add(newIssue(Level.ERROR, e)); } }  @Override void validate(final InputStream stream, final Collection<Issue> issues); @Override String toString();  }### Answer:
@Test public void acceptsValidRadlFile() { validate("<service xmlns='" + Radl.NAMESPACE_URI + "' name='test'/>"); assertTrue("Unexpected issues added: " + issues, issues.isEmpty()); }
@Test public void addsErrorsForSchemaViolations() { validate("<foo/>"); Issue expectedIssue = new Issue(RelaxNgValidator.class, Issue.Level.ERROR, 1, 7, "element \"foo\" not allowed anywhere; expected element \"service\" " + "(with xmlns=\"" + Radl.NAMESPACE_URI + "\")"); TestUtil.assertCollectionEquals("Issues", Arrays.asList(expectedIssue), issues); }