Author: scooter
Date: 2010-11-03 15:04:02 -0700 (Wed, 03 Nov 2010)
New Revision: 22699

Modified:
   
cytoscape/trunk/application/src/test/java/cytoscape/data/ImportHandlerTest.java
   
cytoscape/trunk/application/src/test/java/cytoscape/data/readers/XGMMLReaderTest.java
Log:
Add new test to ImportHandlerTest and fix XGMMLReaderTest so that it actually 
tests the XGMMLReader.


Modified: 
cytoscape/trunk/application/src/test/java/cytoscape/data/ImportHandlerTest.java
===================================================================
--- 
cytoscape/trunk/application/src/test/java/cytoscape/data/ImportHandlerTest.java 
    2010-11-03 21:06:19 UTC (rev 22698)
+++ 
cytoscape/trunk/application/src/test/java/cytoscape/data/ImportHandlerTest.java 
    2010-11-03 22:04:02 UTC (rev 22699)
@@ -34,6 +34,9 @@
 */
 package cytoscape.data;
 
+import cytoscape.AllTests;
+
+import cytoscape.Cytoscape;
 import cytoscape.data.ImportHandler;
 
 import cytoscape.data.readers.GraphReader;
@@ -45,12 +48,17 @@
 import junit.framework.TestCase;
 
 import java.io.*;
+import java.io.File;
 
 import java.lang.String;
 
+import java.net.URL;
+
 import java.util.*;
 
+import giny.model.RootGraph;
 
+
 /**
  * Tests Implementation of ImportHandler.
  *
@@ -62,6 +70,7 @@
        private File DUMMY_GML_FILE;
        private File DUMMY_XML_FILE;
        private File DUMMY_DOC_FILE;
+       private File TEST_XGMML_FILE;
        private GraphReader graphReader;
        private InteractionsReader DUMMY_GRAPH_READER;
        private Collection dummyCollection;
@@ -73,7 +82,10 @@
        private static String DUMMY_GRAPH_NATURE = "NETWORK";
        private static String DUMMY_NATURE = "xxxx";
        private ImportHandler importHandler;
+       private static String testDataDir;
 
+       private static final String FILE_LOCATION = 
"src/test/resources/testData";
+
        /**
         * Set things up.
         * @throws Exception All Exceptions.
@@ -89,6 +101,7 @@
                DUMMY_GML_FILE = File.createTempFile("inputGmlTest", ".gml");
                DUMMY_XML_FILE = File.createTempFile("inputXmlTest", ".xml");
                DUMMY_DOC_FILE = File.createTempFile("inputDocTest", ".doc");
+               TEST_XGMML_FILE = new File(FILE_LOCATION+"/galFiltered2.xgmml");
                DUMMY_GRAPH_READER = new 
InteractionsReader(DUMMY_SIF_FILE.toString());
        }
 
@@ -314,6 +327,27 @@
                assertFalse(exists);
        }
 
+       /**
+        * Test to make sure getReader does the right thing with URL's
+        */
+       public void testGetReaderURL() throws Exception {
+               URL url = TEST_XGMML_FILE.toURI().toURL();
+               System.out.println(url);
+               graphReader = importHandler.getReader(url);
+               assertTrue(graphReader != null);
+               RootGraph network = Cytoscape.getRootGraph();
+               network.removeNodes(network.nodesList());
+               graphReader.read();
+               System.out.println("GetReaderURL: Node count = " + 
network.getNodeCount());
+               System.out.println("GetReaderURL: Edge count = " + 
network.getEdgeCount());
+
+               assertTrue("GetReaderURL: Node count, expect 331, got " + 
network.getNodeCount(),
+                          network.getNodeCount() == 331);
+               assertTrue("GetReaderURL: Edge count, expect 362, got " + 
network.getEdgeCount(),
+               network.getEdgeCount() == 362);
+
+       }
+
        //not sure if I should test a private method 
        //technically by testing all the public methods all the 
        //private ones are indirectly tested

Modified: 
cytoscape/trunk/application/src/test/java/cytoscape/data/readers/XGMMLReaderTest.java
===================================================================
--- 
cytoscape/trunk/application/src/test/java/cytoscape/data/readers/XGMMLReaderTest.java
       2010-11-03 21:06:19 UTC (rev 22698)
+++ 
cytoscape/trunk/application/src/test/java/cytoscape/data/readers/XGMMLReaderTest.java
       2010-11-03 22:04:02 UTC (rev 22699)
@@ -51,7 +51,7 @@
  *
  */
 public class XGMMLReaderTest extends TestCase {
-       private static String testDataDir;
+       private static String testDataDir = "src/test/resources/testData";
 
        /**
         *  DOCUMENT ME!
@@ -78,7 +78,7 @@
                super(arg0);
 
                if (AllTests.runAllTests()) {
-                       testDataDir = "testData";
+                       testDataDir = "src/test/resources/testData";
                }
        }
 
@@ -98,9 +98,9 @@
        public void testXGMMLGraphRead() throws Exception {
                AllTests.standardOut("testXGMMLGraphRead");
 
-               XGMMLReader reader = new 
XGMMLReader("testData/galFiltered2.xgmml");
+               XGMMLReader reader = new 
XGMMLReader(testDataDir+"/galFiltered2.xgmml");
 
-               File testfile = new File("testData/galFiltered2.xgmml");
+               File testfile = new File(testDataDir+"/galFiltered2.xgmml");
 
                if (testfile.canRead()) {
                        System.out.println("Reading XGMML: " + 
testfile.getAbsolutePath());

-- 
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.

Reply via email to