Commits

petermr committed 6023da2

coordinating modules

Comments (0)

Files changed (12)

jc-molecule-all/pom.xml

             <artifactId>jc-molecule-xyz</artifactId>
             <version>${project.version}</version>
         </dependency>
+        
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
     </dependencies>
 
 </project>

jc-molecule-all/src/main/java/org/xmlcml/cml/converters/molecule/registry/MoleculeConverterRegistry.java

+package org.xmlcml.cml.converters.molecule.registry;
+
+import org.xmlcml.cml.converters.registry.ConverterRegistry;
+
+/**
+ * @author pm286
+ */
+public class MoleculeConverterRegistry extends ConverterRegistry {
+
+    /** create singleton registry
+     */
+    private static MoleculeConverterRegistry MOLECULE_CONVERTER_REGISTRY = null;
+
+    public static synchronized MoleculeConverterRegistry getDefaultConverterRegistry() {
+    	if (MOLECULE_CONVERTER_REGISTRY == null) {
+    		MOLECULE_CONVERTER_REGISTRY = new MoleculeConverterRegistry(MoleculeConverterRegistry.class.getClassLoader());
+    		MOLECULE_CONVERTER_REGISTRY.populateAndRegister();
+    	}
+    	return MOLECULE_CONVERTER_REGISTRY;
+    }
+
+    public MoleculeConverterRegistry(ClassLoader classLoader) {
+    	super(classLoader);
+    }
+
+    public MoleculeConverterRegistry(Class clazz) {
+    	super(clazz);
+    }
+
+
+}

jc-molecule-all/src/test/java/org/xmlcml/cml/converters/molecule/registry/MoleculeConverterRegistryTest.java

+package org.xmlcml.cml.converters.molecule.registry;
+
+import static org.junit.Assert.assertNull;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.xmlcml.cml.converters.Converter;
+import org.xmlcml.cml.converters.MimeType;
+import org.xmlcml.cml.converters.cml.CML2CMLLiteConverter;
+import org.xmlcml.cml.converters.cml.CMLCommon;
+import org.xmlcml.cml.converters.molecule.registry.MoleculeConverterRegistry;
+import org.xmlcml.cml.converters.registry.ConverterRegistry;
+import org.xmlcml.cml.converters.registry.TypePair;
+import org.xmlcml.cml.converters.molecule.mdl.MDLModule;
+
+//@Ignore
+public class MoleculeConverterRegistryTest {
+
+	String CML = "chemical/x-cml";
+	String CDX = "chemical/x-cdx";
+	String FOO = "chemical/x-foo";
+	TypePair PAIR_OK  = new TypePair(FOO, CML);
+	TypePair PAIR_MISSING  = new TypePair(CML, CDX);
+
+    @Test
+    public void testMap() {
+    	Map<TypePair, List<Converter>> map = MoleculeConverterRegistry.getDefaultConverterRegistry().getMap();
+    	Assert.assertNotNull(map);
+    	// size will change as more are added
+    	Assert.assertEquals(9, map.size());
+    }
+
+    @Test
+    public void testList() {
+    	List<Converter> converterList = MoleculeConverterRegistry.getDefaultConverterRegistry().getConverterList();
+    	Assert.assertNotNull(converterList);
+    	for (Converter converter : converterList) {
+    		System.out.println(converter);
+    	}
+    	Assert.assertEquals(10, converterList.size());
+    }
+
+    @Test
+    public void testList1() {
+    	List<Converter> converterList = MoleculeConverterRegistry.getDefaultConverterRegistry().getConverterList();
+    	boolean found = false;
+    	for (Converter converter : converterList) {
+    		if (CML2CMLLiteConverter.class.equals(converter.getClass())) {
+    			found = true;
+    			break;
+    		}
+    	}
+    	Assert.assertTrue("converter", found);
+    }
+
+    @Test
+    public void testMap1() {
+    	Map<TypePair, List<Converter>> map = MoleculeConverterRegistry.getDefaultConverterRegistry().getMap();
+    	Assert.assertTrue(map.containsKey(PAIR_OK));
+    	Assert.assertFalse(map.containsKey(PAIR_MISSING));
+    	for (TypePair typePair1 : map.keySet()) {
+    		System.out.println(typePair1);
+    	}
+    }
+
+    @Test
+    public void testFindConverter() {
+    	List<Converter> converters = MoleculeConverterRegistry.getDefaultConverterRegistry().findConverters(
+    			MDLModule.MOL_TYPE.getMimeType(), CMLCommon.CML_TYPE.getMimeType());
+    	Assert.assertNotNull("mdl", converters);
+    	for (Converter converter : converters) {
+    		System.out.println("Converter: "+converter);
+    	}
+    	Assert.assertEquals("mdl", 2, converters.size());
+    	Assert.assertEquals("mdl", "org.xmlcml.cml.converters.molecule.mdl.MDL2CMLConverter", converters.get(0).getClass().getName());
+    }
+
+    @Test
+    public void testFindConverter1() {
+    	List<Converter> converters = MoleculeConverterRegistry.getDefaultConverterRegistry().findConverters(CML, CML);
+    	Assert.assertNotNull("cml", converters);
+//    	for (Converter converter : converters) {
+//    		System.out.println(converter);
+//    	}
+    	Assert.assertEquals("cml", 4, converters.size());
+    }
+
+	@Test
+	public void testRegistryLoadsConverterList() {
+		List<Converter> list = MoleculeConverterRegistry.getDefaultConverterRegistry().getConverterList();
+		assertTrue(list.size()>0);
+	}
+
+	@Test
+	public void testFindFoo2BarConverter() {
+		List<Converter> converterList = MoleculeConverterRegistry.getDefaultConverterRegistry().findConverters("foo", "bar");
+		assertNull(converterList);
+	}
+
+	@Test
+	public void testFindTypesFromSuffix() {
+		Set<MimeType> types = MoleculeConverterRegistry.getDefaultConverterRegistry().getTypes("cml");
+		Assert.assertNotNull("get types", types);
+		Assert.assertEquals("get types", 2, types.size());
+		Assert.assertEquals("get types", "chemical/x-cml", ((MimeType)types.toArray()[0]).getMimeType());
+	}
+
+	@Test
+	public void testFindTypesFromSuffix1() {
+		Set<MimeType> types = MoleculeConverterRegistry.getDefaultConverterRegistry().getTypes("foo");
+		Assert.assertNotNull("get types", types);
+		Assert.assertEquals("types count", 1, types.size());
+		Assert.assertEquals("type", "chemical/x-foo", ((MimeType)types.toArray()[0]).getMimeType());
+	}
+
+	@Test
+	public void testFindSingleTypeFromSuffix() {
+		MimeType type = MoleculeConverterRegistry.getDefaultConverterRegistry().getSingleTypeFromSuffix("cml");
+		Assert.assertNull("get type", type);
+	}
+
+	@Test
+	public void testSingletonConverterRegistry() {
+		Assert.assertNotNull(MoleculeConverterRegistry.getDefaultConverterRegistry());
+	}
+
+	@Test
+	public void testCreateRegistryList0() {
+		ConverterRegistry converterRegistry = new ConverterRegistry(ConverterRegistry.class.getClassLoader());
+		List<Converter> converterList = converterRegistry.getConverterList();
+		Assert.assertNotNull(converterList);
+		converterRegistry.createConvertersList();
+		converterList = converterRegistry.getConverterList();
+		Assert.assertNotNull(converterList);
+	}
+
+	@Test
+	public void testCreateRegistryList() {
+		ConverterRegistry converterRegistry = new MoleculeConverterRegistry(MoleculeConverterRegistry.class.getClassLoader());
+		converterRegistry.populateAndRegister();
+		List<Converter> converterList = converterRegistry.getConverterList();
+		converterRegistry.createConvertersList();
+		converterList = converterRegistry.getConverterList();
+		// should at least contain org.xmlcml.cml.converters.cml.CML2CMLLiteConverter@76f2d004
+		Assert.assertTrue(converterList.size()>0);
+		boolean hasCmllite = false;
+		for (Converter converter : converterList) {
+			if (converter instanceof org.xmlcml.cml.converters.cml.CML2CMLLiteConverter) {
+				hasCmllite = true;
+				break;
+			}
+		}
+		Assert.assertTrue("has cmllite", hasCmllite);
+	}
+
+	@Test
+	public void testSingletonConverterRegistryList0() {
+		ConverterRegistry converterRegistry = MoleculeConverterRegistry.getDefaultConverterRegistry();
+		List<Converter> converterList = converterRegistry.getConverterList();
+		Assert.assertNotNull(converterList);
+		Assert.assertEquals("converterList", 10, converterList.size());
+	}
+
+	@Test
+	public void testSingletonConverterRegistryList() {
+		List<Converter> converterList = MoleculeConverterRegistry.getDefaultConverterRegistry().getConverterList();
+		Assert.assertNotNull(converterList);
+		Assert.assertEquals("converterList", 10, converterList.size());
+	}
+
+}

jc-molecule-registry/.classpath

-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
-	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
-	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
-	<classpathentry kind="output" path="target/classes"/>
-</classpath>

jc-molecule-registry/.project

-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>jc-molecule-registry</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.m2e.core.maven2Builder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.eclipse.m2e.core.maven2Nature</nature>
-	</natures>
-</projectDescription>

jc-molecule-registry/.settings/org.eclipse.core.resources.prefs

-#Sun Feb 19 14:13:28 GMT 2012
-eclipse.preferences.version=1
-encoding//src/main/java=UTF-8
-encoding//src/main/resources=UTF-8
-encoding//src/test/java=UTF-8
-encoding/<project>=UTF-8

jc-molecule-registry/.settings/org.eclipse.jdt.core.prefs

-#Sun Feb 19 12:41:23 GMT 2012
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.6

jc-molecule-registry/.settings/org.eclipse.m2e.core.prefs

-#Sun Feb 19 12:41:22 GMT 2012
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1

jc-molecule-registry/pom.xml

-<?xml version="1.0" encoding="UTF-8"?>
-<project
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
-	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-	<modelVersion>4.0.0</modelVersion>
-
-	<parent>
-		<groupId>org.xml-cml.jc</groupId>
-		<artifactId>jc-molecule</artifactId>
-		<version>0.3-SNAPSHOT</version>
-	</parent>
-
-	<artifactId>jc-molecule-registry</artifactId>
-	<name>jc-molecule-registry</name>
-
-	<dependencies>
-		<dependency>
-			<groupId>${jc.groupId}</groupId>
-			<artifactId>jc-molecule-all</artifactId>
-            <version>${project.version}</version>
-		</dependency>
-	</dependencies>
-</project>

jc-molecule-registry/src/main/java/org/xmlcml/cml/converters/molecule/registry/MoleculeConverterRegistry.java

-package org.xmlcml.cml.converters.molecule.registry;
-
-import org.xmlcml.cml.converters.registry.ConverterRegistry;
-
-/**
- * @author Sam Adams
- */
-public class MoleculeConverterRegistry extends ConverterRegistry {
-
-    /** create singleton registry
-     */
-    private static MoleculeConverterRegistry MOLECULE_CONVERTER_REGISTRY = null;
-    
-    public static synchronized MoleculeConverterRegistry getDefaultConverterRegistry() {
-    	if (MOLECULE_CONVERTER_REGISTRY == null) {
-    		MOLECULE_CONVERTER_REGISTRY = new MoleculeConverterRegistry(MoleculeConverterRegistry.class.getClassLoader());
-    		MOLECULE_CONVERTER_REGISTRY.populateAndRegister();
-    	}
-    	return MOLECULE_CONVERTER_REGISTRY;
-    }
-    
-    public MoleculeConverterRegistry(ClassLoader classLoader) {
-    	super(classLoader);
-    }
-
-    public MoleculeConverterRegistry(Class clazz) {
-    	super(clazz);
-    }
-
-    
-}

jc-molecule-registry/src/test/java/org/xmlcml/cml/converters/molecule/registry/MoleculeConverterRegistryTest.java

-package org.xmlcml.cml.converters.molecule.registry;
-
-import static org.junit.Assert.assertNull;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.MimeType;
-import org.xmlcml.cml.converters.cml.CML2CMLLiteConverter;
-import org.xmlcml.cml.converters.cml.CMLCommon;
-import org.xmlcml.cml.converters.registry.ConverterRegistry;
-import org.xmlcml.cml.converters.registry.TypePair;
-import org.xmlcml.cml.converters.molecule.mdl.MDLModule;
-
-//@Ignore
-public class MoleculeConverterRegistryTest {
-
-	String CML = "chemical/x-cml";
-	String CDX = "chemical/x-cdx";
-	String FOO = "chemical/x-foo";
-	TypePair PAIR_OK  = new TypePair(FOO, CML);
-	TypePair PAIR_MISSING  = new TypePair(CML, CDX);
-	
-    @Test
-    public void testMap() {
-    	Map<TypePair, List<Converter>> map = MoleculeConverterRegistry.getDefaultConverterRegistry().getMap();
-    	Assert.assertNotNull(map);
-    	// size will change as more are added
-    	Assert.assertEquals(2, map.size());
-    }
-
-    @Test
-    public void testList() {
-    	List<Converter> converterList = MoleculeConverterRegistry.getDefaultConverterRegistry().getConverterList();
-    	Assert.assertNotNull(converterList);
-    	Assert.assertEquals(2, converterList.size());
-    }
-
-    @Test
-    public void testList1() {
-    	List<Converter> converterList = MoleculeConverterRegistry.getDefaultConverterRegistry().getConverterList();
-    	boolean found = false;
-    	for (Converter converter : converterList) {
-    		if (CML2CMLLiteConverter.class.equals(converter.getClass())) {
-    			found = true;
-    			break;
-    		}
-    	}
-    	Assert.assertTrue("converter", found);
-    }
-
-    @Test
-    public void testMap1() {
-    	Map<TypePair, List<Converter>> map = MoleculeConverterRegistry.getDefaultConverterRegistry().getMap();
-    	Assert.assertTrue(map.containsKey(PAIR_OK));
-    	Assert.assertFalse(map.containsKey(PAIR_MISSING));
-    	for (TypePair typePair1 : map.keySet()) {
-    		System.out.println(typePair1);
-    	}
-    }
-
-    @Test
-    public void testFindConverter() {
-    	List<Converter> converters = MoleculeConverterRegistry.getDefaultConverterRegistry().findConverters(
-    			MDLModule.MOL_TYPE.getMimeType(), CMLCommon.CML_TYPE.getMimeType());
-    	Assert.assertNotNull("mdl", converters);
-    	for (Converter converter : converters) {
-    		System.out.println("Converter: "+converter);
-    	}
-    	Assert.assertEquals("mdl", 1, converters.size());
-    	Assert.assertEquals("mdl", "org.xmlcml.cml.converters.molecules.mdl.MDL2CMLConverter", converters.get(0).getClass().getName());
-    }
-
-    @Test
-    public void testFindConverter1() {
-    	List<Converter> converters = MoleculeConverterRegistry.getDefaultConverterRegistry().findConverters(CML, CML);
-    	Assert.assertNotNull("cml", converters);
-//    	for (Converter converter : converters) {
-//    		System.out.println(converter);
-//    	}
-    	Assert.assertEquals("cml", 1, converters.size());
-    }
-
-	@Test
-	public void testRegistryLoadsConverterList() {
-		List<Converter> list = MoleculeConverterRegistry.getDefaultConverterRegistry().getConverterList();
-		assertTrue(list.size()>0);
-	}
-
-	@Test
-	public void testFindFoo2BarConverter() {
-		List<Converter> converterList = MoleculeConverterRegistry.getDefaultConverterRegistry().findConverters("foo", "bar");
-		assertNull(converterList);
-	}
-
-	@Test
-	public void testFindTypesFromSuffix() {
-		Set<MimeType> types = MoleculeConverterRegistry.getDefaultConverterRegistry().getTypes("cml");
-		Assert.assertNotNull("get types", types);
-		Assert.assertEquals("get types", 1, types.size());
-		Assert.assertEquals("get types", "chemical/x-cml", ((MimeType)types.toArray()[0]).getMimeType());
-	}
-
-	@Test
-	public void testFindTypesFromSuffix1() {
-		Set<MimeType> types = MoleculeConverterRegistry.getDefaultConverterRegistry().getTypes("foo");
-		Assert.assertNotNull("get types", types);
-		Assert.assertEquals("types count", 1, types.size());
-		Assert.assertEquals("type", "chemical/x-foo", ((MimeType)types.toArray()[0]).getMimeType());
-	}
-
-	@Test
-	public void testFindSingleTypeFromSuffix() {
-		MimeType type = MoleculeConverterRegistry.getDefaultConverterRegistry().getSingleTypeFromSuffix("cml");
-		Assert.assertNotNull("get type", type);
-		Assert.assertEquals("get type", "chemical/x-cml", type.getMimeType());
-	}
-	
-	@Test
-	public void testSingletonConverterRegistry() {
-		Assert.assertNotNull(MoleculeConverterRegistry.getDefaultConverterRegistry());
-	}
-
-	@Test
-	public void testCreateRegistryList0() {
-		ConverterRegistry converterRegistry = new ConverterRegistry(ConverterRegistry.class.getClassLoader());
-		List<Converter> converterList = converterRegistry.getConverterList();
-		Assert.assertNotNull(converterList);
-		converterRegistry.createConvertersList();
-		converterList = converterRegistry.getConverterList();
-		Assert.assertNotNull(converterList);
-	}
-	
-	@Test
-	public void testCreateRegistryList() {
-		ConverterRegistry converterRegistry = new MoleculeConverterRegistry(MoleculeConverterRegistry.class.getClassLoader());
-		converterRegistry.populateAndRegister();
-		List<Converter> converterList = converterRegistry.getConverterList();
-		converterRegistry.createConvertersList();
-		converterList = converterRegistry.getConverterList();
-		// should at least contain org.xmlcml.cml.converters.cml.CML2CMLLiteConverter@76f2d004
-		Assert.assertTrue(converterList.size()>0);
-		boolean hasCmllite = false;
-		for (Converter converter : converterList) {
-			if (converter instanceof org.xmlcml.cml.converters.cml.CML2CMLLiteConverter) {
-				hasCmllite = true;
-				break;
-			}
-		}
-		Assert.assertTrue("has cmllite", hasCmllite);
-	}
-	
-	@Test
-	public void testSingletonConverterRegistryList0() {
-		ConverterRegistry converterRegistry = MoleculeConverterRegistry.getDefaultConverterRegistry();
-		List<Converter> converterList = converterRegistry.getConverterList();
-		Assert.assertNotNull(converterList);
-		Assert.assertEquals("converterList", 2, converterList.size());
-	}
-
-	@Test
-	public void testSingletonConverterRegistryList() {
-		List<Converter> converterList = MoleculeConverterRegistry.getDefaultConverterRegistry().getConverterList();
-		Assert.assertNotNull(converterList);
-		Assert.assertEquals("converterList", 2, converterList.size());
-	}
-
-}
         <module>jc-molecule-mdl</module>
         <module>jc-molecule-pubchem</module>
         <module>jc-molecule-all</module>
-        <module>jc-molecule-registry</module>
     </modules>
 
     <dependencies>