Skip to content

Commit

Permalink
Merge pull request #245 from cdk/release-prep
Browse files Browse the repository at this point in the history
Release prep
  • Loading branch information
egonw committed Oct 9, 2016
2 parents 40b8dad + 9449cb7 commit dce858e
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 105 deletions.
Expand Up @@ -95,7 +95,7 @@ public static Dictionary unmarshal(Reader reader) {
return dict;
}

public void addEntry(Entry entry) {
void addEntry(Entry entry) {
entries.put(entry.getID().toLowerCase(), entry);
}

Expand Down
Expand Up @@ -25,6 +25,7 @@

import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
Expand All @@ -44,6 +45,8 @@
*/
public class DictionaryDatabase {

private static final Map<String,Dictionary> cache = new HashMap<>();

public final static String DICTREFPROPERTYNAME = "org.openscience.cdk.dict";

private ILoggingTool logger = LoggingToolFactory
Expand Down Expand Up @@ -76,23 +79,29 @@ private Dictionary readDictionary(String databaseLocator, String type) {
databaseLocator += "." + type.substring(0, type.length() - 6);
else
databaseLocator += "." + type;
logger.info("Reading dictionary from ", databaseLocator);
try {
InputStreamReader reader = new InputStreamReader(this.getClass().getClassLoader()
.getResourceAsStream(databaseLocator));
if (type.equals("owl")) {
dictionary = OWLFile.unmarshal(reader);
} else if (type.equals("owl_React")) {
dictionary = OWLReact.unmarshal(reader);
} else { // assume XML using Castor
dictionary = Dictionary.unmarshal(reader);
if (cache.containsKey(databaseLocator)) {
return cache.get(databaseLocator);
}
else {
logger.info("Reading dictionary from ", databaseLocator);
try {
InputStreamReader reader = new InputStreamReader(this.getClass().getClassLoader()
.getResourceAsStream(databaseLocator));
if (type.equals("owl")) {
dictionary = OWLFile.unmarshal(reader);
} else if (type.equals("owl_React")) {
dictionary = OWLReact.unmarshal(reader);
} else { // assume XML using Castor
dictionary = Dictionary.unmarshal(reader);
}
} catch (Exception exception) {
dictionary = null;
logger.error("Could not read dictionary ", databaseLocator);
logger.debug(exception);
}
} catch (Exception exception) {
dictionary = null;
logger.error("Could not read dictionary ", databaseLocator);
logger.debug(exception);
cache.put(databaseLocator, dictionary);
return dictionary;
}
return dictionary;
}

/**
Expand Down
Expand Up @@ -20,11 +20,13 @@

import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.openscience.cdk.Atom;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.LonePair;
import org.openscience.cdk.SingleElectron;
import org.openscience.cdk.SlowTest;
import org.openscience.cdk.aromaticity.Aromaticity;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
Expand Down Expand Up @@ -393,6 +395,7 @@ public void testGetStructures_IAtomContainer() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testFlagActiveCenter1() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(new Atom("C"));
Expand Down Expand Up @@ -592,6 +595,7 @@ public void testFluoroethene() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testFluorobenzene() throws Exception {

IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
Expand Down Expand Up @@ -678,6 +682,7 @@ public void testFluorobenzene() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testFluorobenzeneContainer() throws Exception {

IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
Expand Down Expand Up @@ -715,6 +720,7 @@ public void testFluorobenzeneContainer() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testFluorobenzene_symm() throws Exception {

IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
Expand Down Expand Up @@ -801,6 +807,7 @@ public void testFluorobenzene_symm() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testAniline() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "N"));
Expand Down Expand Up @@ -869,6 +876,7 @@ public void testAniline_Symm() throws Exception {
* @throws Exception
*/
@Test
@Category(SlowTest.class)
public void testAllyl() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "C"));
Expand Down Expand Up @@ -896,6 +904,7 @@ public void testAllyl() throws Exception {
* @throws Exception
*/
@Test
@Category(SlowTest.class)
public void testAllylRadical() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "C"));
Expand Down Expand Up @@ -1134,6 +1143,7 @@ public void testCyclobutadiene() throws Exception {
* @cdk.bug 1728830
*/
@Test
@Category(SlowTest.class)
public void testBenzene() throws Exception {
IAtomContainer molecule = TestMoleculeFactory.makeBenzene();
addExplicitHydrogens(molecule);
Expand All @@ -1155,6 +1165,7 @@ public void testBenzene() throws Exception {
* @throws Exception
*/
@Test
@Category(SlowTest.class)
public void testGetContainers_IAtomContainer() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "O"));
Expand Down Expand Up @@ -1229,6 +1240,7 @@ public void testGetContainers2Groups() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testGetContainer_IAtomContainer_IAtom() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
IAtom atom1 = builder.newInstance(IAtom.class, "C");
Expand Down Expand Up @@ -1276,6 +1288,7 @@ public void testGetContainer_IAtomContainer_IAtom() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testGetContainer_IAtomContainer_IBond() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
IAtom atom1 = builder.newInstance(IAtom.class, "C");
Expand Down Expand Up @@ -1323,6 +1336,7 @@ public void testGetContainer_IAtomContainer_IBond() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testGetID() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
IAtom atom1 = builder.newInstance(IAtom.class, "C");
Expand Down Expand Up @@ -1382,6 +1396,7 @@ public void testGetID() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testGetContainersFluoromethylbenzene() throws Exception {

IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
Expand Down Expand Up @@ -1429,6 +1444,7 @@ public void testGetContainersFluoromethylbenzene() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testGetContainersFluorobenzene() throws Exception {

IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
Expand Down Expand Up @@ -1474,6 +1490,8 @@ public void testGetContainersFluorobenzene() throws Exception {
* @return The test suite
*/
@Test

@Category(SlowTest.class)
public void test1Propene2chloro() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "Cl"));
Expand Down Expand Up @@ -1502,6 +1520,7 @@ public void test1Propene2chloro() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testBenzene1bromo4methoxy() throws Exception {
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "F"));
Expand Down Expand Up @@ -1588,6 +1607,7 @@ public void testGetMaximalStructures() throws Exception {
* @return The test suite
*/
@Test
@Category(SlowTest.class)
public void testSetMaximalStructures_int() throws Exception {
StructureResonanceGenerator gRI = new StructureResonanceGenerator();
Assert.assertEquals(50, gRI.getMaximalStructures());
Expand Down
Expand Up @@ -142,10 +142,10 @@ public void testBug706786() throws Exception {
assertThat(
superBits.asBitSet(),
is(asBitSet(53, 56, 65, 71, 73, 88, 97, 100, 104, 111, 112, 126, 130, 136, 138, 139, 140, 142, 143,
144, 145, 148, 149, 151, 153, 156, 158, 159, 162, 163, 164)));
144, 145, 148, 149, 151, 153, 156, 158, 159, 161, 162, 163, 164)));
assertThat(
subBits.asBitSet(),
is(asBitSet(56, 97, 100, 104, 108, 112, 117, 127, 131, 136, 143, 144, 146, 151, 152, 156, 162, 163, 164)));
is(asBitSet(56, 97, 100, 104, 108, 112, 117, 127, 131, 136, 143, 144, 146, 151, 152, 156, 161, 162, 163, 164)));
}

}
Expand Up @@ -22,7 +22,9 @@

import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.SlowTest;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
Expand Down Expand Up @@ -56,6 +58,7 @@ public void setDescriptor(Class<? extends IAtomicDescriptor> descriptorClass) th
}

@Test
@Category(SlowTest.class)
public void testCalculate_IAtomContainer() throws Exception {
IAtomContainer mol = someoneBringMeSomeWater();

Expand All @@ -76,6 +79,7 @@ public void testCalculate_IAtomContainer() throws Exception {
* @throws Exception Passed on from calculate.
*/
@Test
@Category(SlowTest.class)
public void testLabels() throws Exception {
IAtomContainer mol = someoneBringMeSomeWater();

Expand All @@ -101,6 +105,7 @@ public void testLabels() throws Exception {
* of the names
*/
@Test
@Category(SlowTest.class)
public void testNamesConsistency() {
IAtomContainer mol = someoneBringMeSomeWater();

Expand All @@ -116,6 +121,7 @@ public void testNamesConsistency() {
}

@Test
@Category(SlowTest.class)
public void testCalculate_NoModifications() throws Exception {
IAtomContainer mol = someoneBringMeSomeWater();
IAtom atom = mol.getAtom(1);
Expand Down

0 comments on commit dce858e

Please sign in to comment.