@Test public void testWrite_IAtomContainerSet_Properties_Off() throws Exception { StringWriter writer = new StringWriter(); IAtomContainerSet molSet = new AtomContainerSet(); IAtomContainer molecule = new AtomContainer(); molecule.addAtom(new Atom("C")); molecule.setProperty("foo", "bar"); molSet.addAtomContainer(molecule); SDFWriter sdfWriter = new SDFWriter(writer); Properties sdfWriterProps = new Properties(); sdfWriterProps.put("writeProperties", "false"); sdfWriter.addChemObjectIOListener(new PropertiesListener(sdfWriterProps)); sdfWriter.customizeJob(); sdfWriter.write(molSet); sdfWriter.close(); String result = writer.toString(); Assert.assertFalse(result.contains("<foo>")); }
/** * @cdk.bug 3392485 */ @Test public void testIOPropPropagation() throws Exception { IAtomContainer mol = TestMoleculeFactory.makeBenzene(); for (IAtom atom : mol.atoms()) { atom.setFlag(ISAROMATIC, true); } for (IBond bond : mol.bonds()) { bond.setFlag(ISAROMATIC, true); } StringWriter strWriter = new StringWriter(); SDFWriter writer = new SDFWriter(strWriter); Properties sdfWriterProps = new Properties(); sdfWriterProps.put("WriteAromaticBondTypes", "true"); writer.addChemObjectIOListener(new PropertiesListener(sdfWriterProps)); writer.customizeJob(); writer.write(mol); writer.close(); String output = strWriter.toString(); Assert.assertTrue(output.contains("4 0 0 0 0")); }