Commits

petermr  committed 2ac4c6c

more tidying

  • Participants
  • Parent commits dd21dca

Comments (0)

Files changed (18)

File jc-molecule-all/pom.xml

     <packaging>${all.packaging}</packaging>
 	
     <dependencies>
+		<dependency>
+			<groupId>${jc.groupId}</groupId>
+			<artifactId>jc-top-core</artifactId>
+			<scope>compile</scope>
+            <version>${project.version}</version>
+		</dependency>
         <dependency>
             <groupId>${jc.groupId}</groupId>
             <artifactId>jc-molecule-core</artifactId>
         </dependency>
         
 		<dependency>
+			<groupId>${jc.groupId}</groupId>
+			<artifactId>jc-top-core</artifactId>
+            <version>${project.version}</version>
+		</dependency>
+		
+		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
 			<scope>test</scope>

File 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);
-    }
-
-
-}

File 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());
-	}
-
-}

File jc-molecule-cml/src/main/java/org/xmlcml/cml/converters/molecule/CMLModule.java

 import java.util.ArrayList;
 import java.util.List;
 
+import org.xmlcml.cml.converters.AbstractConverterModule;
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.MimeType;
 import org.xmlcml.cml.converters.MimeType.ObjectType;
 import org.xmlcml.cml.converters.molecule.cml.CML2CMLConverter;
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
 
 /**
  * @author Sam Adams

File jc-molecule-core/src/main/java/org/xmlcml/cml/converters/molecule/core/MoleculeModule.java

 package org.xmlcml.cml.converters.molecule.core;
 
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
+import org.xmlcml.cml.converters.AbstractConverterModule;
 
 /**
  * @author pm286
     	super();
     }
 
+
 }

File jc-molecule-mdl/src/main/java/org/xmlcml/cml/converters/molecule/mdl/MDLModule.java

 import java.util.ArrayList;
 import java.util.List;
 
+import org.xmlcml.cml.converters.AbstractConverterModule;
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.MimeType;
 import org.xmlcml.cml.converters.MimeType.ObjectType;
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
 
 /**
  * @author Sam Adams

File jc-molecule-pubchem/src/main/java/org/xmlcml/cml/converters/molecule/pubchem/PubchemModule.java

 import java.util.ArrayList;
 import java.util.List;
 
+import org.xmlcml.cml.converters.AbstractConverterModule;
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.MimeType;
 import org.xmlcml.cml.converters.MimeType.ObjectType;
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
 
 /**
  * @author Sam Adams

File jc-molecule-test/.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 excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<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>

File jc-molecule-test/.project

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>jc-molecule-xyz</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>

File jc-molecule-test/.settings/org.eclipse.core.resources.prefs

+#Wed Feb 15 21:55:40 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//src/test/resources=UTF-8
+encoding/<project>=UTF-8

File jc-molecule-test/.settings/org.eclipse.jdt.core.prefs

+#Sat Feb 11 21:06:58 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

File jc-molecule-test/.settings/org.eclipse.m2e.core.prefs

+#Wed Jan 04 18:20:05 GMT 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

File jc-molecule-test/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-test</artifactId>
+	<name>jc-molecule-test</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>${jc.groupId}</groupId>
+			<artifactId>jc-molecule-all</artifactId>
+            		<version>${project.version}</version>
+		</dependency>
+	</dependencies>
+</project>

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

+package org.xmlcml.cml.converters.molecule.registry;
+
+// Mavens needs something here/
+public class MoleculeConverterRegistry {
+	public MoleculeConverterRegistry() {
+		
+	}
+}

File jc-molecule-test/src/main/resources/META-INF/jumbo-converters

+org.xmlcml.cml.converters.molecule.xyz.XYZModule

File jc-molecule-test/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.TypePair;
+import org.xmlcml.cml.converters.cml.CML2CMLLiteConverter;
+import org.xmlcml.cml.converters.cml.CMLCommon;
+import org.xmlcml.cml.converters.molecule.mdl.MDLModule;
+import org.xmlcml.cml.converters.registry.ConverterRegistry;
+
+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);
+	int MAP_SIZE = 9;
+	int CONVERTER_SIZE = 12;
+
+    @Test
+    public void testMap() {
+    	Map<TypePair, List<Converter>> map = ConverterRegistry.getDefaultConverterRegistry().getMap();
+    	Assert.assertNotNull(map);
+    	// size will change as more are added
+    	Assert.assertEquals(MAP_SIZE, map.size());
+    }
+
+    @Test
+    public void testList() {
+    	List<Converter> converterList = ConverterRegistry.getDefaultConverterRegistry().getConverterList();
+    	Assert.assertNotNull(converterList);
+    	for (Converter converter : converterList) {
+    		System.out.println(converter);
+    	}
+    	Assert.assertEquals(CONVERTER_SIZE, converterList.size());
+    }
+
+    @Test
+    public void testList1() {
+    	List<Converter> converterList = ConverterRegistry.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 = ConverterRegistry.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 = ConverterRegistry.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.molecule.mdl.MDL2CMLConverter", converters.get(0).getClass().getName());
+    }
+
+    @Test
+    public void testFindConverter1() {
+    	List<Converter> converters = ConverterRegistry.getDefaultConverterRegistry().findConverters(CML, CML);
+    	Assert.assertNotNull("cml", converters);
+//    	for (Converter converter : converters) {
+//    		System.out.println(converter);
+//    	}
+    	Assert.assertEquals("cml", 2, converters.size());
+    }
+
+	@Test
+	public void testRegistryLoadsConverterList() {
+		List<Converter> list = ConverterRegistry.getDefaultConverterRegistry().getConverterList();
+		assertTrue(list.size()>0);
+	}
+
+	@Test
+	public void testFindFoo2BarConverter() {
+		List<Converter> converterList = ConverterRegistry.getDefaultConverterRegistry().findConverters("foo", "bar");
+		assertNull(converterList);
+	}
+
+	@Test
+	public void testFindTypesFromSuffix() {
+		Set<MimeType> types = ConverterRegistry.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 = ConverterRegistry.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 = ConverterRegistry.getDefaultConverterRegistry().getSingleTypeFromSuffix("cml");
+		Assert.assertNull("get type", type);
+	}
+
+	@Test
+	public void testSingletonConverterRegistry() {
+		Assert.assertNotNull(ConverterRegistry.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 ConverterRegistry(ConverterRegistry.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 = hasConverter(converterList, "org.xmlcml.cml.converters.cml.CML2CMLLiteConverter");
+		Assert.assertTrue("has cmllite", hasCmllite);
+	}
+
+	private boolean hasConverter(List<Converter> converterList, String className) {
+		for (Converter converter : converterList) {
+			if (converter.getClass().getName().equals(className)) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	@Test
+	public void testSingletonConverterRegistryList0() {
+		ConverterRegistry converterRegistry = ConverterRegistry.getDefaultConverterRegistry();
+		List<Converter> converterList = converterRegistry.getConverterList();
+		Assert.assertNotNull(converterList);
+		Assert.assertEquals("converterList", CONVERTER_SIZE, converterList.size());
+	}
+
+}

File jc-molecule-xyz/src/main/java/org/xmlcml/cml/converters/molecule/xyz/XYZModule.java

 import java.util.ArrayList;
 import java.util.List;
 
+import org.xmlcml.cml.converters.AbstractConverterModule;
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.MimeType;
 import org.xmlcml.cml.converters.MimeType.ObjectType;
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
 
 /**
  * @author Sam Adams
         <module>jc-molecule-mdl</module>
         <module>jc-molecule-pubchem</module>
         <module>jc-molecule-all</module>
+        <module>jc-molecule-test</module>
     </modules>
 
     <dependencies>