@Test public void testXMLValidityPDB() throws Exception { assertValidCML("org/openscience/cdk/config/data/pdb_atomtypes.xml", "PDB"); }
private void assertValidCML(String atomTypeList, String shortcut) throws Exception { InputStream ins = this.getClass().getClassLoader().getResourceAsStream(atomTypeList); File tmpInput = copyFileToTmp(shortcut, ".cmlinput", ins, "../../io/cml/data/cml25b1.xsd", "file://" + tmpCMLSchema.getAbsolutePath()); Assert.assertNotNull("Could not find the atom type list CML source", ins); InputStream cmlSchema = new FileInputStream(tmpCMLSchema); Assert.assertNotNull("Could not find the CML schema", cmlSchema); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); factory.setAttribute(JAXP_SCHEMA_LANGUAGE, cmlSchema); factory.setFeature("http://apache.org/xml/features/validation/schema", true); DocumentBuilder parser = factory.newDocumentBuilder(); parser.setErrorHandler(new SAXValidityErrorHandler(shortcut)); parser.parse(new FileInputStream(tmpInput)); }
@Test public void testXMLValidityMol2() throws Exception { assertValidCML("org/openscience/cdk/config/data/mol2_atomtypes.xml", "Mol2"); }
@Test public void testXMLValidityMMFF94() throws Exception { assertValidCML("org/openscience/cdk/config/data/mmff94_atomtypes.xml", "MMFF94"); }
@Test public void testXMLValidityMM2() throws Exception { assertValidCML("org/openscience/cdk/config/data/mm2_atomtypes.xml", "MM2"); }
@Test public void testXMLValidityStructGen() throws Exception { assertValidCML("org/openscience/cdk/config/data/structgen_atomtypes.xml", "StructGen"); }