Author: mes
Date: 2010-02-09 12:14:15 -0800 (Tue, 09 Feb 2010)
New Revision: 19263
Modified:
coreplugins/trunk/TableImport/build.xml
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/reader/GeneAssociationReaderTest.java
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/DefaultAttributeTableReaderTest.java
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/ExcelAttributeSheetReaderTest.java
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/ExcelNetworkSheetReaderTest.java
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/NetworkTableReaderTest.java
Log:
updated unit tests to run from different directory
Modified: coreplugins/trunk/TableImport/build.xml
===================================================================
--- coreplugins/trunk/TableImport/build.xml 2010-02-09 19:38:35 UTC (rev
19262)
+++ coreplugins/trunk/TableImport/build.xml 2010-02-09 20:14:15 UTC (rev
19263)
@@ -166,7 +166,7 @@
includes="**/*" />
<jar destfile="TableImportTests.jar" >
<fileset dir="${tableImport.testclasses.dir}"
includes="**" />
- <fileset dir="${tableImport.root.dir}/testData"
includes="resources/**" />
+ <fileset dir="${tableImport.root.dir}/testData"
includes="**" />
</jar>
</target>
Modified:
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/reader/GeneAssociationReaderTest.java
===================================================================
---
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/reader/GeneAssociationReaderTest.java
2010-02-09 19:38:35 UTC (rev 19262)
+++
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/reader/GeneAssociationReaderTest.java
2010-02-09 20:14:15 UTC (rev 19263)
@@ -68,9 +68,9 @@
*
*/
public class GeneAssociationReaderTest extends TestCase {
- private static final String GO_SLIM =
"testData/annotation/goslim_generic.obo";
- private static final String GAL_NETWORK = "testData/galFiltered.sif";
- private static final String GENE_ASSOCIATION =
"testData/annotation/gene_association.sgd";
+ private static final String GO_SLIM = "/annotation/goslim_generic.obo";
+ private static final String GAL_NETWORK = "/galFiltered.sif";
+ private static final String GENE_ASSOCIATION =
"/annotation/gene_association.sgd";
private static final String TAXON_FILE = "/resources/tax_report.txt";
private CyNetwork gal;
@@ -78,7 +78,7 @@
protected void setUp() throws Exception {
super.setUp();
- gal = Cytoscape.createNetworkFromFile(GAL_NETWORK);
+ gal =
Cytoscape.createNetworkFromURL(getClass().getResource(GAL_NETWORK),true);
Cytoscape.buildOntologyServer();
}
@@ -104,18 +104,15 @@
System.out.println("Ontology Name used for GA reader =
" + ontologyName);
}
- File sampleSourceFile = new File(GENE_ASSOCIATION);
- assertTrue(sampleSourceFile.canRead());
-
GeneOntology go = new GeneOntology("go1", "testCur",
"testDesc", null);
Cytoscape.getOntologyServer().addOntology(go);
- File goSlim = new File(GO_SLIM);
- Cytoscape.getOntologyServer()
- .addOntology(goSlim.toURI().toURL(), OntologyType.GO,
"GO Slim Test", "Test");
+ Cytoscape.getOntologyServer().addOntology(
+ getClass().getResource(GO_SLIM), OntologyType.GO, "GO
Slim Test", "Test");
GeneAssociationReader gar = new GeneAssociationReader("GO Slim
Test",
-
URLUtil.getInputStream(sampleSourceFile.toURI().toURL()),
+ URLUtil.getInputStream(
+
getClass().getResource(GENE_ASSOCIATION)),
"ID", false, 2, true, TAXON_FILE);
gar.readTable();
@@ -126,8 +123,6 @@
nodeAttr.deleteAttribute(attrName);
}
- /*
- * Delete all attributes
- */
+ // TODO add some actual tests!!
}
}
Modified:
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/DefaultAttributeTableReaderTest.java
===================================================================
---
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/DefaultAttributeTableReaderTest.java
2010-02-09 19:38:35 UTC (rev 19262)
+++
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/DefaultAttributeTableReaderTest.java
2010-02-09 20:14:15 UTC (rev 19263)
@@ -63,10 +63,10 @@
/*
* Toy example created from galFiltered.sif and its attribute files.
*/
- private static final String DATA_FILE =
"testData/annotation/galSubnetworkAnnotation2.txt";
- private static final String NETWORK_FILE = "testData/galSubnetwork.sif";
- private static final String DATA_FILE2 =
"testData/annotation/annotationSampleForYeast.txt";
- private static final String NETWORK_FILE2 = "testData/galFiltered.sif";
+ private static final String DATA_FILE =
"/annotation/galSubnetworkAnnotation2.txt";
+ private static final String NETWORK_FILE = "/galSubnetwork.sif";
+ private static final String DATA_FILE2 =
"/annotation/annotationSampleForYeast.txt";
+ private static final String NETWORK_FILE2 = "/galFiltered.sif";
protected void setUp() throws Exception {
super.setUp();
@@ -83,17 +83,10 @@
* @throws Exception DOCUMENT ME!
*/
public void testReadTable() throws Exception {
- File network = new File(NETWORK_FILE);
- File galNetwork = new File(NETWORK_FILE2);
-
//
- CyNetwork net =
Cytoscape.createNetworkFromFile(network.getAbsolutePath());
- File source = new File(DATA_FILE);
+ CyNetwork net =
Cytoscape.createNetworkFromURL(getClass().getResource(NETWORK_FILE),true);
+ CyNetwork galNet =
Cytoscape.createNetworkFromURL(getClass().getResource(NETWORK_FILE2),true);
- CyNetwork galNet =
Cytoscape.createNetworkFromFile(galNetwork.getAbsolutePath());
-
- File galSource = new File(DATA_FILE2);
-
/*
* Test1
*/
@@ -124,7 +117,7 @@
0, "ID", aliasList,
galAttrName,
galAttrTypes, null, null);
- tableReader = new
DefaultAttributeTableReader(source.toURI().toURL(), mapping, 0, null);
+ tableReader = new
DefaultAttributeTableReader(getClass().getResource(DATA_FILE), mapping, 0,
null);
tableReader.readTable();
assertEquals("ribosomal protein S28A (S33A) (YS27)",
@@ -147,7 +140,7 @@
String[] cols = { "Object Name in SGD", "key", "alias", "Taxon
ID" };
- tableReader = new
DefaultAttributeTableReader(galSource.toURI().toURL(),
+ tableReader = new
DefaultAttributeTableReader(getClass().getResource(DATA_FILE2),
TextTableReader.ObjectType.NODE, delimiters,
PIPE.toString(),
1, "ID", aliases, cols,
null, null, 0);
Modified:
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/ExcelAttributeSheetReaderTest.java
===================================================================
---
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/ExcelAttributeSheetReaderTest.java
2010-02-09 19:38:35 UTC (rev 19262)
+++
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/ExcelAttributeSheetReaderTest.java
2010-02-09 20:14:15 UTC (rev 19263)
@@ -64,8 +64,8 @@
*
*/
public class ExcelAttributeSheetReaderTest extends TestCase {
- private static final String WORKBOOK1 =
"testData/annotation/galSubnetworkAnnotation3.xls";
- private static final String NETWORK_FILE = "testData/galSubnetwork.sif";
+ private static final String WORKBOOK1 =
"/annotation/galSubnetworkAnnotation3.xls";
+ private static final String NETWORK_FILE = "/galSubnetwork.sif";
protected void setUp() throws Exception {
super.setUp();
@@ -85,8 +85,7 @@
/*
* Load test network
*/
- File network = new File(NETWORK_FILE);
- CyNetwork net =
Cytoscape.createNetworkFromFile(network.getAbsolutePath());
+ CyNetwork net =
Cytoscape.createNetworkFromURL(getClass().getResource(NETWORK_FILE),true);
/*
* Single Sheet Test
@@ -94,7 +93,7 @@
InputStream is = null;
POIFSFileSystem excelIn;
try {
- is = new FileInputStream(WORKBOOK1);
+ is = getClass().getResource(WORKBOOK1).openStream();
excelIn = new POIFSFileSystem(is);
}
finally {
Modified:
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/ExcelNetworkSheetReaderTest.java
===================================================================
---
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/ExcelNetworkSheetReaderTest.java
2010-02-09 19:38:35 UTC (rev 19262)
+++
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/ExcelNetworkSheetReaderTest.java
2010-02-09 20:14:15 UTC (rev 19263)
@@ -70,7 +70,7 @@
*
*/
public class ExcelNetworkSheetReaderTest extends TestCase {
- private static final String NETWORK_FILE = "testData/galFiltered.xls";
+ private static final String NETWORK_FILE = "/galFiltered.xls";
private NetworkTableReader reader;
protected void setUp() throws Exception {
@@ -88,13 +88,12 @@
* @throws Exception DOCUMENT ME!
*/
public void testReadTable() throws Exception {
- File network = new File(NETWORK_FILE);
InputStream is =null;
POIFSFileSystem excelIn;
try {
- is = new FileInputStream(network);
+ is = getClass().getResource(NETWORK_FILE).openStream();
excelIn = new POIFSFileSystem(is);
}
finally {
@@ -151,13 +150,13 @@
}
public void testReadTableWithEmptyRows() throws Exception {
- File network = new File("testData/empty_attr_row.xls");
+ String network = "/empty_attr_row.xls";
InputStream is = null;
POIFSFileSystem excelIn;
try {
- is = new FileInputStream(network);
+ is = getClass().getResource(network).openStream();
excelIn = new POIFSFileSystem(is);
}
finally {
Modified:
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/NetworkTableReaderTest.java
===================================================================
---
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/NetworkTableReaderTest.java
2010-02-09 19:38:35 UTC (rev 19262)
+++
coreplugins/trunk/TableImport/tests/edu/ucsd/bioeng/coreplugin/tableImport/tests/NetworkTableReaderTest.java
2010-02-09 20:14:15 UTC (rev 19263)
@@ -68,7 +68,7 @@
/*
* Test file: galFiltered.sif + some edge attributes.
*/
- private static final String TEST_TABLE = "testData/galFiltered.txt";
+ private static final String TEST_TABLE = "/galFiltered.txt";
protected void setUp() throws Exception {
super.setUp();
@@ -85,7 +85,6 @@
* @throws Exception DOCUMENT ME!
*/
public void testReadTable() throws Exception {
- File network = new File(TEST_TABLE);
List<String> delimiters = new ArrayList<String>();
delimiters.add(TextFileDelimiters.TAB.toString());
@@ -107,7 +106,7 @@
null, null, 0, 1,
2, null);
- reader = new NetworkTableReader(network.getName(),
network.toURI().toURL(), mapping, 0, null);
+ reader = new NetworkTableReader("test name",
getClass().getResource(TEST_TABLE), mapping, 0, null);
CyNetwork net = Cytoscape.createNetwork(reader, false, null);
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.