/** 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 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()); } }
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()); } }
public void test() throws java.lang.Exception { Connection conn = newConnection(); TestUtil.testScript(conn, path); }
private void runScript() { TestUtil.testScript(conn, "testrun/hsqldb/TestTriggers.txt"); }