### Question:
ToolspecValidator { public void validateWithXMLSchema() throws GeneratorException { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new File(ioc.getXmlConf())); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Source schemaFile = new StreamSource(new File("src/main/resources/toolspec.xsd")); Schema schema = schemaFactory.newSchema(schemaFile); Validator validator = schema.newValidator(); validator.validate(new DOMSource(doc)); logger.info("XML tool specification file successfully validated."); } catch (SAXException ex) { org.xml.sax.SAXParseException saxex = null; if (ex instanceof org.xml.sax.SAXParseException) { saxex = (org.xml.sax.SAXParseException) ex; logger.error("SAX parse error: " + saxex.getLocalizedMessage()); } else { logger.error("SAXException:", ex); } throw new GeneratorException("SAXException occurred while validating instance."); } catch (IOException ex) { throw new GeneratorException("IOException occurred while validating instance."); } catch (ParserConfigurationException ex) { throw new GeneratorException("ParserConfigurationException occurred while validating instance."); } } ToolspecValidator(Toolspec toolspec, Configuration ioc); void validateWithXMLSchema(); void validate(); boolean isValid(); void checkpoint(); void addError(Error err);  }### Answer:
@Test public void testValidateError() { try { Configuration ioc = new Configuration(); URL url = this.getClass().getResource("/Errortoolspec.xml"); File testXml = new File(url.getFile()); ioc.setXmlConf(testXml); ioc.setProjConf(new File(Constants.DEFAULT_PROJECT_PROPERTIES)); Toolspec toolspec = new Toolspec(); ToolspecValidator tv = new ToolspecValidator(toolspec, ioc); tv.validateWithXMLSchema(); fail("Should raise exception"); } catch (GeneratorException ex) { } }