Skip to content

Commit

Permalink
Separated test-libiocml's dependance on test-qsar* by creating 'test-…
Browse files Browse the repository at this point in the history
…qsarcml' - this now tests the preexisting module 'qsarcml'

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Jul 31, 2013
1 parent 513d2b6 commit 8e2dfd5
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 67 deletions.
4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
test-render,test-ioformats,test-log4j,test-cip"/>
<foreach target="compile-module" param="module" trim="true"
parallel="${parallel}" maxthreads="${threadCount}"
list="test-formula,test-qsaratomic,test-qsarbond,
list="test-formula,test-qsaratomic,test-qsarbond,test-qsarcml,
test-pdb,test-pdbcml,test-smiles,test-extra,test-fragment,test-atomtype,
test-structgen,test-iordf,test-silent"/>
<foreach target="compile-module" param="module" trim="true"
Expand Down Expand Up @@ -1146,7 +1146,7 @@
list="core,data,datadebug,dict,diff,atomtype,standard,
io,builder3d,forcefield,valencycheck,charges,reaction,
smarts,fingerprint,smiles,qsar,qsaratomic,qsarbond,
qsarmolecular,qsarionpot,qsarprotein,pdb,pcore,inchi,
qsarcml,qsarmolecular,qsarionpot,qsarprotein,pdb,pcore,inchi,
structgen,libiomd,libiocml,pdbcml,formula,render,extra,fragment,sdg,
ioformats,log4j,smsd,signature,iordf,cip,tautomer,
isomorphism,renderbasic,renderawt,renderextra,silent,group,
Expand Down
1 change: 1 addition & 0 deletions src/META-INF/test-ioformats.cdkdepends
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cdk-iordf.jar
cdk-smiles.jar
cdk-pdb.jar
cdk-libiocml.jar
cdk-extra.jar
cdk-data.jar
cdk-test.jar
cdk-testdata.jar
3 changes: 0 additions & 3 deletions src/META-INF/test-libiocml.cdkdepends
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ cdk-test-io.jar
cdk-ioformats.jar
cdk-libiocml.jar
cdk-test.jar
cdk-qsar.jar
cdk-qsarmolecular.jar
cdk-qsarcml.jar
cdk-atomtype.jar
cdk-silent.jar
cdk-pdb.jar
Expand Down
16 changes: 15 additions & 1 deletion src/META-INF/test-qsarcml.cdkdepends
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
cdk-test.jar
cdk-test.jar
cdk-log4j.jar
cdk-annotation.jar
cdk-interfaces.jar
cdk-qsarcml.jar
cdk-io.jar
cdk-testdata.jar
cdk-libiocml.jar
cdk-test-libiocml.jar
cdk-qsar.jar
cdk-qsarmolecular.jar
cdk-data.jar
cdk-test-data.jar
cdk-core.jar
cdk-standard.jar
2 changes: 1 addition & 1 deletion src/META-INF/test-qsarcml.devellibdepends
Original file line number Diff line number Diff line change
@@ -1 +1 @@
junit-4.10.jar
junit-4.11.jar
4 changes: 4 additions & 0 deletions src/META-INF/test-qsarcml.libdepends
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vecmath*.jar
log4j*.jar
cmlxom-2.5-b1.jar
xom*.jar
22 changes: 0 additions & 22 deletions src/test/org/openscience/cdk/io/cml/CML2WriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionScheme;
import org.openscience.cdk.io.CMLWriter;
import org.openscience.cdk.libio.cml.QSARCustomizer;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.IMolecularDescriptor;
import org.openscience.cdk.qsar.descriptors.molecular.WeightDescriptor;
import org.openscience.cdk.silent.AtomContainer;
import org.openscience.cdk.silent.AtomContainerSet;
import org.openscience.cdk.silent.ChemModel;
Expand Down Expand Up @@ -185,25 +181,7 @@ public class CML2WriterTest extends CDKTestCase {
Assert.assertTrue(cmlContent.indexOf("<atom") != -1); // an Atom has to be present
}

@Test public void testQSARCustomization() throws Exception {
StringWriter writer = new StringWriter();
IAtomContainer molecule = MoleculeFactory.makeBenzene();
IMolecularDescriptor descriptor = new WeightDescriptor();

CMLWriter cmlWriter = new CMLWriter(writer);
cmlWriter.registerCustomizer(new QSARCustomizer());
DescriptorValue value = descriptor.calculate(molecule);
molecule.setProperty(value.getSpecification(), value);

cmlWriter.write(molecule);
String cmlContent = writer.toString();
logger.debug("****************************** testQSARCustomization()");
logger.debug(cmlContent);
logger.debug("******************************");
Assert.assertTrue(cmlContent.indexOf("<property") != -1 &&
cmlContent.indexOf("xmlns:qsar") != -1);
Assert.assertTrue(cmlContent.indexOf("#weight\"") != -1);
}

@Test public void testReactionCustomization() throws Exception {
StringWriter writer = new StringWriter();
Expand Down
38 changes: 0 additions & 38 deletions src/test/org/openscience/cdk/io/cml/CMLRoundTripTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.io.CMLReader;
import org.openscience.cdk.libio.cml.Convertor;
import org.openscience.cdk.libio.cml.QSARCustomizer;
import org.openscience.cdk.qsar.DescriptorSpecification;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.IMolecularDescriptor;
import org.openscience.cdk.qsar.descriptors.molecular.WeightDescriptor;
import org.openscience.cdk.templates.TestMoleculeFactory;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;
Expand All @@ -80,7 +75,6 @@ public class CMLRoundTripTest extends CDKTestCase {

@BeforeClass public static void setup() {
convertor = new Convertor(false, "");
convertor.registerCustomizer(new QSARCustomizer());
}

@Test public void testAtom() throws Exception {
Expand Down Expand Up @@ -526,39 +520,7 @@ public void testAtomStereoParity() throws Exception {
Assert.assertEquals(1, roundTrippedAgent.getAtomCount());
}

@Test public void testDescriptorValue_QSAR() throws Exception {
IAtomContainer molecule = MoleculeFactory.makeBenzene();
IMolecularDescriptor descriptor = new WeightDescriptor();

DescriptorValue originalValue = null;
originalValue = descriptor.calculate(molecule);
molecule.setProperty(originalValue.getSpecification(), originalValue);
IAtomContainer roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, molecule);

Assert.assertEquals(1, roundTrippedMol.getProperties().size());
System.out.println("" + roundTrippedMol.getProperties().keySet());
Object object = roundTrippedMol.getProperties().keySet().toArray()[0];
System.out.println("" + object);
Assert.assertTrue(object instanceof DescriptorSpecification);
DescriptorSpecification spec = (DescriptorSpecification)object;
Assert.assertEquals(descriptor.getSpecification().getSpecificationReference(),
spec.getSpecificationReference());
Assert.assertEquals(descriptor.getSpecification().getImplementationIdentifier(),
spec.getImplementationIdentifier());
Assert.assertEquals(descriptor.getSpecification().getImplementationTitle(),
spec.getImplementationTitle());
Assert.assertEquals(descriptor.getSpecification().getImplementationVendor(),
spec.getImplementationVendor());

Object value = roundTrippedMol.getProperty(spec);
Assert.assertNotNull(value);
Assert.assertTrue(value instanceof DescriptorValue);
DescriptorValue descriptorResult = (DescriptorValue)value;
Assert.assertEquals(originalValue.getClass().getName(),
descriptorResult.getClass().getName());
Assert.assertEquals(originalValue.getValue().toString(),
descriptorResult.getValue().toString());
}

@Test public void testDescriptorValue() throws Exception {
IAtomContainer molecule = TestMoleculeFactory.makeBenzene();
Expand Down
113 changes: 113 additions & 0 deletions src/test/org/openscience/cdk/io/cml/QSARCMLRoundTripTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright (c) 2013. John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* All we ask is that proper credit is given for our work, which includes
* - but is not limited to - adding the above copyright notice to the beginning
* of your source code files, and to any copyright notice that you may distribute
* with programs based on this work.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/

package org.openscience.cdk.io.cml;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.io.CMLWriter;
import org.openscience.cdk.libio.cml.Convertor;
import org.openscience.cdk.libio.cml.QSARCustomizer;
import org.openscience.cdk.qsar.DescriptorSpecification;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.IMolecularDescriptor;
import org.openscience.cdk.qsar.descriptors.molecular.WeightDescriptor;
import org.openscience.cdk.templates.TestMoleculeFactory;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;

import java.io.StringWriter;

/**
* @author John May
* @cdk.module test-qsarcml
*/
public class QSARCMLRoundTripTest {

private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(QSARCMLRoundTripTest.class);

private static Convertor convertor;

@BeforeClass public static void setup() {
convertor = new Convertor(false, "");
convertor.registerCustomizer(new QSARCustomizer());
}

@Test public void testDescriptorValue_QSAR() throws Exception {
IAtomContainer molecule = TestMoleculeFactory.makeBenzene();
IMolecularDescriptor descriptor = new WeightDescriptor();

DescriptorValue originalValue = null;
originalValue = descriptor.calculate(molecule);
molecule.setProperty(originalValue.getSpecification(), originalValue);
IAtomContainer roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, molecule);

Assert.assertEquals(1, roundTrippedMol.getProperties().size());
System.out.println("" + roundTrippedMol.getProperties().keySet());
Object object = roundTrippedMol.getProperties().keySet().toArray()[0];
System.out.println("" + object);
Assert.assertTrue(object instanceof DescriptorSpecification);
DescriptorSpecification spec = (DescriptorSpecification)object;
Assert.assertEquals(descriptor.getSpecification().getSpecificationReference(),
spec.getSpecificationReference());
Assert.assertEquals(descriptor.getSpecification().getImplementationIdentifier(),
spec.getImplementationIdentifier());
Assert.assertEquals(descriptor.getSpecification().getImplementationTitle(),
spec.getImplementationTitle());
Assert.assertEquals(descriptor.getSpecification().getImplementationVendor(),
spec.getImplementationVendor());

Object value = roundTrippedMol.getProperty(spec);
Assert.assertNotNull(value);
Assert.assertTrue(value instanceof DescriptorValue);
DescriptorValue descriptorResult = (DescriptorValue)value;
Assert.assertEquals(originalValue.getClass().getName(),
descriptorResult.getClass().getName());
Assert.assertEquals(originalValue.getValue().toString(),
descriptorResult.getValue().toString());
}

@Test public void testQSARCustomization() throws Exception {
StringWriter writer = new StringWriter();
IAtomContainer molecule = TestMoleculeFactory.makeBenzene();
IMolecularDescriptor descriptor = new WeightDescriptor();

CMLWriter cmlWriter = new CMLWriter(writer);
cmlWriter.registerCustomizer(new QSARCustomizer());
DescriptorValue value = descriptor.calculate(molecule);
molecule.setProperty(value.getSpecification(), value);

cmlWriter.write(molecule);
String cmlContent = writer.toString();
logger.debug("****************************** testQSARCustomization()");
logger.debug(cmlContent);
logger.debug("******************************");
Assert.assertTrue(cmlContent.indexOf("<property") != -1 &&
cmlContent.indexOf("xmlns:qsar") != -1);
Assert.assertTrue(cmlContent.indexOf("#weight\"") != -1);
}

}
40 changes: 40 additions & 0 deletions src/test/org/openscience/cdk/modulesuites/MqsarcmlTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2013. John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* All we ask is that proper credit is given for our work, which includes
* - but is not limited to - adding the above copyright notice to the beginning
* of your source code files, and to any copyright notice that you may distribute
* with programs based on this work.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/
package org.openscience.cdk.modulesuites;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.openscience.cdk.io.cml.QSARCMLRoundTripTest;

/**
* test suite for qsarcml module
*
* @cdk.module test-qsarcml
*/
@RunWith(value=Suite.class)
@SuiteClasses(value={
QSARCMLRoundTripTest.class
})
public class MqsarcmlTests {}

0 comments on commit 8e2dfd5

Please sign in to comment.