Skip to content

Commit

Permalink
JDBC-193: Add tests for getTables() metadata (work in progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotteveel committed Jan 5, 2012
1 parent d09e2bc commit 6f729f9
Show file tree
Hide file tree
Showing 3 changed files with 600 additions and 11 deletions.
7 changes: 3 additions & 4 deletions src/test/org/firebirdsql/jdbc/FBMetaDataTestBase.java
Expand Up @@ -106,8 +106,8 @@ protected void additionalTeardown() throws Exception {
}

/**
* Method providing the list of DROP statements to be executed in the
* setUp() and tearDown().
* Provides the list of DROP statements to be executed in the setUp() and
* tearDown().
* <p>
* The provided list must be ordered based on dependencies between objects
* (if any)
Expand All @@ -118,8 +118,7 @@ protected void additionalTeardown() throws Exception {
protected abstract List<String> getDropStatements();

/**
* Methods providing the list of CREATE (or other DDL) to be executed in the
* setUp().
* Provides the list of CREATE (or other DDL) to be executed in the setUp().
* <p>
* The provided list must be ordered based on dependencies between objects
* (if any)
Expand Down
14 changes: 7 additions & 7 deletions src/test/org/firebirdsql/jdbc/MetaDataValidator.java
Expand Up @@ -59,7 +59,8 @@ public void assertColumnPosition(ResultSet rs) throws SQLException {
*/
public void assertColumnType(ResultSet rs) throws SQLException {
ResultSetMetaData md = rs.getMetaData();
assertEquals(String.format("Unexpected SQL Type for column %s", mdi), getSqlType(), md.getColumnType(mdi.getPosition()));
int sqlType = md.getColumnType(mdi.getPosition());
assertTrue(String.format("Unexpected SQL Type %d for column %s", sqlType, mdi), isAllowedSqlType(sqlType));
}

/**
Expand Down Expand Up @@ -118,17 +119,16 @@ private void assertStringColumnValue(ResultSet rs, String expectedValue)
assertEquals(String.format("Unexpected value for %s", mdi), expectedValue, value);
}

private int getSqlType() {
private boolean isAllowedSqlType(int sqlType) {
if (mdi.getColumnClass() == String.class) {
return Types.VARCHAR;
return (sqlType == Types.CHAR || sqlType == Types.VARCHAR || sqlType == Types.LONGVARCHAR);
} else if (mdi.getColumnClass() == Integer.class) {
return Types.INTEGER;
return (sqlType == Types.INTEGER);
} else if (mdi.getColumnClass() == Short.class) {
return Types.SMALLINT;
return (sqlType == Types.SMALLINT);
}
return Types.OTHER;
return false;
}


/**
* Interface for the information enums for metadata columns should be able to provide for the {@link MetaDataValidator}.
Expand Down

0 comments on commit 6f729f9

Please sign in to comment.