Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved ContentTypesPluginTest to cml.tests
The tested content types are define in the net.bioclipse.cml plugin
- Loading branch information
Showing
3 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
plugins/net.bioclipse.cml.tests/src/net/bioclipse/cml/tests/ContentTypesPluginTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() ); | ||
} | ||
} |