Skip to content
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

Merged
merged 4 commits into from
Dec 28, 2016
Merged

Updates to test framework #90

merged 4 commits into from
Dec 28, 2016

Conversation

Suraiya-Hameed
Copy link
Contributor

No description provided.


//TODO: create a driver class to getConnection
DBConnection con = new DBConnection();
con.getConnection(connectionString);
Copy link
Contributor

@xiangyushawn xiangyushawn Dec 23, 2016

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

@xiangyushawn xiangyushawn Dec 23, 2016

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.

Copy link
Contributor Author

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 ");
Copy link
Contributor

@xiangyushawn xiangyushawn Dec 23, 2016

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?

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe no?

Copy link
Contributor Author

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));
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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();
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@xiangyushawn xiangyushawn merged commit 0a8344e into microsoft:dev Dec 28, 2016
@lilgreenbird lilgreenbird added this to Closed/Merged PRs in MSSQL JDBC Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Closed/Merged PRs
Development

Successfully merging this pull request may close these issues.

None yet

2 participants