Exemplo n.º 1
0
  /**
   * From a datastore, dump it, then load from that dump, dump again, and compare the two dumps.
   *
   * <p>This is a somewhat weak test in that if the dump does something wrong, it quite possibly
   * will do the same thing wrong in both dumps. But it does catch things like dump files which
   * won't load because tables/rows are not in the order which will work with foreign keys.
   */
  private static void checkRoundTrip(DataStore inputStore) {
    String dump = new SqlDumper().dump(inputStore);
    Database database2 = new Database();
    try {
      database2.executeScript(new StringReader(dump));
    } catch (MayflyException e) {
      throw new RuntimeException(
          "failure in command: " + e.failingCommand() + "\ndump was:\n" + dump, e);
    }

    String dump2 = new SqlDumper().dump(database2.dataStore());
    assertEquals(dump, dump2);
  }
Exemplo n.º 2
0
 private Database load(String second) {
   Database aDatabase = new Database();
   aDatabase.executeScript(new StringReader(second));
   return aDatabase;
 }