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

Statement test cases #147

Merged
merged 6 commits into from
Feb 15, 2017
Merged

Statement test cases #147

merged 6 commits into from
Feb 15, 2017

Conversation

AfsanehR-zz
Copy link
Contributor

added unit test cases

@codecov-io
Copy link

codecov-io commented Feb 14, 2017

Codecov Report

Merging #147 into dev will increase coverage by 2.31%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##                dev     #147      +/-   ##
============================================
+ Coverage     27.32%   29.63%   +2.31%     
- Complexity     1142     1247     +105     
============================================
  Files            95       97       +2     
  Lines         23279    23303      +24     
  Branches       3870     3871       +1     
============================================
+ Hits           6360     6906     +546     
+ Misses        15641    15046     -595     
- Partials       1278     1351      +73
Flag Coverage Δ Complexity Δ
#JDBC41 29.54% <ø> (+2.31%) 1242 <ø> (+104)
#JDBC42 29.59% <ø> (+2.34%) 1247 <ø> (+107)
Impacted Files Coverage Δ Complexity Δ
src/main/java/microsoft/sql/DateTimeOffset.java 37.14% <ø> (-2.86%) 8% <ø> (-2%)
...rc/main/java/com/microsoft/sqlserver/jdbc/DDC.java 22.54% <ø> (-0.45%) 36% <ø> (ø)
...soft/sqlserver/jdbc/SQLServerDatabaseMetaData.java 12.68% <ø> (-0.12%) 20% <ø> (ø)
.../java/com/microsoft/sqlserver/jdbc/StreamDone.java 50% <ø> (ø) 14% <ø> (+1%)
.../com/microsoft/sqlserver/jdbc/SqlFedAuthToken.java 0% <ø> (ø) 0% <ø> (?)
...microsoft/sqlserver/jdbc/SQLServerADAL4JUtils.java 0% <ø> (ø) 0% <ø> (?)
...m/microsoft/sqlserver/jdbc/SQLServerResultSet.java 17.61% <ø> (+0.12%) 127% <ø> (ø)
...n/java/com/microsoft/sqlserver/jdbc/DataTypes.java 68.01% <ø> (+0.16%) 0% <ø> (ø)
...in/java/com/microsoft/sqlserver/jdbc/IOBuffer.java 31.88% <ø> (+0.97%) 0% <ø> (ø)
.../microsoft/sqlserver/jdbc/SQLServerConnection.java 38.78% <ø> (+1.24%) 190% <ø> (+11%)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3733637...30a4359. Read the comment docs.

Copy link
Contributor

@v-nisidh v-nisidh left a comment

Choose a reason for hiding this comment

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

Still reviewing.

import com.microsoft.sqlserver.testframework.DBConnection;
import com.microsoft.sqlserver.testframework.DBStatement;

@RunWith(JUnitPlatform.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to have class & method level javadocs for all classes in this PR

@Test
@DisplayName("Named Param Multi Part Test")
public void datatypestest() throws Exception {
Connection Connection1 = DriverManager.getConnection(connectionString);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you really need connection1 & statment1? Because in AbstractTest we open one connection and accessible for all child classes. If somehow this connection fails due to may be wrong db connectionstring etc then all testcases which extends AbstractTest get skipped due to failure of setup method.

For specific testing it is goo to create your own connection & close that one but this case for connection1 we are not doing anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. This was part of the original test. Will remove it.

public void poolableTest() throws SQLException, ClassNotFoundException {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection Connection1 = DriverManager.getConnection(connectionString);
Statement Statement151 = Connection1.createStatement();
Copy link
Contributor

Choose a reason for hiding this comment

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

Statement151. :) I think stmt might be more appropriate.

@RunWith(JUnitPlatform.class)
public class CallableMixed extends AbstractTest {
Connection connection1 = null;
Statement Statement151 = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I found non standard naming conventions. Instance Variables should start with lowercase. Generally identified as camelCase / lowerCamelCase. Look difference between connection1 and Stmatement151 / Driver1. Please change all instance variables with appropriate camelCase naming convention.

PS: Generally only static / final variables are in CAPS otherwise camelCase is pretty standard.


@Test
@DisplayName("Test CallableMix")
public void datatypestest() throws SQLException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Function / Method name should be in lowerCamelCase / camelCase. This name should be dataTypesTest.

*/
@Test
@DisplayName("Test CallableMix")
public void datatypestest() throws SQLException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately GitHub Reviews are not getting reflected after code file changes. :(

Here method name is not following lowerCamelCase nomenclature. It should be dataTypesTest

//TODO: Check the intermittent verification error
//verifydata(ordinal, coercion, expectedData, retrieved);
// TODO: Check the intermittent verification error
// verifydata(ordinal, coercion, expectedData, retrieved);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really want to verify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not related to this pr. we need to investigate this later for the intermittent bvt failures

return isSqlAzure;
}

public double serverversion() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can give better function name like getServerVersion()

}

// Returns the default server version, not to be used in multiple server versions case
public static double serverversion() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw another serverversion() in DBConnection with different implementation. Which is right? Can we move this function in AbstractTest ?

public class WrapperTest extends AbstractTest {

@Test
public void WrapTest() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Function name should be lowerCamelCase like

wrapTest

public static final String SERVER_TYPE_SQL_SERVER = "SQL";
public static final String SERVER_TYPE_SQL_AZURE = "SQLAzure";

public static String servertype()
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Formatting is not consistent for servertype method.
  • Method name should be like getServerType(...) for better naming convention.
  • Do you think this might be utility method and can be used by many test cases?

return _serverType;
}

public static String get(String property){
Copy link
Contributor

Choose a reason for hiding this comment

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

Really no need of this method. Instead of this method you can call Utils.getConfiguredProperty

@DisplayName("Test CallableMix")
public void datatypestest() throws SQLException {
connection1 = DriverManager.getConnection(connectionString);
Statement151 = connection1.createStatement();
Copy link
Contributor

Choose a reason for hiding this comment

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

All instance variable's name should be in lowerCamelCase while static final variable names should be in CAPS.

isPoolable = ((SQLServerPreparedStatement) prepStmt).isPoolable();
assertEquals(isPoolable, true, "SQLServerPreparedStatement should be Poolable by default");


CallableStatement CallableStatement1 = Connection1.prepareCall("{ ? = CALL " + "ProcName" + " (?, ?, ?, ?) }");
CallableStatement CallableStatement1 = connection.prepareCall("{ ? = CALL " + "ProcName" + " (?, ?, ?, ?) }");
Copy link
Contributor

Choose a reason for hiding this comment

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

CallableStatement1 should be callableStatement1. lowerCamelCase.

}

public double serverversion() throws Exception {
public double getServerversion() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change function name in lowerCamelCase i.e. getServerVersion

// default to SQL Server
_serverType = SERVER_TYPE_SQL_SERVER;
}
else if (serverTypeProperty.equalsIgnoreCase(SERVER_TYPE_SQL_AZURE))
Copy link
Contributor

Choose a reason for hiding this comment

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

Like to have constant on left hand side for comparison. Although it's good that you are checking serverTypeProperty is null nor not before any comparison.

@v-nisidh v-nisidh added this to the 6.1.4 milestone Feb 15, 2017
@AfsanehR-zz AfsanehR-zz merged commit 59a571a into microsoft:dev Feb 15, 2017
@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

3 participants