### Question:
XmlValidator { public void validate(Document doc) { try { doValidate(doc); } catch (Exception e) { throw new PluginException("Error validating document: " + e, e); } } XmlValidator(InterceptingResolver resolver); void validate(Document doc);  }### Answer:
@Test public void testValidFile() { File xmlFile = Files.fromResource("SomeService.xml"); Document xml = XmlUtil.parse(xmlFile, resolver); new XmlValidator(resolver).validate(xml); }
@Test public void testValidFileNewVersion() { File xmlFile = Files.fromResource("SomeService3.3.xml"); Document xml = XmlUtil.parse(xmlFile, resolver); new XmlValidator(resolver).validate(xml); }
@Test public void testInvalidFile() { File xmlFile = Files.fromResource("BrokenService.xml"); Document xml = XmlUtil.parse(xmlFile, resolver); try { new XmlValidator(resolver).validate(xml); fail("Should have thrown an exception"); } catch (Exception e) { assertTrue("Should have validation error about invalid element, instead got: " + e, e.getMessage().contains("AnInvalidElement")); } }