Permalink
Browse files

Moved ContentTypesPluginTest to cml.tests

The tested content types are define in the net.bioclipse.cml plugin
  • Loading branch information...
1 parent e52b907 commit 9e78f07944c3836b4aaeb9c4a99fe6ce0690c301 @goglepox goglepox committed Feb 20, 2012
View
5 features/net.bioclipse.cheminformatics.test_feature/ChemoinformaticsPluginTestSuite.launch
@@ -36,7 +36,12 @@
<setAttribute key="selected_features">
<setEntry value="net.bioclipse.cheminformatics.test_feature:default"/>
<setEntry value="net.bioclipse.chemoinformatics_feature:default"/>
+<setEntry value="net.bioclipse.core.tests_feature:default"/>
<setEntry value="net.bioclipse.core_feature:default"/>
+<setEntry value="net.bioclipse.platform_feature:default"/>
+<setEntry value="org.eclipse.equinox.p2.core.feature:default"/>
+<setEntry value="org.eclipse.equinox.p2.extras.feature:default"/>
+<setEntry value="org.eclipse.equinox.p2.rcp.feature:default"/>
<setEntry value="org.eclipse.equinox.p2.user.ui:default"/>
<setEntry value="org.eclipse.rcp:default"/>
</setAttribute>
View
3 .../net.bioclipse.cml.tests/src/net/bioclipse/cml/tests/AllValidateCMLManagerPluginTest.java
@@ -17,7 +17,8 @@
@RunWith(value=Suite.class)
@SuiteClasses({
JavaScriptValidateCMLManagerPluginTest.class,
- JavaValidateCMLManagerPluginTest.class
+ JavaValidateCMLManagerPluginTest.class,
+ ContentTypesPluginTest.class
})
public class AllValidateCMLManagerPluginTest {
View
110 plugins/net.bioclipse.cml.tests/src/net/bioclipse/cml/tests/ContentTypesPluginTest.java
@@ -0,0 +1,110 @@
+/* *****************************************************************************
+ * Copyright (c) 2008-2009 The Bioclipse Project and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ola Spjuth
+ * Jonathan Alvarsson
+ *
+ ******************************************************************************/
+package net.bioclipse.cml.tests;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import net.bioclipse.core.MockIFile;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class ContentTypesPluginTest{
+
+ @Test public void testCMLSingle2d() throws Exception{
+ URI uri = getClass().getResource("/testFiles/single2d.cml").toURI();
+ URL url=FileLocator.toFileURL(uri.toURL());
+ String path=url.getFile();
+ IFile file=new MockIFile(path);
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ InputStream stream = file.getContents();
+ IContentType contentType = contentTypeManager.findContentTypeFor(stream, "single2d.cml");
+ stream.close();
+ Assert.assertEquals( "net.bioclipse.contenttypes.cml.singleMolecule2d",contentType.getId() );
+ }
+ @Test public void testCMLSingle3d() throws Exception{
+ URI uri = getClass().getResource("/testFiles/single3d.cml").toURI();
+ URL url=FileLocator.toFileURL(uri.toURL());
+ String path=url.getFile();
+ IFile file=new MockIFile(path);
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ InputStream stream = file.getContents();
+ IContentType contentType = contentTypeManager.findContentTypeFor(stream, "single3d.cml");
+ stream.close();
+ Assert.assertEquals( "net.bioclipse.contenttypes.cml.singleMolecule3d",contentType.getId() );
+ }
+ @Test public void testCMLSingle5d() throws Exception{
+ URI uri = getClass().getResource("/testFiles/single5d.cml").toURI();
+ URL url=FileLocator.toFileURL(uri.toURL());
+ String path=url.getFile();
+ IFile file=new MockIFile(path);
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ InputStream stream = file.getContents();
+ IContentType contentType = contentTypeManager.findContentTypeFor(stream, "single5d.cml");
+ stream.close();
+ Assert.assertEquals( "net.bioclipse.contenttypes.cml.singleMolecule5d",contentType.getId() );
+ }
+ @Test public void testCMLMultipleSingle2d() throws Exception{
+ URI uri = getClass().getResource("/testFiles/multiple2d.cml").toURI();
+ URL url=FileLocator.toFileURL(uri.toURL());
+ String path=url.getFile();
+ IFile file=new MockIFile(path);
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ InputStream stream = file.getContents();
+ IContentType contentType = contentTypeManager.findContentTypeFor(stream, "multiple2d.cml");
+ stream.close();
+ Assert.assertEquals( "net.bioclipse.contenttypes.cml.multipleMolecule2d",contentType.getId() );
+ }
+ @Test public void testCMLMultipleSingle3d() throws Exception{
+ URI uri = getClass().getResource("/testFiles/multiple3d.cml").toURI();
+ URL url=FileLocator.toFileURL(uri.toURL());
+ String path=url.getFile();
+ IFile file=new MockIFile(path);
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ InputStream stream = file.getContents();
+ IContentType contentType = contentTypeManager.findContentTypeFor(stream, "multiple3d.cml");
+ stream.close();
+ Assert.assertEquals( "net.bioclipse.contenttypes.cml.multipleMolecule3d",contentType.getId() );
+ }
+ @Test public void testCMLMultipleSingle5d() throws Exception{
+ URI uri = getClass().getResource("/testFiles/multiple5d.cml").toURI();
+ URL url=FileLocator.toFileURL(uri.toURL());
+ String path=url.getFile();
+ IFile file=new MockIFile(path);
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ InputStream stream = file.getContents();
+ IContentType contentType = contentTypeManager.findContentTypeFor(stream, "multiple5d.cml");
+ stream.close();
+ Assert.assertEquals( "net.bioclipse.contenttypes.cml.multipleMolecule5d",contentType.getId() );
+ }
+
+ @Test public void testBug708() throws Exception{
+ URI uri = getClass().getResource("/testFiles/bug708.cml").toURI();
+ URL url=FileLocator.toFileURL(uri.toURL());
+ String path=url.getFile();
+ IFile file=new MockIFile(path);
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ InputStream stream = file.getContents();
+ IContentType contentType = contentTypeManager.findContentTypeFor(stream, "single2d.cml");
+ stream.close();
+ Assert.assertEquals( "net.bioclipse.contenttypes.cml.singleMolecule5d",contentType.getId() );
+ }
+}

0 comments on commit 9e78f07

Please sign in to comment.