Author: noelr
Date: 2009-07-09 06:53:38 -0700 (Thu, 09 Jul 2009)
New Revision: 17280

Added:
   cytoscape/trunk/testData/XGMMLWriterTestFile01a.xgmml
   cytoscape/trunk/testData/XGMMLWriterTestFile01b.xgmml
   cytoscape/trunk/testData/XGMMLWriterTestFile02a.xgmml
   cytoscape/trunk/testData/XGMMLWriterTestFile02b.xgmml
   cytoscape/trunk/testData/XGMMLWriterTestFile02c.xgmml
   cytoscape/trunk/tests/cytoscape/data/writers/XGMMLWriterTest.java
Modified:
   cytoscape/trunk/src/cytoscape/data/writers/XGMMLWriter.java
Log:
Fixes, tests and data for bugs 1938 and 2020

Modified: cytoscape/trunk/src/cytoscape/data/writers/XGMMLWriter.java
===================================================================
--- cytoscape/trunk/src/cytoscape/data/writers/XGMMLWriter.java 2009-07-09 
13:32:12 UTC (rev 17279)
+++ cytoscape/trunk/src/cytoscape/data/writers/XGMMLWriter.java 2009-07-09 
13:53:38 UTC (rev 17280)
@@ -167,7 +167,8 @@
  */
 public class XGMMLWriter {
        // XML preamble information
-       private static final String XML_STRING = "<?xml version=\"1.0\" 
encoding=\"UTF-8\" standalone=\"yes\"?>";
+    public static final String ENCODING = "UTF-8";
+       private static final String XML_STRING = "<?xml version=\"1.0\" 
encoding=\"" + ENCODING + "\" standalone=\"yes\"?>";
 
        private static final String[] NAMESPACES = {
                "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"";,
@@ -213,6 +214,11 @@
         */
        public static final String GRAPH_VIEW_CENTER_Y = "GRAPH_VIEW_CENTER_Y";
 
+       /**
+        *
+        */
+    public static final String ENCODE_PROPERTY = 
"cytoscape.encode.xgmml.attributes";
+
        private CyAttributes nodeAttributes;
        private CyAttributes edgeAttributes;
        private CyAttributes networkAttributes;
@@ -229,7 +235,9 @@
        private String indentString = "";
        private Writer writer = null;
 
-       /**
+    private boolean doFullEncoding;
+
+    /**
         * Constructor.<br>
         * Initialize data objects to be saved in XGMML file.<br>
         *
@@ -258,6 +266,8 @@
                // Create our indent string (480 blanks);
                for (int i = 0; i < 20; i++) 
                        indentString += "                        ";
+
+        doFullEncoding = Boolean.valueOf(System.getProperty(ENCODE_PROPERTY, 
"true"));
        }
 
        /**
@@ -471,8 +481,10 @@
                        depth--; writeElement("</att>\n");
                }
 
-               // Output the node graphics if we have a view
-               writeNodeGraphics(node, 
(NodeView)networkView.getNodeView(node));
+        if (networkView != null) {
+            // Output the node graphics if we have a view
+            writeNodeGraphics(node, (NodeView)networkView.getNodeView(node));
+        }
 
                depth--;
                writeElement("</node>\n");
@@ -657,8 +669,10 @@
                                writeAttribute(curEdge.getIdentifier(), 
edgeAttributes, edgeAttNames[att]);
                }
 
-               // Write the edge graphics
-               writeEdgeGraphics(curEdge, 
(EdgeView)networkView.getEdgeView(curEdge));
+        if (networkView != null) {
+            // Write the edge graphics
+            writeEdgeGraphics(curEdge, 
(EdgeView)networkView.getEdgeView(curEdge));
+        }
 
                depth--;
                writeElement("</edge>\n");
@@ -1153,25 +1167,60 @@
         * @return the quoted string
         */
        private String quote(String str) {
-               // Find and replace any "magic" characters
-               if (str.contains("&")) {
-                       str = str.replaceAll("&", "&amp;");
-               }
-               if (str.contains("\"")) {
-                       str = str.replaceAll("\"", "&quot;");
-               }
-               if (str.contains("'")) {
-                       str = str.replaceAll("\'", "&apos;");
-               }
-               if (str.contains("<")) {
-                       str = str.replaceAll("<", "&lt;");
-               }
-               if (str.contains(">")) {
-                       str = str.replaceAll(">", "&gt;");
-               }
-               return "\""+str+"\"";
+               // Find and replace any "magic", control, non-printable etc. 
characters
+        // For maximum safety, everything other than printable ASCII (0x20 
thru 0x7E) is converted into a character entity
+        
+        StringBuilder sb;
+        
+        sb = new StringBuilder(str.length());
+        sb.append('"');
+        for (int i = 0; i < str.length(); i++) {
+            char c;
+
+            c = str.charAt(i);
+            if ((c < ' ') || (c > '~'))
+            {
+                if (doFullEncoding) {
+                    sb.append("&#");
+                    sb.append(Integer.toHexString((int)c));
+                    sb.append(";");
+                }
+                else {
+                    sb.append(c);
+                }
+            }
+            else if (c == '"') {
+                sb.append("&quot;");
+            }
+            else if (c == '\'') {
+                sb.append("&apos;");
+            }
+            else if (c == '&') {
+                sb.append("&amp;");
+            }
+            else if (c == '<') {
+                sb.append("&lt;");
+            }
+            else if (c == '>') {
+                sb.append("&gt;");
+            }
+            else {
+                sb.append(c);
+            }
+        }
+        sb.append('"');
+
+               return sb.toString();
        }
 
+    public boolean isDoFullEncoding() {
+        return doFullEncoding;
+    }
+
+    public void setDoFullEncoding(boolean doFullEnc) {
+        doFullEncoding = doFullEnc;
+    }
+
        /**
         * Determines if object has key in multihashmap
         *

Added: cytoscape/trunk/testData/XGMMLWriterTestFile01a.xgmml
===================================================================
--- cytoscape/trunk/testData/XGMMLWriterTestFile01a.xgmml                       
        (rev 0)
+++ cytoscape/trunk/testData/XGMMLWriterTestFile01a.xgmml       2009-07-09 
13:53:38 UTC (rev 17280)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<graph label="Network 0" xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 
xmlns:cy="http://www.cytoscape.org"; xmlns="http://www.cs.rpi.edu/XGMML";  
directed="1">
+  <att name="documentVersion" value="1.1"/>
+  <att name="networkMetadata">
+    <rdf:RDF>
+      <rdf:Description rdf:about="http://www.cytoscape.org/";>
+        <dc:type>Protein-Protein Interaction</dc:type>
+        <dc:description>N/A</dc:description>
+        <dc:identifier>N/A</dc:identifier>
+        <dc:date>2009-06-15 16:45:41</dc:date>
+        <dc:title>Network 0</dc:title>
+        <dc:source>http://www.cytoscape.org/</dc:source>
+        <dc:format>Cytoscape-XGMML</dc:format>
+      </rdf:Description>
+    </rdf:RDF>
+  </att>
+  <att type="string" name="backgroundColor" value="#ccccff"/>
+  <att type="real" name="GRAPH_VIEW_ZOOM" value="1.0"/>
+  <att type="real" name="GRAPH_VIEW_CENTER_X" value="0.0"/>
+  <att type="real" name="GRAPH_VIEW_CENTER_Y" value="0.0"/>
+  <node label="node1" id="-2">
+    <att type="string" name="testString" value="This is a test string for 
node1"/>
+    <att type="string" name="NODE_TYPE" value="DefaultNode"/>
+    <att type="string" name="canonicalName" value="node1"/>
+    <graphics type="ELLIPSE" h="40.0" w="40.0" x="63.0" y="-46.0" 
fill="#ff9999" width="1" outline="#666666" cy:nodeTransparency="1.0" 
cy:nodeLabelFont="SansSerif.bold-0-12" cy:borderLineType="solid"/>
+  </node>
+  <node label="node0" id="-1">
+    <att type="string" name="testString" value="This is a test string for 
node0"/>
+    <att type="string" name="NODE_TYPE" value="DefaultNode"/>
+    <att type="string" name="canonicalName" value="node0"/>
+    <graphics type="ELLIPSE" h="40.0" w="40.0" x="-122.0" y="-48.0" 
fill="#ff9999" width="1" outline="#666666" cy:nodeTransparency="1.0" 
cy:nodeLabelFont="SansSerif.bold-0-12" cy:borderLineType="solid"/>
+  </node>
+  <edge label="node0 (DirectedEdge) node1" source="-1" target="-2">
+    <att type="string" name="EDGE_TYPE" value="DirectedEdge"/>
+    <att type="string" name="testString" value="This is a test string for the 
edge"/>
+    <att type="string" name="interaction" value="DirectedEdge"/>
+    <att type="string" name="canonicalName" value="node0 (DirectedEdge) 
node1"/>
+    <graphics width="1" fill="#0000ff" cy:sourceArrow="0" cy:targetArrow="0" 
cy:sourceArrowColor="#000000" cy:targetArrowColor="#000000" 
cy:edgeLabelFont="Default-0-10" cy:edgeLineType="SOLID" 
cy:curved="STRAIGHT_LINES"/>
+  </edge>
+</graph>

Added: cytoscape/trunk/testData/XGMMLWriterTestFile01b.xgmml
===================================================================
--- cytoscape/trunk/testData/XGMMLWriterTestFile01b.xgmml                       
        (rev 0)
+++ cytoscape/trunk/testData/XGMMLWriterTestFile01b.xgmml       2009-07-09 
13:53:38 UTC (rev 17280)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<graph label="Network 0" xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 
xmlns:cy="http://www.cytoscape.org"; xmlns="http://www.cs.rpi.edu/XGMML";  
directed="1">
+  <att name="documentVersion" value="1.1"/>
+  <att name="networkMetadata">
+    <rdf:RDF>
+      <rdf:Description rdf:about="http://www.cytoscape.org/";>
+        <dc:type>Protein-Protein Interaction</dc:type>
+        <dc:description>N/A</dc:description>
+        <dc:identifier>N/A</dc:identifier>
+        <dc:date>2009-06-15 16:45:41</dc:date>
+        <dc:title>Network 0</dc:title>
+        <dc:source>http://www.cytoscape.org/</dc:source>
+        <dc:format>Cytoscape-XGMML</dc:format>
+      </rdf:Description>
+    </rdf:RDF>
+  </att>
+  <node label="node0" id="-2">
+    <att type="string" name="NODE_TYPE" value="DefaultNode"/>
+    <att type="string" name="testString" value="This is a test string for 
node0"/>
+    <att type="string" name="canonicalName" value="node0"/>
+  </node>
+  <node label="node1" id="-1">
+    <att type="string" name="NODE_TYPE" value="DefaultNode"/>
+    <att type="string" name="testString" value="This is a test string for 
node1"/>
+    <att type="string" name="canonicalName" value="node1"/>
+  </node>
+  <edge label="node0 (DirectedEdge) node1" source="-2" target="-1">
+    <att type="string" name="EDGE_TYPE" value="DirectedEdge"/>
+    <att type="string" name="testString" value="This is a test string for the 
edge"/>
+    <att type="string" name="interaction" value="DirectedEdge"/>
+    <att type="string" name="canonicalName" value="node0 (DirectedEdge) 
node1"/>
+  </edge>
+</graph>

Added: cytoscape/trunk/testData/XGMMLWriterTestFile02a.xgmml
===================================================================
--- cytoscape/trunk/testData/XGMMLWriterTestFile02a.xgmml                       
        (rev 0)
+++ cytoscape/trunk/testData/XGMMLWriterTestFile02a.xgmml       2009-07-09 
13:53:38 UTC (rev 17280)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<graph label="Network 0" xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 
xmlns:cy="http://www.cytoscape.org"; xmlns="http://www.cs.rpi.edu/XGMML";  
directed="1">
+  <att name="documentVersion" value="1.1"/>
+  <att name="networkMetadata">
+    <rdf:RDF>
+      <rdf:Description rdf:about="http://www.cytoscape.org/";>
+        <dc:type>Protein-Protein Interaction</dc:type>
+        <dc:description>N/A</dc:description>
+        <dc:identifier>N/A</dc:identifier>
+        <dc:date>2009-06-15 16:45:41</dc:date>
+        <dc:title>Network 0</dc:title>
+        <dc:source>http://www.cytoscape.org/</dc:source>
+        <dc:format>Cytoscape-XGMML</dc:format>
+      </rdf:Description>
+    </rdf:RDF>
+  </att>
+  <node label="node0" id="-2">
+    <att type="string" name="NODE_TYPE" value="DefaultNode"/>
+    <att type="string" name="testString" value="This is a test string 
for\tnode0\n"/>
+    <att type="string" name="canonicalName" value="node0"/>
+  </node>
+</graph>

Added: cytoscape/trunk/testData/XGMMLWriterTestFile02b.xgmml
===================================================================
--- cytoscape/trunk/testData/XGMMLWriterTestFile02b.xgmml                       
        (rev 0)
+++ cytoscape/trunk/testData/XGMMLWriterTestFile02b.xgmml       2009-07-09 
13:53:38 UTC (rev 17280)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<graph label="Network 0" xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 
xmlns:cy="http://www.cytoscape.org"; xmlns="http://www.cs.rpi.edu/XGMML";  
directed="1">
+  <att name="documentVersion" value="1.1"/>
+  <att name="networkMetadata">
+    <rdf:RDF>
+      <rdf:Description rdf:about="http://www.cytoscape.org/";>
+        <dc:type>Protein-Protein Interaction</dc:type>
+        <dc:description>N/A</dc:description>
+        <dc:identifier>N/A</dc:identifier>
+        <dc:date>2009-06-15 16:45:41</dc:date>
+        <dc:title>Network 0</dc:title>
+        <dc:source>http://www.cytoscape.org/</dc:source>
+        <dc:format>Cytoscape-XGMML</dc:format>
+      </rdf:Description>
+    </rdf:RDF>
+  </att>
+  <node label="node0" id="-1">
+    <att type="string" name="NODE_TYPE" value="DefaultNode"/>
+    <att type="string" name="testString" value="This is a test string 
for&#x9;node0&#xA;"/>
+    <att type="string" name="canonicalName" value="node0"/>
+  </node>
+</graph>

Added: cytoscape/trunk/testData/XGMMLWriterTestFile02c.xgmml
===================================================================
--- cytoscape/trunk/testData/XGMMLWriterTestFile02c.xgmml                       
        (rev 0)
+++ cytoscape/trunk/testData/XGMMLWriterTestFile02c.xgmml       2009-07-09 
13:53:38 UTC (rev 17280)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<graph label="Network 0" xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 
xmlns:cy="http://www.cytoscape.org"; xmlns="http://www.cs.rpi.edu/XGMML";  
directed="1">
+  <att name="documentVersion" value="1.1"/>
+  <att name="networkMetadata">
+    <rdf:RDF>
+      <rdf:Description rdf:about="http://www.cytoscape.org/";>
+        <dc:type>Protein-Protein Interaction</dc:type>
+        <dc:description>N/A</dc:description>
+        <dc:identifier>N/A</dc:identifier>
+        <dc:date>2009-06-15 16:45:41</dc:date>
+        <dc:title>Network 0</dc:title>
+        <dc:source>http://www.cytoscape.org/</dc:source>
+        <dc:format>Cytoscape-XGMML</dc:format>
+      </rdf:Description>
+    </rdf:RDF>
+  </att>
+  <node label="node0" id="-2">
+    <att type="string" name="NODE_TYPE" value="DefaultNode"/>
+    <att type="string" name="testString" value="This is a test string for 
node0\nAnother sentence$©ﻸ"/>
+    <att type="string" name="canonicalName" value="node0"/>
+  </node>
+</graph>

Added: cytoscape/trunk/tests/cytoscape/data/writers/XGMMLWriterTest.java
===================================================================
--- cytoscape/trunk/tests/cytoscape/data/writers/XGMMLWriterTest.java           
                (rev 0)
+++ cytoscape/trunk/tests/cytoscape/data/writers/XGMMLWriterTest.java   
2009-07-09 13:53:38 UTC (rev 17280)
@@ -0,0 +1,182 @@
+/*
+ File: XGMMLWriterTest.java
+
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.data.writers;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+import cytoscape.data.CyAttributesImpl;
+
+import cytoscape.data.readers.XGMMLReader;
+
+import java.io.FileInputStream;
+import junit.framework.TestCase;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+
+import java.net.URISyntaxException;
+
+
+/**
+ * Tests the CyAttributesWriter Class.
+ *
+ * Note 2/6/2008 by kono:
+ *   This code tests CyAttributesWriter2, not the original one.
+ *
+ */
+public class XGMMLWriterTest extends TestCase {
+    public void testXGMMLWriterRoundTrip1() throws IOException, 
URISyntaxException {
+        // No characters that are affecting by full encoding, so only one test.
+        compareRoundTrip("testData/XGMMLWriterTestFile01a.xgmml", 
"testData/XGMMLWriterTestFile01b.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2aFullEncodingDefault() throws 
IOException, URISyntaxException {
+        System.clearProperty(XGMMLWriter.ENCODE_PROPERTY);
+        compareRoundTrip("testData/XGMMLWriterTestFile02a.xgmml", 
"testData/XGMMLWriterTestFile02a.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2aFullEncodingOn() throws IOException, 
URISyntaxException {
+        System.setProperty(XGMMLWriter.ENCODE_PROPERTY, "true");
+        compareRoundTrip("testData/XGMMLWriterTestFile02a.xgmml", 
"testData/XGMMLWriterTestFile02a.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2aFullEncodingOff() throws 
IOException, URISyntaxException {
+        System.setProperty(XGMMLWriter.ENCODE_PROPERTY, "false");
+        compareRoundTrip("testData/XGMMLWriterTestFile02a.xgmml", 
"testData/XGMMLWriterTestFile02a.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2bFullEncodingDefault() throws 
IOException, URISyntaxException {
+        System.clearProperty(XGMMLWriter.ENCODE_PROPERTY);
+        compareRoundTrip("testData/XGMMLWriterTestFile02b.xgmml", 
"testData/XGMMLWriterTestFile02a.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2bFullEncodingOn() throws IOException, 
URISyntaxException {
+        System.setProperty(XGMMLWriter.ENCODE_PROPERTY, "true");
+        compareRoundTrip("testData/XGMMLWriterTestFile02b.xgmml", 
"testData/XGMMLWriterTestFile02a.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2bFullEncodingOff() throws 
IOException, URISyntaxException {
+        System.setProperty(XGMMLWriter.ENCODE_PROPERTY, "false");
+        compareRoundTrip("testData/XGMMLWriterTestFile02b.xgmml", 
"testData/XGMMLWriterTestFile02a.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2cFullEncodingDefault() throws 
IOException, URISyntaxException {
+        System.clearProperty(XGMMLWriter.ENCODE_PROPERTY);
+        compareRoundTrip("testData/XGMMLWriterTestFile02c.xgmml", 
"testData/XGMMLWriterTestFile02d.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2cFullEncodingOn() throws IOException, 
URISyntaxException {
+        System.setProperty(XGMMLWriter.ENCODE_PROPERTY, "true");
+        compareRoundTrip("testData/XGMMLWriterTestFile02c.xgmml", 
"testData/XGMMLWriterTestFile02d.xgmml");
+    }
+
+    public void testXGMMLWriterRoundTrip2cFullEncodingOff() throws 
IOException, URISyntaxException {
+        System.setProperty(XGMMLWriter.ENCODE_PROPERTY, "false");
+        compareRoundTrip("testData/XGMMLWriterTestFile02c.xgmml", 
"testData/XGMMLWriterTestFile02c.xgmml");
+    }
+
+    private void compareRoundTrip(String fileIn, String fileToCompare) throws 
IOException, URISyntaxException {
+        XGMMLReader r;
+        CyNetwork cn;
+        StringWriter sw;
+        XGMMLWriter w;
+               String output;
+
+        r = new XGMMLReader(fileIn);
+        cn = Cytoscape.createNetwork(r, false, null);
+
+        sw = new StringWriter();
+        w = new XGMMLWriter(cn, null);
+        w.write(sw);
+        sw.close();
+
+               output = sw.toString();
+
+        compareFilesByLine(fileToCompare, output);
+    }
+
+    private void compareFilesByLine(String fileToCompare, String output) 
throws IOException {
+        String[] linesGot;
+        StringBuilder sb;
+        FileInputStream fis;
+        InputStreamReader isr;
+        int c;
+        String content;
+        String[] linesExptd;
+
+               linesGot = output.split("\n");
+
+               for (String line : linesGot) {
+                       System.out.println(line);
+               }
+
+        sb = new StringBuilder();
+        fis = new FileInputStream(fileToCompare);
+        isr = new InputStreamReader(fis, XGMMLWriter.ENCODING);
+        c = isr.read();
+        while (c != -1)
+        {
+            sb.append((char)c);
+            c = isr.read();
+        }
+        isr.close();
+        content = sb.toString();
+        System.out.println("Read " + 
content.getBytes(XGMMLWriter.ENCODING).length + " bytes");
+               linesExptd = content.split("\n");
+        assertTrue("XGMMLWriter: No. of lines, expect " + linesExptd.length + 
", got" + linesGot.length, linesExptd.length == linesGot.length);
+
+        for (int i = 0; i < linesExptd.length; i++) {
+            // <dc:date> value will be different so skip this line
+            if (linesExptd[i].contains("<dc:date>")) {
+                continue;
+            }
+            System.out.println("Exp (" + linesExptd[i].length() + ")>" + 
linesExptd[i]);
+            System.out.println("Got (" + linesGot[i].length() + ")>" + 
linesGot[i]);
+            assertEquals(linesExptd[i], linesGot[i]);
+        }
+    }
+
+       /**
+        * Runs just this one unit test.
+        */
+       public static void main(String[] args) {
+               junit.textui.TestRunner.run(XGMMLWriterTest.class);
+       }
+}


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