-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates to test framework #90
Conversation
|
||
//TODO: create a driver class to getConnection | ||
DBConnection con = new DBConnection(); | ||
con.getConnection(connectionString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connection.getConnection()
returns nothing makes me feel unfamiliar in the first glance. what do you think if we make the DBConnection()
constructor accept connectionString
and create actual connection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's sounds better, will update it.
DBStatement stmt = con.createStatement(); | ||
DBTable sourceTable = new DBTable(true); | ||
sourceTable.createTable(stmt); | ||
sourceTable.populateTable(stmt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of DBTable.createTable(DBStatement)
or DBTable.populateTable(DBStatement)
, can we do DBStatement.createTable(DBTable)
and DBStatement.populateTable(DBTable)
? to be consistent with actual JDBC code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
srcResultSet.close(); | ||
validateValues(con, sourceTable, destinationTable); | ||
sourceTable.dropTable(stmt); | ||
destinationTable.dropTable(stmt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, can we do DBStatement.dropTable(DBTable)
? to be consistent with actual JDBC code.
can we also move dropTable() methods into a finally block to make sure table is dropped when test fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
case java.sql.Types.CHAR: | ||
case java.sql.Types.NCHAR: | ||
assertTrue((((String) srcValue).equals(((String) dstValue))), "Unexpected char/nchar value "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we have .trim() for varchar and nvarchar but not for char or nchar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for char and nchar the trailing space is preserved, so I din't add it. Now that you mention it, do you think they needed for nvarchar and varchar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be even I'll remove trim() form both char and varchar
break; | ||
|
||
default: | ||
System.out.println("Unknow type "+destMeta.getColumnType(i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we throw exception if there is a missing type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/** | ||
* Container for all the columns | ||
*/ | ||
class DBColumns { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class is called DBColumns. can we merge it with DBTable? I feel they should be identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds fair, I'll update it.
} catch (ClassNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering why we need to catch those 2 exceptions? can't we just throw the exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best practice not to throw generic Exception whenever possible, so I've added individual ones (since its just 2).
public void close() throws SQLException | ||
{ | ||
if(null != resultSet) | ||
resultSet.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember we decided to use {} for single line if statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.