Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 350ce8f

Browse files
johnmayegonw
authored andcommitted
Avoid test-jar dependency for qsarcml - we only need the roundtrip function.
1 parent 777484a commit 350ce8f

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

descriptor/qsarcml/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@
7373
<type>test-jar</type>
7474
<scope>test</scope>
7575
</dependency>
76-
<dependency>
77-
<groupId>${project.groupId}</groupId>
78-
<artifactId>cdk-libiocml</artifactId>
79-
<version>${project.parent.version}</version>
80-
<type>test-jar</type>
81-
<scope>test</scope>
82-
</dependency>
8376
<dependency>
8477
<groupId>${project.groupId}</groupId>
8578
<artifactId>cdk-qsarmolecular</artifactId>

descriptor/qsarcml/src/test/java/org/openscience/cdk/io/cml/QSARCMLRoundTripTest.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@
2424

2525
package org.openscience.cdk.io.cml;
2626

27+
import nu.xom.Element;
2728
import org.junit.Assert;
2829
import org.junit.BeforeClass;
2930
import org.junit.Test;
3031
import org.openscience.cdk.interfaces.IAtomContainer;
32+
import org.openscience.cdk.interfaces.IAtomContainerSet;
33+
import org.openscience.cdk.interfaces.IChemFile;
34+
import org.openscience.cdk.interfaces.IChemModel;
35+
import org.openscience.cdk.interfaces.IChemSequence;
36+
import org.openscience.cdk.io.CMLReader;
3137
import org.openscience.cdk.io.CMLWriter;
3238
import org.openscience.cdk.libio.cml.Convertor;
3339
import org.openscience.cdk.libio.cml.QSARCustomizer;
@@ -39,10 +45,11 @@
3945
import org.openscience.cdk.tools.ILoggingTool;
4046
import org.openscience.cdk.tools.LoggingToolFactory;
4147

48+
import java.io.ByteArrayInputStream;
4249
import java.io.StringWriter;
4350

4451
/**
45-
* @author John May
52+
* @author John Mayfield
4653
* @cdk.module test-qsarcml
4754
*/
4855
public class QSARCMLRoundTripTest {
@@ -57,6 +64,34 @@ public static void setup() {
5764
convertor.registerCustomizer(new QSARCustomizer());
5865
}
5966

67+
// See also CMLRoundTripTool
68+
public static IAtomContainer roundTripMolecule(Convertor convertor, IAtomContainer mol) throws Exception {
69+
String cmlString = "<!-- failed -->";
70+
Element cmlDOM = convertor.cdkAtomContainerToCMLMolecule(mol);
71+
cmlString = cmlDOM.toXML();
72+
73+
IAtomContainer roundTrippedMol = null;
74+
logger.debug("CML string: ", cmlString);
75+
CMLReader reader = new CMLReader(new ByteArrayInputStream(cmlString.getBytes()));
76+
77+
IChemFile file = (IChemFile) reader.read(new org.openscience.cdk.ChemFile());
78+
reader.close();
79+
Assert.assertNotNull(file);
80+
Assert.assertEquals(1, file.getChemSequenceCount());
81+
IChemSequence sequence = file.getChemSequence(0);
82+
Assert.assertNotNull(sequence);
83+
Assert.assertEquals(1, sequence.getChemModelCount());
84+
IChemModel chemModel = sequence.getChemModel(0);
85+
Assert.assertNotNull(chemModel);
86+
IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
87+
Assert.assertNotNull(moleculeSet);
88+
Assert.assertEquals(1, moleculeSet.getAtomContainerCount());
89+
roundTrippedMol = moleculeSet.getAtomContainer(0);
90+
Assert.assertNotNull(roundTrippedMol);
91+
92+
return roundTrippedMol;
93+
}
94+
6095
@Test
6196
public void testDescriptorValue_QSAR() throws Exception {
6297
IAtomContainer molecule = TestMoleculeFactory.makeBenzene();
@@ -65,7 +100,7 @@ public void testDescriptorValue_QSAR() throws Exception {
65100
DescriptorValue originalValue = null;
66101
originalValue = descriptor.calculate(molecule);
67102
molecule.setProperty(originalValue.getSpecification(), originalValue);
68-
IAtomContainer roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, molecule);
103+
IAtomContainer roundTrippedMol = roundTripMolecule(convertor, molecule);
69104

70105
Assert.assertEquals(1, roundTrippedMol.getProperties().size());
71106
Object object = roundTrippedMol.getProperties().keySet().toArray()[0];

0 commit comments

Comments
 (0)