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

Fix AEv2 tests exclude for reqExternalSetup and cleanup #1247

Merged
merged 18 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.microsoft.sqlserver.jdbc.SQLServerStatement;
import com.microsoft.sqlserver.jdbc.TestResource;
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
import com.microsoft.sqlserver.testframework.Constants;
import com.microsoft.sqlserver.testframework.PrepUtil;

Expand Down Expand Up @@ -850,11 +849,10 @@ public void testAEFMTOnly(String serverName, String url, String protocol) throws
checkAESetup(serverName, url, protocol);
try (SQLServerConnection c = PrepUtil.getConnection(AETestConnectionString + ";useFmtOnly=true", AEInfo);
Statement s = c.createStatement()) {
dropTables(s);
createTable(NUMERIC_TABLE_AE, cekJks, numericTable);
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( "
String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?,"
+ "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?,"
+ "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")";
+ "?,?,?," + "?,?,?," + "?,?,?" + ")";
try (PreparedStatement p = c.prepareStatement(sql)) {
ParameterMetaData pmd = p.getParameterMetaData();
assertTrue(pmd.getParameterCount() == 48);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.microsoft.sqlserver.jdbc.SQLServerStatement;
import com.microsoft.sqlserver.jdbc.TestResource;
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
import com.microsoft.sqlserver.testframework.Constants;
import com.microsoft.sqlserver.testframework.PrepUtil;

Expand Down Expand Up @@ -214,8 +213,8 @@ public void testDateScale5Null(String serverName, String url, String protocol) t

private void testNumeric(String[] numeric) throws SQLException {
try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo);
SQLServerStatement stmt = (SQLServerStatement) con.createStatement(); ResultSet rs = stmt
.executeQuery("select * from " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE))) {
SQLServerStatement stmt = (SQLServerStatement) con.createStatement();
ResultSet rs = stmt.executeQuery("select * from " + NUMERIC_TABLE_AE)) {
int numberOfColumns = rs.getMetaData().getColumnCount();

ArrayList<Integer> skipMax = new ArrayList<>();
Expand All @@ -230,8 +229,8 @@ private void testNumeric(String[] numeric) throws SQLException {

private void testDate(String[] dateNormalCase, String[] dateSetObject) throws Exception {
try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo);
SQLServerStatement stmt = (SQLServerStatement) con.createStatement(); ResultSet rs = stmt
.executeQuery("select * from " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE))) {
SQLServerStatement stmt = (SQLServerStatement) con.createStatement();
ResultSet rs = stmt.executeQuery("select * from " + DATE_TABLE_AE)) {
int numberOfColumns = rs.getMetaData().getColumnCount();

ArrayList<Integer> skipMax = new ArrayList<>();
Expand Down Expand Up @@ -397,8 +396,8 @@ private void testGetDate(ResultSet rs, int numberOfColumns, String[] dates) thro
}

private void populateDate(int scale) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?,"
+ "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")";
String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?,"
+ "?,?,?" + ")";

try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo);
SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql,
Expand Down Expand Up @@ -477,8 +476,8 @@ private void populateDate(int scale) throws SQLException {
}

private void populateDateNormalCaseNull(int scale) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?,"
+ "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")";
String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?,"
+ "?,?,?" + ")";

try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo);
SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql,
Expand Down Expand Up @@ -520,8 +519,7 @@ private void populateDateNormalCaseNull(int scale) throws SQLException {
}

private void populateNumeric(String[] numeric, int precision, int scale) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?,"
+ "?,?,?," + "?,?,?" + ")";
String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?" + ")";
try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo);
SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql,
stmtColEncSetting)) {
Expand Down Expand Up @@ -578,8 +576,7 @@ private void populateNumeric(String[] numeric, int precision, int scale) throws
}

private void populateNumericSetObjectNull(int precision, int scale) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?,"
+ "?,?,?," + "?,?,?" + ")";
String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?" + ")";

try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo);
SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql,
Expand All @@ -606,8 +603,8 @@ private void populateNumericSetObjectNull(int precision, int scale) throws SQLEx
}

private void populateDateSetObjectNull(int scale) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?,"
+ "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")";
String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?,"
+ "?,?,?" + ")";

try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo);
SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.junit.runners.Parameterized;

import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
import com.microsoft.sqlserver.testframework.Constants;
import com.microsoft.sqlserver.testframework.PrepUtil;

Expand Down Expand Up @@ -99,8 +98,7 @@ public void alwaysEncrypted2(String serverName, String url, String protocol) thr
}

private void populateDateTable(Connection connection) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?"
+ ")";
String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?" + ")";
try (PreparedStatement sqlPstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, connection.getHoldability())) {
sqlPstmt.setObject(1, Constants.DATE);
Expand All @@ -111,8 +109,7 @@ private void populateDateTable(Connection connection) throws SQLException {
}

private void populateCharTable(Connection connection) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE) + " values( " + "?,?,?,?,?,?"
+ ")";
String sql = "insert into " + CHAR_TABLE_AE + " values( " + "?,?,?,?,?,?" + ")";
try (PreparedStatement sqlPstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, connection.getHoldability())) {
sqlPstmt.setObject(1, "hi");
Expand All @@ -126,8 +123,7 @@ private void populateCharTable(Connection connection) throws SQLException {
}

private void populateNumericTable(Connection connection) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE)
+ " values(?,?,?,?,?,?,?,?,?)";
String sql = "insert into " + NUMERIC_TABLE_AE + " values(?,?,?,?,?,?,?,?,?)";
try (PreparedStatement sqlPstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, connection.getHoldability())) {
sqlPstmt.setObject(1, true);
Expand All @@ -145,8 +141,7 @@ private void populateNumericTable(Connection connection) throws SQLException {
}

private void populateNumericTableSpecificSetter(Connection connection) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( "
+ "?,?,?,?,?,?,?,?,?" + ")";
String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?,?,?,?,?,?,?" + ")";
try (PreparedStatement sqlPstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, connection.getHoldability())) {
sqlPstmt.setBoolean(1, true);
Expand All @@ -164,8 +159,7 @@ private void populateNumericTableSpecificSetter(Connection connection) throws SQ
}

private void populateNumericTableWithNull(Connection connection) throws SQLException {
String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?"
+ ",?,?,?" + ",?,?,?" + ")";
String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?" + ",?,?,?" + ",?,?,?" + ")";
try (PreparedStatement sqlPstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, connection.getHoldability())) {
sqlPstmt.setObject(1, null, java.sql.Types.BIT);
Expand All @@ -183,8 +177,7 @@ private void populateNumericTableWithNull(Connection connection) throws SQLExcep

private void verifyDateTable(Connection connection) throws SQLException {
try (Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt
.executeQuery("select * from " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE))) {
ResultSet rs = stmt.executeQuery("select * from " + DATE_TABLE_AE)) {
while (rs.next()) {
// VSTS BUG 5268
// assertEquals(date.getTime(), ((Date) rs.getObject(1)).getTime());
Expand All @@ -194,8 +187,7 @@ private void verifyDateTable(Connection connection) throws SQLException {

private void verifyCharTable(Connection connection) throws SQLException {
try (Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt
.executeQuery("select * from " + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE))) {
ResultSet rs = stmt.executeQuery("select * from " + CHAR_TABLE_AE)) {
while (rs.next()) {
assertEquals("hi ", rs.getObject(1));
assertEquals("sample ", rs.getObject(2));
Expand All @@ -209,8 +201,7 @@ private void verifyCharTable(Connection connection) throws SQLException {

private void verifyNumericTable(Connection connection, boolean isNull) throws SQLException {
try (Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt
.executeQuery("select * from " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE))) {
ResultSet rs = stmt.executeQuery("select * from " + NUMERIC_TABLE_AE)) {
while (rs.next()) {
if (isNull) {
assertEquals(null, rs.getObject(1));
Expand Down Expand Up @@ -238,8 +229,8 @@ private void verifyNumericTable(Connection connection, boolean isNull) throws SQ
}

public static void dropTables(Statement stmt) throws SQLException {
TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE), stmt);
TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE), stmt);
TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE), stmt);
TestUtils.dropTableIfExists(DATE_TABLE_AE, stmt);
TestUtils.dropTableIfExists(CHAR_TABLE_AE, stmt);
TestUtils.dropTableIfExists(NUMERIC_TABLE_AE, stmt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public static void setup() throws Exception {
prop = getConfiguredProperty("enclaveServer", null);
if (null == prop) {
// default to server in connection string
String serverName = connectionString.substring(Constants.JDBC_PREFIX.length())
.split(Constants.SEMI_COLON)[0];
String serverName = (connectionString.substring(Constants.JDBC_PREFIX.length())
.split(Constants.SEMI_COLON)[0]).split(":")[0];
enclaveServer = new String[1];
enclaveServer[0] = new String(serverName);
} else {
Expand Down