Beispiel #1
0
  public void testAdjacencyDirected() {
    DirectedGraph<String, DefaultEdge> g =
        new DirectedMultigraph<String, DefaultEdge>(DefaultEdge.class);
    g.addVertex(V1);
    g.addVertex(V2);
    g.addEdge(V1, V2);
    g.addVertex(V3);
    g.addEdge(V3, V1);
    g.addEdge(V3, V1);

    Writer w = new StringWriter();
    exporter.exportAdjacencyMatrix(w, g);
    assertEquals(DIRECTED_ADJACENCY, w.toString());
  }
  /**
   * Tests that the data updated in a Clob is always reflected in the Reader got. Here the updates
   * are done using both a Writer obtained from this Clob and using Clob.setString.
   *
   * @throws Exception
   */
  public void testGetCharacterStreamClobUpdates() throws Exception {
    // The String that will be used
    // to do the inserts into the
    // Clob.
    String str1 = "Hi I am the insert string";

    // The String that will be used in the
    // second series of updates
    String str2 = "Hi I am the update string";

    // create the empty Clob.
    Clob clob = getConnection().createClob();

    // Get the Reader from this
    // Clob
    Reader r_BeforeWrite = clob.getCharacterStream();

    // Get a writer from this Clob
    // into which the data can be written
    Writer w = clob.setCharacterStream(1);
    char[] chars_str1 = new char[str1.length()];
    str2.getChars(0, str1.length(), chars_str1, 0);
    w.write(chars_str1);

    // Doing a setString now on the Clob
    // should reflect the same extension
    // in the InputStream also.
    clob.setString((str1.length()) + 1, str2);

    // Now get the reader from the Clob after
    // the update has been done.
    Reader r_AfterWrite = clob.getCharacterStream();

    // Now compare the two readers to see that they
    // contain the same data.
    assertEquals(r_BeforeWrite, r_AfterWrite);
  }