-
Notifications
You must be signed in to change notification settings - Fork 451
Tests | Added more datatype tests to increase code coverage #878
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
eb3df3a
ported tests from VSO and added tests to increase code coverage
lilgreenbird c31b1f3
moved resultset tests to resultset
lilgreenbird 145ee72
removed unused import
lilgreenbird fd123b2
added tests to increase code coverage
lilgreenbird 3275750
fixed issue with timezone
lilgreenbird 45eeef5
fixed issue with timezone
lilgreenbird c5f4a9d
modified testWithThaiLocale to use current time
lilgreenbird d93e0fe
fixed issue with timezone
lilgreenbird 27702d3
fixed issue with timezone
lilgreenbird a48c810
fixed issue with timezone
lilgreenbird 9c697cf
added SparseTest and BigIntegerTest and cleaned up with try-with-reso…
lilgreenbird 83b6ddc
review changes
lilgreenbird b3c5ac5
review comments
lilgreenbird 8f71ce6
more review updates
lilgreenbird c46db9f
review updates
lilgreenbird e9556dd
Merge remote-tracking branch 'upstream/dev' into cov
lilgreenbird 3a0703d
removed dummy file
lilgreenbird d507114
review udpates
lilgreenbird 2994200
more cleanup
lilgreenbird e3512f9
updated isSqlAzure
lilgreenbird e4cb7f2
Merge branch 'cov' of https://github.com/lilgreenbird/mssql-jdbc into…
lilgreenbird 5217270
review updates
lilgreenbird 79ac177
more review updates
lilgreenbird ada91ae
fixed imports
lilgreenbird 36838a8
updated failed error strings with more detail
lilgreenbird a196be9
added locale to time format
lilgreenbird c7df1ed
format date for comparision
lilgreenbird dbcc0a3
1 more timezone fix
lilgreenbird f36c132
Merge remote-tracking branch 'upstream/dev' into cov
lilgreenbird bcc8732
cleanup leaded stream resources
lilgreenbird a5ee49f
Merge remote-tracking branch 'upstream/dev' into cov
lilgreenbird 62f615b
Merge remote-tracking branch 'upstream/dev' into cov
lilgreenbird fe01b41
manually merged with #903 changes for now
lilgreenbird d72eccc
merged
lilgreenbird 238b66f
more cleanup on assertEqual checks
lilgreenbird dc1a721
more cleanup on assertEqual checks
lilgreenbird 6eac22c
cosmetic changes from review
lilgreenbird 72956ed
updated all assertEquals params to proper expected, actual order
lilgreenbird db38827
fixed comments and leaked resultsets
lilgreenbird File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/test/java/com/microsoft/sqlserver/jdbc/callablestatement/CallableMixedTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| package com.microsoft.sqlserver.jdbc.callablestatement; | ||
|
|
||
| import java.sql.*; | ||
lilgreenbird marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import com.microsoft.sqlserver.jdbc.RandomUtil; | ||
| import com.microsoft.sqlserver.jdbc.SQLServerDriver; | ||
| import com.microsoft.sqlserver.jdbc.TestUtils; | ||
| import com.microsoft.sqlserver.testframework.AbstractSQLGenerator; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.platform.runner.JUnitPlatform; | ||
| import org.junit.runner.RunWith; | ||
| import static org.junit.jupiter.api.Assertions.fail; | ||
|
|
||
|
|
||
| @RunWith(JUnitPlatform.class) | ||
| public class CallableMixedTest { | ||
|
|
||
| @Test | ||
| public void datatypestest() throws Exception { | ||
| Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); | ||
lilgreenbird marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| String connectionString = TestUtils.getConfiguredProperty("mssql_jdbc_test_connection_properties"); | ||
lilgreenbird marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| String tableName = RandomUtil.getIdentifier("TFOO3"); | ||
| String procName = RandomUtil.getIdentifier("SPFOO3"); | ||
|
|
||
| try (Connection conn = DriverManager.getConnection(connectionString)) { | ||
| try (Statement stmt = conn.createStatement()) { | ||
| TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(tableName), stmt); | ||
|
|
||
| String createSQL = "create table " + AbstractSQLGenerator.escapeIdentifier(tableName) | ||
| + "(c1_int int primary key, col2 int)"; | ||
| stmt.executeUpdate(createSQL); | ||
|
|
||
| stmt.executeUpdate("Insert into " + AbstractSQLGenerator.escapeIdentifier(tableName) + " values(0, 1)"); | ||
|
|
||
| stmt.executeUpdate("CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(procName) | ||
| + " (@p2_int int, @p2_int_out int OUTPUT, @p4_smallint smallint, @p4_smallint_out smallint OUTPUT) AS begin transaction SELECT * FROM " | ||
| + AbstractSQLGenerator.escapeIdentifier(tableName) | ||
| + " ; SELECT @p2_int_out=@p2_int, @p4_smallint_out=@p4_smallint commit transaction RETURN -2147483648"); | ||
| } | ||
|
|
||
| try (CallableStatement cstmt = conn.prepareCall( | ||
| "{ ? = CALL " + AbstractSQLGenerator.escapeIdentifier(procName) + " (?, ?, ?, ?) }")) { | ||
| cstmt.registerOutParameter((int) 1, (int) 4); | ||
| cstmt.setObject((int) 2, Integer.valueOf("31"), (int) 4); | ||
| cstmt.registerOutParameter((int) 3, (int) 4); | ||
| cstmt.registerOutParameter((int) 5, java.sql.Types.BINARY); // Test OUT param | ||
| // re-registration | ||
| // (Defect 60921) | ||
| cstmt.registerOutParameter((int) 5, (int) 5); | ||
| cstmt.setObject((int) 4, Short.valueOf("-5372"), (int) 5); | ||
|
|
||
| // get results and a value | ||
| ResultSet rs = cstmt.executeQuery(); | ||
| rs.next(); | ||
|
|
||
| if (rs.getInt(1) != 0) { | ||
| fail("Received data not equal to setdata"); | ||
| } | ||
|
|
||
| if (cstmt.getInt((int) 5) != -5372) { | ||
| fail("Received data not equal to setdata"); | ||
| } | ||
|
|
||
| // do nothing and reexecute | ||
| rs = cstmt.executeQuery(); | ||
| // get the param without getting the resultset | ||
| rs = cstmt.executeQuery(); | ||
| if (cstmt.getInt((int) 1) != -2147483648) { | ||
| fail("Received data not equal to setdata"); | ||
| } | ||
|
|
||
| if (cstmt.getInt((int) 1) != -2147483648) { | ||
| fail("Received data not equal to setdata"); | ||
| } | ||
|
|
||
lilgreenbird marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| rs = cstmt.executeQuery(); | ||
| rs.next(); | ||
|
|
||
| if (rs.getInt(1) != 0) { | ||
| fail("Received data not equal to setdata"); | ||
| } | ||
|
|
||
| if (cstmt.getInt((int) 1) != -2147483648) { | ||
| fail("Received data not equal to setdata"); | ||
| } | ||
|
|
||
| if (cstmt.getInt((int) 5) != -5372) { | ||
| fail("Received data not equal to setdata"); | ||
| } | ||
|
|
||
| rs = cstmt.executeQuery(); | ||
| } | ||
| } finally { | ||
| try (Connection conn = DriverManager.getConnection(connectionString); | ||
| Statement stmt = conn.createStatement()) { | ||
| TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(tableName), stmt); | ||
| } catch (SQLException e) { | ||
| fail(e.toString()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.