-
Notifications
You must be signed in to change notification settings - Fork 423
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
Statement test cases #147
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8e036d5
added Statement unit test cases
AfsanehR-zz c68cdca
added getproperty for checking jdbc version and java docs
AfsanehR-zz 85b0c4b
post review changes
AfsanehR-zz 4f7c866
post reviews commits
AfsanehR-zz 741dd77
fixed the failure on travis-CI
AfsanehR-zz 30a4359
fixed the formatting
AfsanehR-zz 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
462 changes: 462 additions & 0 deletions
462
src/test/java/com/microsoft/sqlserver/UnitStatement/BatchExecuteWithErrorsTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
src/test/java/com/microsoft/sqlserver/UnitStatement/CallableMixedTest.java
This file contains 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 @@ | ||
/* | ||
* Microsoft JDBC Driver for SQL Server | ||
* | ||
* Copyright(c) Microsoft Corporation All rights reserved. | ||
* | ||
* This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information. | ||
*/ | ||
package com.microsoft.sqlserver.UnitStatement; | ||
|
||
import java.sql.CallableStatement; | ||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.platform.runner.JUnitPlatform; | ||
import org.junit.runner.RunWith; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator; | ||
import com.microsoft.sqlserver.testframework.AbstractTest; | ||
import com.microsoft.sqlserver.testframework.util.RandomUtil; | ||
|
||
@RunWith(JUnitPlatform.class) | ||
public class CallableMixedTest extends AbstractTest { | ||
Connection connection1 = null; | ||
Statement Statement151 = null; | ||
String tableN = RandomUtil.getIdentifier("TFOO3"); | ||
String procN = RandomUtil.getIdentifier("SPFOO3"); | ||
String tableName = AbstractSQLGenerator.escapeIdentifier(tableN); | ||
String procName = AbstractSQLGenerator.escapeIdentifier(procN); | ||
|
||
/** | ||
* Tests Callable mix | ||
* @throws SQLException | ||
*/ | ||
@Test | ||
@DisplayName("Test CallableMix") | ||
public void datatypestest() throws SQLException { | ||
connection1 = DriverManager.getConnection(connectionString); | ||
Statement151 = connection1.createStatement(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
try { | ||
Statement151.executeUpdate("DROP TABLE " + tableName); | ||
Statement151.executeUpdate(" DROP PROCEDURE " + procName); | ||
} | ||
catch (Exception e) { | ||
} | ||
|
||
Statement151.executeUpdate("create table " + tableName + " (c1_int int primary key, col2 int)"); | ||
Statement151.executeUpdate("Insert into " + tableName + " values(0, 1)"); | ||
Statement151.close(); | ||
Statement Statement153 = connection1.createStatement(); | ||
Statement153.executeUpdate("CREATE PROCEDURE " + procName | ||
+ " (@p2_int int, @p2_int_out int OUTPUT, @p4_smallint smallint, @p4_smallint_out smallint OUTPUT) AS begin transaction SELECT * FROM " | ||
+ tableName + " ; SELECT @p2_int_out=@p2_int, @p4_smallint_out=@p4_smallint commit transaction RETURN -2147483648"); | ||
Statement153.close(); | ||
|
||
CallableStatement CallableStatement1 = connection1.prepareCall("{ ? = CALL " + procName + " (?, ?, ?, ?) }"); | ||
CallableStatement1.registerOutParameter((int) 1, (int) 4); | ||
CallableStatement1.setObject((int) 2, Integer.valueOf("31"), (int) 4); | ||
CallableStatement1.registerOutParameter((int) 3, (int) 4); | ||
CallableStatement1.registerOutParameter((int) 5, java.sql.Types.BINARY); | ||
CallableStatement1.registerOutParameter((int) 5, (int) 5); | ||
CallableStatement1.setObject((int) 4, Short.valueOf("-5372"), (int) 5); | ||
|
||
// get results and a value | ||
ResultSet ResultSet1 = CallableStatement1.executeQuery(); | ||
ResultSet1.next(); | ||
|
||
assertEquals(ResultSet1.getInt(1), 0, "Received data not equal to setdata"); | ||
assertEquals(CallableStatement1.getInt((int) 5), -5372, "Received data not equal to setdata"); | ||
|
||
// do nothing and reexecute | ||
ResultSet1 = CallableStatement1.executeQuery(); | ||
// get the param without getting the resultset | ||
ResultSet1 = CallableStatement1.executeQuery(); | ||
assertEquals(CallableStatement1.getInt((int) 1), -2147483648, "Received data not equal to setdata"); | ||
|
||
ResultSet1 = CallableStatement1.executeQuery(); | ||
ResultSet1.next(); | ||
|
||
assertEquals(ResultSet1.getInt(1), 0, "Received data not equal to setdata"); | ||
assertEquals(CallableStatement1.getInt((int) 1), -2147483648, "Received data not equal to setdata"); | ||
assertEquals(CallableStatement1.getInt((int) 5), -5372, "Received data not equal to setdata"); | ||
ResultSet1 = CallableStatement1.executeQuery(); | ||
CallableStatement1.close(); | ||
ResultSet1.close(); | ||
|
||
terminateVariation(); | ||
} | ||
|
||
|
||
private void terminateVariation() throws SQLException { | ||
Statement151 = connection1.createStatement(); | ||
Statement151.executeUpdate("DROP TABLE " + tableName); | ||
Statement151.executeUpdate(" DROP PROCEDURE " + procName); | ||
} | ||
|
||
} |
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.
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.
Unfortunately GitHub Reviews are not getting reflected after code file changes. :(
Here method name is not following lowerCamelCase nomenclature. It should be
dataTypesTest