Skip to content

Commit 40c40ee

Browse files
committed
Unit test for writing a custom title
1 parent c3d0f16 commit 40c40ee

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

storage/ctab/src/test/java/org/openscience/cdk/io/MDLV3000WriterTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.openscience.cdk.interfaces.IBond;
3333
import org.openscience.cdk.interfaces.IChemObjectBuilder;
3434
import org.openscience.cdk.interfaces.ITetrahedralChirality;
35+
import org.openscience.cdk.io.listener.PropertiesListener;
3536
import org.openscience.cdk.sgroup.Sgroup;
3637
import org.openscience.cdk.sgroup.SgroupKey;
3738
import org.openscience.cdk.sgroup.SgroupType;
@@ -48,6 +49,7 @@
4849
import java.util.ArrayList;
4950
import java.util.Collections;
5051
import java.util.List;
52+
import java.util.Properties;
5153

5254
import static org.hamcrest.CoreMatchers.containsString;
5355
import static org.junit.Assert.assertThat;
@@ -446,6 +448,26 @@ public void writeDimensionField3D() throws Exception {
446448
assertThat(sw.toString(), containsString("3D"));
447449
}
448450

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+
449471
private String writeToStr(IAtomContainer mol) throws IOException, CDKException {
450472
StringWriter sw = new StringWriter();
451473
try (MDLV3000Writer mdlw = new MDLV3000Writer(sw)) {

0 commit comments

Comments
 (0)