Attached is a patch that fixes DatabaseMetaDataTest in the JDBC driver's test suite. With previous patches applied, this reduces the number of failures of the test suite from 6 to 4. The patch fixes the test case itself, rather than the driver. Details: 1) The driver correctly provided DatabaseMetaData about the sort order of NULLs. This was confirmed by Peter Eisentraut on pgsql-hackers. I fixed the test to accept/require the current behaviour, and made it dependent on the backend version. See nullsAreSortedAtStart(), nullsAreSortedAtEnd(), nullsAreSortedHigh() and nullsAreSortedLow(). 2) DatabaseMetaData.supportsOrderByUnrelated() correctly returned true (an ORDER BY clause can contain columns that are not in the SELECT clause), but the test case required false. Fixed that. 3) Replaced deprecated assert() of junit.framework.TestCase by assertEquals(), assertTrue() and assertNotNull(). This is because assert will be a new keyword in Java 1.4. 4) Replaced assert(message,false) by the more elegant fail(message). Regards, René Pijlman <[EMAIL PROTECTED]>
Index: org/postgresql/test/jdbc2/DatabaseMetaDataTest.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v retrieving revision 1.1 diff -c -r1.1 DatabaseMetaDataTest.java *** org/postgresql/test/jdbc2/DatabaseMetaDataTest.java 2001/02/13 16:39:05 1.1 --- org/postgresql/test/jdbc2/DatabaseMetaDataTest.java 2001/09/09 14:04:42 *************** *** 29,39 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 29,39 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 45,76 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! assert(dbmd.allProceduresAreCallable()==true); ! assert(dbmd.allTablesAreSelectable()==true); // not true all the time // This should always be false for postgresql (at least for 7.x) ! assert(!dbmd.isReadOnly()); // does the backend support this yet? The protocol does... ! assert(!dbmd.supportsMultipleResultSets()); // yes, as multiple backends can have transactions open ! assert(dbmd.supportsMultipleTransactions()); ! assert(dbmd.supportsMinimumSQLGrammar()); ! assert(!dbmd.supportsCoreSQLGrammar()); ! assert(!dbmd.supportsExtendedSQLGrammar()); ! assert(!dbmd.supportsANSI92EntryLevelSQL()); ! assert(!dbmd.supportsANSI92IntermediateSQL()); ! assert(!dbmd.supportsANSI92FullSQL()); ! assert(!dbmd.supportsIntegrityEnhancementFacility()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 45,76 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! assertTrue(dbmd.allProceduresAreCallable()); ! assertTrue(dbmd.allTablesAreSelectable()); // not true all the time // This should always be false for postgresql (at least for 7.x) ! assertTrue(!dbmd.isReadOnly()); // does the backend support this yet? The protocol does... ! assertTrue(!dbmd.supportsMultipleResultSets()); // yes, as multiple backends can have transactions open ! assertTrue(dbmd.supportsMultipleTransactions()); ! assertTrue(dbmd.supportsMinimumSQLGrammar()); ! assertTrue(!dbmd.supportsCoreSQLGrammar()); ! assertTrue(!dbmd.supportsExtendedSQLGrammar()); ! assertTrue(!dbmd.supportsANSI92EntryLevelSQL()); ! assertTrue(!dbmd.supportsANSI92IntermediateSQL()); ! assertTrue(!dbmd.supportsANSI92FullSQL()); ! assertTrue(!dbmd.supportsIntegrityEnhancementFacility()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 80,94 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! assert(dbmd.supportsOuterJoins()); ! assert(dbmd.supportsFullOuterJoins()); ! assert(dbmd.supportsLimitedOuterJoins()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 80,94 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! assertTrue(dbmd.supportsOuterJoins()); ! assertTrue(dbmd.supportsFullOuterJoins()); ! assertTrue(dbmd.supportsLimitedOuterJoins()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 97,110 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! assert(!dbmd.supportsPositionedDelete()); ! assert(!dbmd.supportsPositionedUpdate()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 97,110 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! assertTrue(!dbmd.supportsPositionedDelete()); ! assertTrue(!dbmd.supportsPositionedUpdate()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 113,133 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! // these need double checking ! assert(!dbmd.nullsAreSortedAtStart()); ! assert(dbmd.nullsAreSortedAtEnd()); ! assert(!dbmd.nullsAreSortedHigh()); ! assert(!dbmd.nullsAreSortedLow()); ! assert(dbmd.nullPlusNonNullIsNull()); ! assert(dbmd.supportsNonNullableColumns()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 113,139 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! // We need to type cast the connection to get access to the ! // PostgreSQL-specific method haveMinimumServerVersion(). ! // This is not available through the java.sql.Connection interface. ! assertTrue( con instanceof org.postgresql.Connection ); ! assertTrue(!dbmd.nullsAreSortedAtStart()); ! assertTrue( dbmd.nullsAreSortedAtEnd() != ! ((org.postgresql.Connection)con).haveMinimumServerVersion("7.2")); ! assertTrue( dbmd.nullsAreSortedHigh() == ! ((org.postgresql.Connection)con).haveMinimumServerVersion("7.2")); ! assertTrue(!dbmd.nullsAreSortedLow()); ! assertTrue(dbmd.nullPlusNonNullIsNull()); + assertTrue(dbmd.supportsNonNullableColumns()); + JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 136,149 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! assert(!dbmd.usesLocalFilePerTable()); ! assert(!dbmd.usesLocalFiles()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 142,155 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! assertTrue(!dbmd.usesLocalFilePerTable()); ! assertTrue(!dbmd.usesLocalFiles()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 152,174 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! assert(!dbmd.supportsMixedCaseIdentifiers()); // always false ! assert(dbmd.supportsMixedCaseQuotedIdentifiers()); // always true ! assert(!dbmd.storesUpperCaseIdentifiers()); // always false ! assert(dbmd.storesLowerCaseIdentifiers()); // always true ! assert(!dbmd.storesUpperCaseQuotedIdentifiers()); // always false ! assert(!dbmd.storesLowerCaseQuotedIdentifiers()); // always false ! assert(!dbmd.storesMixedCaseQuotedIdentifiers()); // always false ! assert(dbmd.getIdentifierQuoteString().equals("\"")); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 158,180 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! assertTrue(!dbmd.supportsMixedCaseIdentifiers()); // always false ! assertTrue(dbmd.supportsMixedCaseQuotedIdentifiers()); // always true ! assertTrue(!dbmd.storesUpperCaseIdentifiers()); // always false ! assertTrue(dbmd.storesLowerCaseIdentifiers()); // always true ! assertTrue(!dbmd.storesUpperCaseQuotedIdentifiers()); // always false ! assertTrue(!dbmd.storesLowerCaseQuotedIdentifiers()); // always false ! assertTrue(!dbmd.storesMixedCaseQuotedIdentifiers()); // always false ! assertTrue(dbmd.getIdentifierQuoteString().equals("\"")); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 177,193 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); // we can add columns ! assert(dbmd.supportsAlterTableWithAddColumn()); // we can't drop columns (yet) ! assert(!dbmd.supportsAlterTableWithDropColumn()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 183,199 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); // we can add columns ! assertTrue(dbmd.supportsAlterTableWithAddColumn()); // we can't drop columns (yet) ! assertTrue(!dbmd.supportsAlterTableWithDropColumn()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 196,218 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); // yes we can?: SELECT col a FROM a; ! assert(dbmd.supportsColumnAliasing()); // yes we can have expressions in ORDERBY ! assert(dbmd.supportsExpressionsInOrderBy()); ! assert(!dbmd.supportsOrderByUnrelated()); ! assert(dbmd.supportsGroupBy()); ! assert(dbmd.supportsGroupByUnrelated()); ! assert(dbmd.supportsGroupByBeyondSelect()); // needs checking JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } --- 202,226 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); // yes we can?: SELECT col a FROM a; ! assertTrue(dbmd.supportsColumnAliasing()); // yes we can have expressions in ORDERBY ! assertTrue(dbmd.supportsExpressionsInOrderBy()); ! // Yes, an ORDER BY clause can contain columns that are not in the ! // SELECT clause. ! assertTrue(dbmd.supportsOrderByUnrelated()); ! assertTrue(dbmd.supportsGroupBy()); ! assertTrue(dbmd.supportsGroupByUnrelated()); ! assertTrue(dbmd.supportsGroupByBeyondSelect()); // needs checking JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } *************** *** 221,273 **** Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! assert(dbmd.getURL().equals(JDBC2Tests.getURL())); ! assert(dbmd.getUserName().equals(JDBC2Tests.getUser())); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } public void testDbProductDetails() { try { Connection con = JDBC2Tests.openDB(); ! assert(con instanceof org.postgresql.Connection); org.postgresql.Connection pc = (org.postgresql.Connection) con; DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! assert(dbmd.getDatabaseProductName().equals("PostgreSQL")); ! assert(dbmd.getDatabaseProductVersion().startsWith(Integer.toString(pc.this_driver.getMajorVersion())+"."+Integer.toString(pc.this_driver.getMinorVersion()))); ! assert(dbmd.getDriverName().equals("PostgreSQL Native Driver")); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } public void testDriverVersioning() { try { Connection con = JDBC2Tests.openDB(); ! assert(con instanceof org.postgresql.Connection); org.postgresql.Connection pc = (org.postgresql.Connection) con; DatabaseMetaData dbmd = con.getMetaData(); ! assert(dbmd!=null); ! assert(dbmd.getDriverVersion().equals(pc.this_driver.getVersion())); ! assert(dbmd.getDriverMajorVersion()==pc.this_driver.getMajorVersion()); ! assert(dbmd.getDriverMinorVersion()==pc.this_driver.getMinorVersion()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! assert(ex.getMessage(),false); } } ! } \ No newline at end of file --- 229,281 ---- Connection con = JDBC2Tests.openDB(); DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! assertTrue(dbmd.getURL().equals(JDBC2Tests.getURL())); ! assertTrue(dbmd.getUserName().equals(JDBC2Tests.getUser())); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } public void testDbProductDetails() { try { Connection con = JDBC2Tests.openDB(); ! assertTrue(con instanceof org.postgresql.Connection); org.postgresql.Connection pc = (org.postgresql.Connection) con; DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! assertTrue(dbmd.getDatabaseProductName().equals("PostgreSQL")); ! assertTrue(dbmd.getDatabaseProductVersion().startsWith(Integer.toString(pc.this_driver.getMajorVersion())+"."+Integer.toString(pc.this_driver.getMinorVersion()))); ! assertTrue(dbmd.getDriverName().equals("PostgreSQL Native Driver")); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } public void testDriverVersioning() { try { Connection con = JDBC2Tests.openDB(); ! assertTrue(con instanceof org.postgresql.Connection); org.postgresql.Connection pc = (org.postgresql.Connection) con; DatabaseMetaData dbmd = con.getMetaData(); ! assertNotNull(dbmd); ! assertTrue(dbmd.getDriverVersion().equals(pc.this_driver.getVersion())); ! assertTrue(dbmd.getDriverMajorVersion()==pc.this_driver.getMajorVersion()); ! assertTrue(dbmd.getDriverMinorVersion()==pc.this_driver.getMinorVersion()); JDBC2Tests.closeDB(con); } catch(SQLException ex) { ! fail(ex.getMessage()); } } ! }
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly