|
32 | 32 | import org.openscience.cdk.interfaces.IBond; |
33 | 33 | import org.openscience.cdk.interfaces.IChemObjectBuilder; |
34 | 34 | import org.openscience.cdk.interfaces.ITetrahedralChirality; |
| 35 | +import org.openscience.cdk.io.listener.PropertiesListener; |
35 | 36 | import org.openscience.cdk.sgroup.Sgroup; |
36 | 37 | import org.openscience.cdk.sgroup.SgroupKey; |
37 | 38 | import org.openscience.cdk.sgroup.SgroupType; |
|
48 | 49 | import java.util.ArrayList; |
49 | 50 | import java.util.Collections; |
50 | 51 | import java.util.List; |
| 52 | +import java.util.Properties; |
51 | 53 |
|
52 | 54 | import static org.hamcrest.CoreMatchers.containsString; |
53 | 55 | import static org.junit.Assert.assertThat; |
@@ -446,6 +448,26 @@ public void writeDimensionField3D() throws Exception { |
446 | 448 | assertThat(sw.toString(), containsString("3D")); |
447 | 449 | } |
448 | 450 |
|
| 451 | + @Test |
| 452 | + public void writeCustomTitle() throws Exception { |
| 453 | + IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); |
| 454 | + IAtomContainer mol = builder.newAtomContainer(); |
| 455 | + IAtom atom = builder.newAtom(); |
| 456 | + atom.setSymbol("C"); |
| 457 | + atom.setImplicitHydrogenCount(4); |
| 458 | + atom.setPoint3d(new Point3d(0.5, 0.5, 0.1)); |
| 459 | + mol.addAtom(atom); |
| 460 | + StringWriter sw = new StringWriter(); |
| 461 | + try (MDLV3000Writer mdlw = new MDLV3000Writer(sw)) { |
| 462 | + Properties sdfWriterProps = new Properties(); |
| 463 | + sdfWriterProps.put("PorgramName", "FakeNews"); |
| 464 | + mdlw.addChemObjectIOListener(new PropertiesListener(sdfWriterProps)); |
| 465 | + // mdlw.customizeJob(); |
| 466 | + mdlw.write(mol); |
| 467 | + } |
| 468 | + assertThat(sw.toString(), containsString("FakeNews")); |
| 469 | + } |
| 470 | + |
449 | 471 | private String writeToStr(IAtomContainer mol) throws IOException, CDKException { |
450 | 472 | StringWriter sw = new StringWriter(); |
451 | 473 | try (MDLV3000Writer mdlw = new MDLV3000Writer(sw)) { |
|
0 commit comments