static void testScripts(String directory) {

    TestUtil.deleteDatabase("test1");

    try {
      Class.forName("org.hsqldb.jdbc.JDBCDriver");

      String url = "jdbc:hsqldb:test1;sql.enforce_strict_size=true";
      String user = "******";
      String password = "";
      Connection cConnection = null;
      String[] filelist;
      String absolute = new File(directory).getAbsolutePath();

      filelist = new File(absolute).list();

      ArraySort.sort((Object[]) filelist, 0, filelist.length, new StringComparator());

      for (int i = 0; i < filelist.length; i++) {
        String fname = filelist[i];

        if (fname.startsWith("TestSelf") && fname.endsWith(".txt")) {
          print("Openning DB");

          cConnection = DriverManager.getConnection(url, user, password);

          testScript(cConnection, absolute + File.separator + fname);
          cConnection.close();
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      print("TestUtil init error: " + e.getMessage());
    }
  }
  /** Basic test of DatabaseMetaData functions that access system tables */
  public void testTwo() throws Exception {

    Connection conn = newConnection();
    int updateCount;

    try {
      TestUtil.testScript(conn, "testrun/hsqldb/TestSelf.txt");

      DatabaseMetaData dbmeta = conn.getMetaData();

      dbmeta.allProceduresAreCallable();
      dbmeta.getBestRowIdentifier(null, null, "T_1", DatabaseMetaData.bestRowTransaction, true);
      dbmeta.getCatalogs();
      dbmeta.getColumnPrivileges(null, "PUBLIC", "T_1", "%");
      dbmeta.getColumns("PUBLIC", "PUBLIC", "T_1", "%");
      dbmeta.getCrossReference(null, null, "T_1", null, null, "T_1");
      dbmeta.getExportedKeys(null, null, "T_1");
      dbmeta.getFunctionColumns(null, "%", "%", "%");
      dbmeta.getFunctions(null, "%", "%");
      dbmeta.getImportedKeys("PUBLIC", "PUBLIC", "T_1");
      dbmeta.getIndexInfo("PUBLIC", "PUBLIC", "T1", true, true);
      dbmeta.getPrimaryKeys("PUBLIC", "PUBLIC", "T_1");
      dbmeta.getProcedureColumns(null, null, "%", "%");
      dbmeta.getProcedures("PUBLIC", "%", "%");
      dbmeta.getSchemas(null, "#");
      dbmeta.getTablePrivileges(null, "%", "%");
      dbmeta.getUDTs(null, "%", "%", new int[] {Types.DISTINCT});

    } catch (Exception e) {
      assertTrue("unable to prepare or execute DDL", false);
    } finally {
      conn.close();
    }
  }
  static void testScript(Connection aConnection, String aPath) {

    /*
     * This is a legacy wrapper method which purposefully inherits the sins
     * of the original.
     * No indication is given to the invoker of even RuntimeExceptions.
     */
    File file = new File(aPath);

    try {
      TestUtil.testScript(aConnection, file.getAbsolutePath(), new FileReader(file));
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("test script file error: " + e.getMessage());
    }
  }
  protected String getResultString() {

    StringBuffer sb = new StringBuffer();

    if (lines.length == 1 && lines[0].trim().length() < 1) {
      return null;
    }

    for (int i = 0; i < lines.length; i++) {
      if (i > 0) {
        sb.append(LS);
      }

      sb.append("+ " + lines[i]);
    }

    TestUtil.expandStamps(sb);

    return sb.toString().trim();
  }
  protected void setUp() throws Exception {

    super.setUp();

    user = "******";
    password = "";
    stmnt = null;
    connection = null;

    TestUtil.deleteDatabase("/hsql/test/testpersistent");

    try {
      Class.forName("org.hsqldb.jdbc.JDBCDriver");

      connection = DriverManager.getConnection(url, user, password);
      stmnt = connection.createStatement();
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("TestSqlPersistence.setUp() error: " + e.getMessage());
    }
  }
  public void test() throws java.lang.Exception {

    Connection conn = newConnection();

    TestUtil.testScript(conn, path);
  }
 private void runScript() {
   TestUtil.testScript(conn, "testrun/hsqldb/TestTriggers.txt");
 }
 public static void main(String[] argv) {
   TestUtil.testScripts("testrun/hsqldb");
 }
 /** Legacy wrapper */
 static void test(Statement stat, String s, int line) {
   TestUtil.test(stat, s, null, line);
 }