package test; import junit.framework.*; import java.sql.*; import net.ivoa.SkyNode.*; public class TestColumns extends TestCase { public void testColumns(){ String testTable = ""; Connection db = null; MetaColumn[] cNames = null; ncsa.nvo.skynode.Configure config = new ncsa.nvo.skynode.Configure("/Configure.xml"); String dbDriver = config.getConfigParam("JDBCDriver")[0]; // Get the db parameters String jdbcUrl = config.getConfigParam("JDBCurl")[0]; String userName = config.getConfigParam("Username")[0]; String passWord = config.getConfigParam("Password")[0]; try { Class.forName(dbDriver); } catch (ClassNotFoundException e) { System.out.println( "JDBC Driver class not found: " + dbDriver + "\n" + "Check the JDBCDriver tag in Configure.xml" ); Assert.fail("Driver class not found"); } try { db = DriverManager.getConnection (jdbcUrl, userName, passWord); } catch (java.sql.SQLException e) { System.out.println( "Cannot connect to the database: " + jdbcUrl + "\n" + "Check the JDBCurl, Username and Password tags in Configure.xml" ); Assert.fail("Can't connect to the database"); } try { //Now get columns for a table; try the first one from a database // query for tables DatabaseMetaData dbmd = db.getMetaData(); ResultSet rs = dbmd.getTables(null, null, null, null); boolean existExclude = true; boolean existInclude = true; String[] excludeTables = config.getConfigParam("ExcludeTable"); String[] includeTables = config.getConfigParam("IncludeTable"); if (excludeTables.length == 1 && excludeTables[0].equals("")) existExclude = false; if (includeTables.length == 1 && includeTables[0].equals("")) existInclude = false; if(existInclude) { //Find out how many tables we are returning // Should match number of includeTables int count = 0; while(rs.next()) { String temp = ""; for (int i=0;i= 0 test: while (rs.next()) { boolean includeTable = true; String temp = rs.getString(3); for (int i=0;i= 0 rs = dbmd.getColumns(null, null, testTable, null); //Find out how many columns we are returning int count = 0; while(rs.next()) { count++; } int numExcludes = 0; for (int i=0;i