/**
   * DOCUMENT ME!
   *
   * @throws Exception DOCUMENT ME!
   */
  public void testReadTable() throws Exception {

    InputStream is = null;
    POIFSFileSystem excelIn;

    try {
      is = getClass().getResource(NETWORK_FILE).openStream();
      excelIn = new POIFSFileSystem(is);
    } finally {
      if (is != null) {
        is.close();
      }
    }

    HSSFWorkbook wb = new HSSFWorkbook(excelIn);

    HSSFSheet sheet = wb.getSheetAt(0);

    List<String> delimiters = new ArrayList<String>();
    delimiters.add(TextFileDelimiters.TAB.toString());

    String[] galAttrName = {
      "Source", "Target", "Interaction", "edge bool attr", "edge string attr", "edge float attr"
    };
    Byte[] galAttrTypes = {
      CyAttributes.TYPE_STRING, CyAttributes.TYPE_STRING,
      CyAttributes.TYPE_STRING, CyAttributes.TYPE_BOOLEAN,
      CyAttributes.TYPE_STRING, CyAttributes.TYPE_FLOATING
    };
    NetworkTableMappingParameters mapping =
        new NetworkTableMappingParameters(
            delimiters,
            TextFileDelimiters.PIPE.toString(),
            galAttrName,
            galAttrTypes,
            null,
            null,
            0,
            1,
            2,
            null);

    reader = new ExcelNetworkSheetReader(wb.getSheetName(0), sheet, mapping);

    CyNetwork net = Cytoscape.createNetwork(reader, false, null);

    /*
     * test cases
     */
    assertEquals("Yeast Network Sheet 1", net.getTitle());
    assertEquals(331, net.getNodeCount());
    assertEquals(362, net.getEdgeCount());

    CyAttributes attr = Cytoscape.getEdgeAttributes();
    assertTrue(attr.getBooleanAttribute("YGL122C (pp) YOL123W", "edge bool attr"));
    assertFalse(attr.getBooleanAttribute("YKR026C (pp) YGL122C", "edge bool attr"));

    assertEquals(1.2344543, attr.getDoubleAttribute("YBL026W (pp) YOR167C", "edge float attr"));
    assertEquals("abcd12706", attr.getStringAttribute("YBL026W (pp) YOR167C", "edge string attr"));
    assertEquals("abcd12584", attr.getStringAttribute("YPL248C (pd) ?", "edge string attr"));

    Cytoscape.destroyNetwork(net);
  }
  public void testReadTableWithEmptyRows() throws Exception {
    String network = "/empty_attr_row.xls";

    InputStream is = null;
    POIFSFileSystem excelIn;

    try {
      is = getClass().getResource(network).openStream();
      excelIn = new POIFSFileSystem(is);
    } finally {
      if (is != null) {
        is.close();
      }
    }

    HSSFWorkbook wb = new HSSFWorkbook(excelIn);

    HSSFSheet sheet = wb.getSheetAt(0);

    List<String> delimiters = new ArrayList<String>();
    delimiters.add(TextFileDelimiters.TAB.toString());

    String[] galAttrName = {"Gene 1", "Gene 2", "Interaction Type", "Gene", "GO Group"};
    Byte[] galAttrTypes = {
      CyAttributes.TYPE_STRING,
      CyAttributes.TYPE_STRING,
      CyAttributes.TYPE_STRING,
      CyAttributes.TYPE_STRING,
      CyAttributes.TYPE_STRING
    };
    NetworkTableMappingParameters mapping =
        new NetworkTableMappingParameters(
            delimiters,
            TextFileDelimiters.PIPE.toString(),
            galAttrName,
            galAttrTypes,
            null,
            null,
            0,
            1,
            2,
            null);

    CyNetwork net = null;
    try {
      reader = new ExcelNetworkSheetReader(wb.getSheetName(0), sheet, mapping, 1);
      net = Cytoscape.createNetwork(reader, false, null);
    } catch (Exception ee) {
      ee.printStackTrace();
      fail("Caught exception");
    }

    assertEquals(222, net.getNodeCount());
    assertEquals(443, net.getEdgeCount());

    CyAttributes attr = Cytoscape.getEdgeAttributes();

    // test some random edges
    assertEquals("cc", attr.getStringAttribute("YDR459C (cc) YNL271C", "interaction"));
    assertEquals("Transport", attr.getStringAttribute("YDR459C (cc) YNL271C", "GO Group"));
    assertEquals("YPR011C", attr.getStringAttribute("YDR459C (cc) YNL271C", "Gene"));

    assertNull(attr.getStringAttribute("YEL040W (cc) YER016W", "GO Group"));
    assertNull(attr.getStringAttribute("YEL040W (cc) YER016W", "Gene"));

    Cytoscape.destroyNetwork(net);
  }