Skip to content

Commit

Permalink
Moved ContentTypesPluginTest to cml.tests
Browse files Browse the repository at this point in the history
The tested content types are define in the net.bioclipse.cml plugin
  • Loading branch information
goglepox committed Feb 20, 2012
1 parent e52b907 commit 9e78f07
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
Expand Up @@ -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>
Expand Down
Expand Up @@ -17,7 +17,8 @@
@RunWith(value=Suite.class)
@SuiteClasses({
JavaScriptValidateCMLManagerPluginTest.class,
JavaValidateCMLManagerPluginTest.class
JavaValidateCMLManagerPluginTest.class,
ContentTypesPluginTest.class
})
public class AllValidateCMLManagerPluginTest {

Expand Down
@@ -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.