Skip to content

Updates to test framework#90

Merged
xiangyushawn merged 4 commits intomicrosoft:devfrom
Suraiya-Hameed:dev
Dec 28, 2016
Merged

Updates to test framework#90
xiangyushawn merged 4 commits intomicrosoft:devfrom
Suraiya-Hameed:dev

Conversation

@Suraiya-Hameed
Copy link
Copy Markdown
Contributor

No description provided.


//TODO: create a driver class to getConnection
DBConnection con = new DBConnection();
con.getConnection(connectionString);
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants