diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java index 2b988d029..b21e45e9c 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java @@ -75,13 +75,18 @@ public class AESetup extends AbstractTest { protected static boolean isAEv2 = false; - public static final String tableName = RandomUtil.getIdentifier("AETest_"); - public static final String CHAR_TABLE_AE = RandomUtil.getIdentifier("JDBCEncryptedChar"); - public static final String BINARY_TABLE_AE = RandomUtil.getIdentifier("JDBCEncryptedBinary"); - public static final String DATE_TABLE_AE = RandomUtil.getIdentifier("JDBCEncryptedDate"); - public static final String NUMERIC_TABLE_AE = RandomUtil.getIdentifier("JDBCEncryptedNumeric"); - public static final String SCALE_DATE_TABLE_AE = RandomUtil.getIdentifier("JDBCEncryptedScaleDate"); - private static final boolean isSqlLinux = false; + public static final String tableName = TestUtils + .escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("AETest_"))); + public static final String CHAR_TABLE_AE = TestUtils + .escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("JDBCEncryptedChar"))); + public static final String BINARY_TABLE_AE = TestUtils + .escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("JDBCEncryptedBinary"))); + public static final String DATE_TABLE_AE = TestUtils + .escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("JDBCEncryptedDate"))); + public static final String NUMERIC_TABLE_AE = TestUtils.escapeSingleQuotes( + AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("JDBCEncryptedNumeric"))); + public static final String SCALE_DATE_TABLE_AE = TestUtils.escapeSingleQuotes( + AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("JDBCEncryptedScaleDate"))); enum ColumnType { PLAIN, @@ -147,6 +152,9 @@ enum ColumnType { "PlainMoney money", "PlainDecimal2 decimal(28,4)", "PlainNumeric2 numeric(28,4)", "PlainFloat float(30)", "PlainDecimal decimal(30)", "PlainNumeric numeric(30)"}; + // junit test parameters: serverName, enclaveAttestationUrl, enclaveAttestationProtocol + static String[][] param = new String[AbstractTest.enclaveServer.length][3]; + /** * This provides the arguments (serverName, enclaveAttestationUrl, enclaveAttestationProtocol) for the parameterized * tests using MethodSource parameters @@ -154,17 +162,7 @@ enum ColumnType { * @return parameters for the tests * @throws Exception */ - public static String[][] enclaveParams() throws Exception { - setup(); - - String[][] param = new String[AbstractTest.enclaveServer.length][3]; - - for (int i = 0; i < enclaveServer.length; i++) { - param[i][0] = enclaveServer[i]; - param[i][1] = null != enclaveAttestationUrl ? enclaveAttestationUrl[i] : null; - param[i][2] = null != enclaveAttestationProtocol ? enclaveAttestationProtocol[i] : null; - } - + static String[][] enclaveParams() throws Exception { return param; } @@ -175,9 +173,9 @@ public static String[][] enclaveParams() throws Exception { * @param url * @param protocol */ - void setAEConnectionString(String serverName, String url, String protocol) { + static void setAEConnectionString(String serverName, String url, String protocol) { // AEv2 is not supported on Linux servers - if (!isSqlLinux() && null != serverName) { + if (!isSqlLinux() && null != serverName && null != url && null != protocol) { enclaveProperties = "serverName=" + serverName + ";" + Constants.ENCLAVE_ATTESTATIONURL + "=" + url + ";" + Constants.ENCLAVE_ATTESTATIONPROTOCOL + "=" + protocol; AETestConnectionString = connectionString + ";sendTimeAsDateTime=false" + ";columnEncryptionSetting=enabled" @@ -194,14 +192,14 @@ void setAEConnectionString(String serverName, String url, String protocol) { } /** - * Check if AEv2 + * Setup AE connection string and check setup * * @param serverName * @param url * @param protocol * @throws SQLException */ - void checkAEv2(String serverName, String url, String protocol) throws SQLException { + void checkAESetup(String serverName, String url, String protocol) throws Exception { setAEConnectionString(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo)) { @@ -214,26 +212,8 @@ void checkAEv2(String serverName, String url, String protocol) throws SQLExcepti } } - void checkAESetup(String serverName, String url, String protocol) throws Exception { - checkAEv2(serverName, url, protocol); - - createCMK(cmkJks, Constants.JAVA_KEY_STORE_NAME, javaKeyAliases, Constants.CMK_SIGNATURE); - createCEK(cmkJks, cekJks, jksProvider); - - createCMK(cmkAkv, Constants.AZURE_KEY_VAULT_NAME, keyIDs[0], Constants.CMK_SIGNATURE_AKV); - createCEK(cmkAkv, cekAkv, akvProvider); - - createCMK(cmkWin, Constants.WINDOWS_KEY_STORE_NAME, windowsKeyPath, Constants.CMK_SIGNATURE); - createCEK(cmkWin, cekWin, null); - } - @BeforeAll - public static void getProperties() throws Exception { - if (null == applicationClientID || null == applicationKey || null == keyIDs - || (isWindows && null == windowsKeyPath)) { - fail("enclaveProperties: " + enclaveProperties + "\n" + TestResource.getResource("R_reqExternalSetup")); - } - + public static void setupAETest() throws Exception { readFromFile(Constants.JAVA_KEY_STORE_FILENAME, "Alias name"); stmtColEncSetting = SQLServerStatementColumnEncryptionSetting.Enabled; @@ -246,6 +226,32 @@ public static void getProperties() throws Exception { // reset logging to avoid severe logs due to negative testing LogManager.getLogManager().reset(); + + // setup test params and encryption keys on each server + for (int i = 0; i < enclaveServer.length; i++) { + String serverName = enclaveServer[i]; + String url = null != enclaveAttestationUrl ? enclaveAttestationUrl[i] : null; + String protocol = null != enclaveAttestationProtocol ? enclaveAttestationProtocol[i] : null; + + param[i][0] = serverName; + param[i][1] = url; + param[i][2] = protocol; + + setAEConnectionString(serverName, url, protocol); + + createCMK(cmkJks, Constants.JAVA_KEY_STORE_NAME, javaKeyAliases, Constants.CMK_SIGNATURE); + createCEK(cmkJks, cekJks, jksProvider); + + if (null != keyIDs && !keyIDs[0].isEmpty()) { + createCMK(cmkAkv, Constants.AZURE_KEY_VAULT_NAME, keyIDs[0], Constants.CMK_SIGNATURE_AKV); + createCEK(cmkAkv, cekAkv, akvProvider); + } + + if (null != windowsKeyPath) { + createCMK(cmkWin, Constants.WINDOWS_KEY_STORE_NAME, windowsKeyPath, Constants.CMK_SIGNATURE); + createCEK(cmkWin, cekWin, null); + } + } } /** @@ -336,8 +342,8 @@ protected static void createTable(String tableName, String cekName, String table sql += ColumnType.RANDOMIZED.name() + table[i][0] + " " + table[i][1] + String.format(encryptSql, ColumnType.RANDOMIZED.name(), cekName) + ") NULL,"; } - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(tableName), stmt); - sql = String.format(createSql, AbstractSQLGenerator.escapeIdentifier(tableName), sql); + TestUtils.dropTableIfExists(tableName, stmt); + sql = String.format(createSql, tableName, sql); stmt.execute(sql); stmt.execute("DBCC FREEPROCCACHE"); } catch (SQLException e) { @@ -371,7 +377,7 @@ protected static void createPrecisionTable(String tableName, String table[][], S + ") NULL,"; } } - sql = String.format(createSql, AbstractSQLGenerator.escapeIdentifier(tableName), sql); + sql = String.format(createSql, tableName, sql); stmt.execute(sql); stmt.execute("DBCC FREEPROCCACHE"); } catch (SQLException e) { @@ -399,7 +405,7 @@ protected static void createScaleTable(String tableName, String table[][], Strin + String.format(encryptSql, ColumnType.DETERMINISTIC.name(), cekName) + ") NULL,"; } - sql = String.format(createSql, AbstractSQLGenerator.escapeIdentifier(tableName), sql); + sql = String.format(createSql, tableName, sql); stmt.execute(sql); stmt.execute("DBCC FREEPROCCACHE"); } catch (SQLException e) { @@ -574,10 +580,10 @@ private static void createCEK(String cmkName, String cekName, * @throws SQLException */ protected static void dropTables(Statement stmt) throws SQLException { - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE), stmt); + TestUtils.dropTableIfExists(NUMERIC_TABLE_AE, stmt); + TestUtils.dropTableIfExists(CHAR_TABLE_AE, stmt); + TestUtils.dropTableIfExists(BINARY_TABLE_AE, stmt); + TestUtils.dropTableIfExists(DATE_TABLE_AE, stmt); } /** @@ -587,8 +593,8 @@ protected static void dropTables(Statement stmt) throws SQLException { * @throws SQLException */ protected static void populateBinaryNormalCase(LinkedList byteValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + BINARY_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil .getConnection(AETestConnectionString + ";sendTimeAsDateTime=false", AEInfo); @@ -651,8 +657,8 @@ protected static void populateBinaryNormalCase(LinkedList byteValues) th * @throws SQLException */ protected static void populateBinarySetObject(LinkedList byteValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + BINARY_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, stmtColEncSetting)) { @@ -713,8 +719,8 @@ protected static void populateBinarySetObject(LinkedList byteValues) thr * @throws SQLException */ protected static void populateBinarySetObjectWithJDBCType(LinkedList byteValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + BINARY_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -775,8 +781,8 @@ protected static void populateBinarySetObjectWithJDBCType(LinkedList byt * @throws SQLException */ protected static void populateBinaryNullCase() throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + BINARY_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -813,8 +819,8 @@ protected static void populateBinaryNullCase() throws SQLException { * @throws SQLException */ protected static void populateCharNormalCase(String[] charValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + CHAR_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -880,8 +886,8 @@ protected static void populateCharNormalCase(String[] charValues) throws SQLExce * @throws SQLException */ protected static void populateCharSetObject(String[] charValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + CHAR_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -943,8 +949,8 @@ protected static void populateCharSetObject(String[] charValues) throws SQLExcep * @throws SQLException */ protected static void populateCharSetObjectWithJDBCTypes(String[] charValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + CHAR_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1005,8 +1011,8 @@ protected static void populateCharSetObjectWithJDBCTypes(String[] charValues) th * @throws SQLException */ protected static void populateCharNullCase() throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + CHAR_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1059,8 +1065,8 @@ protected static void populateCharNullCase() throws SQLException { * @throws SQLException */ protected static void populateDateNormalCase(LinkedList dateValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1106,8 +1112,7 @@ protected static void populateDateNormalCase(LinkedList dateValues) thro * @throws SQLException */ protected static void populateDateScaleNormalCase(LinkedList dateValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(SCALE_DATE_TABLE_AE) + " values( " - + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + SCALE_DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1141,8 +1146,8 @@ protected static void populateDateScaleNormalCase(LinkedList dateValues) */ protected static void populateDateSetObject(LinkedList dateValues, String setter) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1208,8 +1213,8 @@ else if (setter.equalsIgnoreCase("setwithJDBCType")) * @throws SQLException */ protected void populateDateSetObjectNull() throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1255,8 +1260,8 @@ protected void populateDateSetObjectNull() throws SQLException { * @throws SQLException */ protected static void populateDateNullCase() throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1303,9 +1308,9 @@ protected static void populateDateNullCase() throws SQLException { * @throws SQLException */ protected static void populateNumeric(String[] values) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?," + String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1412,9 +1417,9 @@ protected static void populateNumeric(String[] values) throws SQLException { * @throws SQLException */ protected static void populateNumericSetObject(String[] values) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?," + String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1521,9 +1526,9 @@ protected static void populateNumericSetObject(String[] values) throws SQLExcept * @throws SQLException */ protected static void populateNumericSetObjectWithJDBCTypes(String[] values) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?," + String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1629,9 +1634,9 @@ protected static void populateNumericSetObjectWithJDBCTypes(String[] values) thr * @throws SQLException */ protected static void populateNumericSetObjectNull() throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?," + String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1728,9 +1733,9 @@ protected static void populateNumericSetObjectNull() throws SQLException { * @throws SQLException */ protected static void populateNumericNullCase(String[] values) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?," + String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + + "?,?,?," + "?,?,?," + "?,?,?" + ")"; @@ -1828,9 +1833,9 @@ protected static void populateNumericNullCase(String[] values) throws SQLExcepti * @throws SQLException */ protected static void populateNumericNormalCase(String[] numericValues) throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) + " values( " + "?,?,?," + String sql = "insert into " + NUMERIC_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + + "?,?,?," + "?,?,?," + "?,?,?" + ")"; diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/CallableStatementTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/CallableStatementTest.java index 3d092bc34..eaa9f4897 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/CallableStatementTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/CallableStatementTest.java @@ -20,6 +20,7 @@ import java.util.LinkedList; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -51,32 +52,55 @@ @Tag(Constants.xAzureSQLDB) public class CallableStatementTest extends AESetup { - private static String multiStatementsProcedure = RandomUtil.getIdentifier("multiStatementsProcedure"); - private static String inputProcedure = RandomUtil.getIdentifier("inputProcedure"); - private static String inputProcedure2 = RandomUtil.getIdentifier("inputProcedure2"); - private static String outputProcedure = RandomUtil.getIdentifier("outputProcedure"); - private static String outputProcedure2 = RandomUtil.getIdentifier("outputProcedure2"); - private static String outputProcedure3 = RandomUtil.getIdentifier("outputProcedure3"); - private static String outputProcedure4 = RandomUtil.getIdentifier("outputProcedure4"); - private static String outputProcedureChar = RandomUtil.getIdentifier("outputProcedureChar"); - private static String outputProcedureNumeric = RandomUtil.getIdentifier("outputProcedureNumeric"); - private static String outputProcedureBinary = RandomUtil.getIdentifier("outputProcedureBinary"); - private static String outputProcedureDate = RandomUtil.getIdentifier("outputProcedureDate"); - private static String outputProcedureDateScale = RandomUtil.getIdentifier("outputProcedureDateScale"); - private static String outputProcedureBatch = RandomUtil.getIdentifier("outputProcedureBatch"); - private static String inoutProcedure = RandomUtil.getIdentifier("inoutProcedure"); - private static String mixedProcedure = RandomUtil.getIdentifier("mixedProcedure"); - private static String mixedProcedure2 = RandomUtil.getIdentifier("mixedProcedure2"); - private static String mixedProcedure3 = RandomUtil.getIdentifier("mixedProcedure3"); - private static String mixedProcedureNumericPrcisionScale = RandomUtil - .getIdentifier("mixedProcedureNumericPrcisionScale"); - - private static String table1 = RandomUtil.getIdentifier("StoredProcedure_table1"); - private static String table2 = RandomUtil.getIdentifier("StoredProcedure_table2"); - private static String table3 = RandomUtil.getIdentifier("StoredProcedure_table3"); - private static String table4 = RandomUtil.getIdentifier("StoredProcedure_table4"); - private static String table5 = RandomUtil.getIdentifier("StoredProcedure_table5"); - private static String table6 = RandomUtil.getIdentifier("StoredProcedure_table6"); + private static String multiStatementsProcedure = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("multiStatementsProcedure")); + private static String inputProcedure = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("inputProcedure")); + private static String inputProcedure2 = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("inputProcedure2")); + private static String outputProcedure = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedure")); + private static String outputProcedure2 = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedure2")); + private static String outputProcedure3 = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedure3")); + private static String outputProcedure4 = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedure4")); + private static String outputProcedureChar = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedureChar")); + private static String outputProcedureNumeric = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedureNumeric")); + private static String outputProcedureBinary = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedureBinary")); + private static String outputProcedureDate = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedureDate")); + private static String outputProcedureDateScale = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedureDateScale")); + private static String outputProcedureBatch = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("outputProcedureBatch")); + private static String inoutProcedure = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("inoutProcedure")); + private static String mixedProcedure = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("mixedProcedure")); + private static String mixedProcedure2 = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("mixedProcedure2")); + private static String mixedProcedure3 = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("mixedProcedure3")); + private static String mixedProcedureNumericPrecisionScale = AbstractSQLGenerator + .escapeIdentifier(RandomUtil.getIdentifier("mixedProcedureNumericPrecisionScale")); + + private static String table1 = TestUtils.escapeSingleQuotes( + AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("StoredProcedure_table1"))); + private static String table2 = TestUtils.escapeSingleQuotes( + AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("StoredProcedure_table2"))); + private static String table3 = TestUtils.escapeSingleQuotes( + AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("StoredProcedure_table3"))); + private static String table4 = TestUtils.escapeSingleQuotes( + AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("StoredProcedure_table4"))); + private static String table5 = TestUtils.escapeSingleQuotes( + AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("StoredProcedure_table5"))); + private static String table6 = TestUtils.escapeSingleQuotes( + AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("StoredProcedure_table6"))); private static String[] numericValues; private static LinkedList byteValues; @@ -101,15 +125,20 @@ public class CallableStatementTest extends AESetup { * * @throws SQLException */ - public void initCallableStatementTest() throws Exception { + @BeforeAll + public static void initValues() throws Exception { dropAll(); numericValues = createNumericValues(nullable); byteValues = createBinaryValues(nullable); dateValues = createTemporalTypesCallableStatement(nullable); charValues = createCharValues(nullable); + } + + void initCallableStatementTest() throws Exception { + dropAll(); - createTables(cekJks); + createSPTables(cekJks); populateTable3(); populateTable4(); @@ -150,9 +179,7 @@ public void testInputProcedureNumeric(String serverName, String url, String prot initCallableStatementTest(); createInputProcedure(); - testInputProcedure( - "{call " + AbstractSQLGenerator.escapeIdentifier(inputProcedure) + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}", - numericValues); + testInputProcedure("{call " + inputProcedure + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}", numericValues); } @ParameterizedTest @@ -162,7 +189,7 @@ public void testInputProcedureChar(String serverName, String url, String protoco initCallableStatementTest(); createInputProcedure2(); - testInputProcedure2("{call " + AbstractSQLGenerator.escapeIdentifier(inputProcedure2) + "(?,?,?,?,?,?,?,?)}"); + testInputProcedure2("{call " + inputProcedure2 + "(?,?,?,?,?,?,?,?)}"); } @ParameterizedTest @@ -172,14 +199,10 @@ public void testEncryptedOutputNumericParams(String serverName, String url, Stri initCallableStatementTest(); createOutputProcedure(); - testOutputProcedureRandomOrder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure) + "(?,?,?,?,?,?,?)}", numericValues); - testOutputProcedureInorder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure) + "(?,?,?,?,?,?,?)}", numericValues); - testOutputProcedureReverseOrder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure) + "(?,?,?,?,?,?,?)}", numericValues); - testOutputProcedureRandomOrder( - "exec " + AbstractSQLGenerator.escapeIdentifier(outputProcedure) + " ?,?,?,?,?,?,?", numericValues); + testOutputProcedureRandomOrder("{call " + outputProcedure + "(?,?,?,?,?,?,?)}", numericValues); + testOutputProcedureInorder("{call " + outputProcedure + "(?,?,?,?,?,?,?)}", numericValues); + testOutputProcedureReverseOrder("{call " + outputProcedure + "(?,?,?,?,?,?,?)}", numericValues); + testOutputProcedureRandomOrder("exec " + outputProcedure + " ?,?,?,?,?,?,?", numericValues); } @ParameterizedTest @@ -190,15 +213,9 @@ public void testUnencryptedAndEncryptedNumericOutputParams(String serverName, St initCallableStatementTest(); createOutputProcedure2(); - testOutputProcedure2RandomOrder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure2) + "(?,?,?,?,?,?,?,?,?,?)}", - numericValues); - testOutputProcedure2Inorder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure2) + "(?,?,?,?,?,?,?,?,?,?)}", - numericValues); - testOutputProcedure2ReverseOrder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure2) + "(?,?,?,?,?,?,?,?,?,?)}", - numericValues); + testOutputProcedure2RandomOrder("{call " + outputProcedure2 + "(?,?,?,?,?,?,?,?,?,?)}", numericValues); + testOutputProcedure2Inorder("{call " + outputProcedure2 + "(?,?,?,?,?,?,?,?,?,?)}", numericValues); + testOutputProcedure2ReverseOrder("{call " + outputProcedure2 + "(?,?,?,?,?,?,?,?,?,?)}", numericValues); } @ParameterizedTest @@ -209,9 +226,9 @@ public void testEncryptedOutputParamsFromDifferentTables(String serverName, Stri initCallableStatementTest(); createOutputProcedure3(); - testOutputProcedure3RandomOrder("{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure3) + "(?,?)}"); - testOutputProcedure3Inorder("{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure3) + "(?,?)}"); - testOutputProcedure3ReverseOrder("{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedure3) + "(?,?)}"); + testOutputProcedure3RandomOrder("{call " + outputProcedure3 + "(?,?)}"); + testOutputProcedure3Inorder("{call " + outputProcedure3 + "(?,?)}"); + testOutputProcedure3ReverseOrder("{call " + outputProcedure3 + "(?,?)}"); } @ParameterizedTest @@ -221,8 +238,8 @@ public void testInOutProcedure(String serverName, String url, String protocol) t initCallableStatementTest(); createInOutProcedure(); - testInOutProcedure("{call " + AbstractSQLGenerator.escapeIdentifier(inoutProcedure) + "(?)}"); - testInOutProcedure("exec " + AbstractSQLGenerator.escapeIdentifier(inoutProcedure) + " ?"); + testInOutProcedure("{call " + inoutProcedure + "(?)}"); + testInOutProcedure("exec " + inoutProcedure + " ?"); } @ParameterizedTest @@ -232,7 +249,7 @@ public void testMixedProcedure(String serverName, String url, String protocol) t initCallableStatementTest(); createMixedProcedure(); - testMixedProcedure("{ ? = call " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure) + "(?,?,?)}"); + testMixedProcedure("{ ? = call " + mixedProcedure + "(?,?,?)}"); } @ParameterizedTest @@ -244,9 +261,8 @@ public void testUnencryptedAndEncryptedIOParams(String serverName, String url, S // unencrypted input and output parameter // encrypted input and output parameter createMixedProcedure2(); - testMixedProcedure2RandomOrder( - "{call " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure2) + "(?,?,?,?)}"); - testMixedProcedure2Inorder("{call " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure2) + "(?,?,?,?)}"); + testMixedProcedure2RandomOrder("{call " + mixedProcedure2 + "(?,?,?,?)}"); + testMixedProcedure2Inorder("{call " + mixedProcedure2 + "(?,?,?,?)}"); } @ParameterizedTest @@ -256,11 +272,9 @@ public void testUnencryptedIOParams(String serverName, String url, String protoc initCallableStatementTest(); createMixedProcedure3(); - testMixedProcedure3RandomOrder( - "{call " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure3) + "(?,?,?,?)}"); - testMixedProcedure3Inorder("{call " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure3) + "(?,?,?,?)}"); - testMixedProcedure3ReverseOrder( - "{call " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure3) + "(?,?,?,?)}"); + testMixedProcedure3RandomOrder("{call " + mixedProcedure3 + "(?,?,?,?)}"); + testMixedProcedure3Inorder("{call " + mixedProcedure3 + "(?,?,?,?)}"); + testMixedProcedure3ReverseOrder("{call " + mixedProcedure3 + "(?,?,?,?)}"); } @ParameterizedTest @@ -269,11 +283,10 @@ public void testVariousIOParams(String serverName, String url, String protocol) checkAESetup(serverName, url, protocol); initCallableStatementTest(); - createMixedProcedureNumericPrcisionScale(); - testMixedProcedureNumericPrcisionScaleInorder( - "{call " + AbstractSQLGenerator.escapeIdentifier(mixedProcedureNumericPrcisionScale) + "(?,?,?,?)}"); - testMixedProcedureNumericPrcisionScaleParameterName( - "{call " + AbstractSQLGenerator.escapeIdentifier(mixedProcedureNumericPrcisionScale) + "(?,?,?,?)}"); + createmixedProcedureNumericPrecisionScale(); + testmixedProcedureNumericPrecisionScaleInorder("{call " + mixedProcedureNumericPrecisionScale + "(?,?,?,?)}"); + testmixedProcedureNumericPrecisionScaleParameterName( + "{call " + mixedProcedureNumericPrecisionScale + "(?,?,?,?)}"); } @ParameterizedTest @@ -283,10 +296,8 @@ public void testOutputProcedureChar(String serverName, String url, String protoc initCallableStatementTest(); createOutputProcedureChar(); - testOutputProcedureCharInorder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureChar) + "(?,?,?,?,?,?,?,?,?)}"); - testOutputProcedureCharInorderObject( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureChar) + "(?,?,?,?,?,?,?,?,?)}"); + testOutputProcedureCharInorder("{call " + outputProcedureChar + "(?,?,?,?,?,?,?,?,?)}"); + testOutputProcedureCharInorderObject("{call " + outputProcedureChar + "(?,?,?,?,?,?,?,?,?)}"); } @ParameterizedTest @@ -296,10 +307,9 @@ public void testOutputProcedureNumeric(String serverName, String url, String pro initCallableStatementTest(); createOutputProcedureNumeric(); - testOutputProcedureNumericInorder("{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureNumeric) - + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); - testcoerctionsOutputProcedureNumericInorder("{call " - + AbstractSQLGenerator.escapeIdentifier(outputProcedureNumeric) + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); + testOutputProcedureNumericInorder("{call " + outputProcedureNumeric + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); + testcoerctionsOutputProcedureNumericInorder( + "{call " + outputProcedureNumeric + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); } @ParameterizedTest @@ -309,12 +319,9 @@ public void testOutputProcedureBinary(String serverName, String url, String prot initCallableStatementTest(); createOutputProcedureBinary(); - testOutputProcedureBinaryInorder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureBinary) + "(?,?,?,?,?)}"); - testOutputProcedureBinaryInorderObject( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureBinary) + "(?,?,?,?,?)}"); - testOutputProcedureBinaryInorderString( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureBinary) + "(?,?,?,?,?)}"); + testOutputProcedureBinaryInorder("{call " + outputProcedureBinary + "(?,?,?,?,?)}"); + testOutputProcedureBinaryInorderObject("{call " + outputProcedureBinary + "(?,?,?,?,?)}"); + testOutputProcedureBinaryInorderString("{call " + outputProcedureBinary + "(?,?,?,?,?)}"); } @ParameterizedTest @@ -324,10 +331,8 @@ public void testOutputProcedureDate(String serverName, String url, String protoc initCallableStatementTest(); createOutputProcedureDate(); - testOutputProcedureDateInorder("{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureDate) - + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); - testOutputProcedureDateInorderObject("{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureDate) - + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); + testOutputProcedureDateInorder("{call " + outputProcedureDate + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); + testOutputProcedureDateInorderObject("{call " + outputProcedureDate + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); } @ParameterizedTest @@ -337,10 +342,8 @@ public void testMixedProcedureDateScale(String serverName, String url, String pr initCallableStatementTest(); createMixedProcedureDateScale(); - testMixedProcedureDateScaleInorder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureDateScale) + "(?,?,?,?,?,?)}"); - testMixedProcedureDateScaleWithParameterName( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureDateScale) + "(?,?,?,?,?,?)}"); + testMixedProcedureDateScaleInorder("{call " + outputProcedureDateScale + "(?,?,?,?,?,?)}"); + testMixedProcedureDateScaleWithParameterName("{call " + outputProcedureDateScale + "(?,?,?,?,?,?)}"); } @ParameterizedTest @@ -350,8 +353,7 @@ public void testOutputProcedureBatch(String serverName, String url, String proto initCallableStatementTest(); createOutputProcedureBatch(); - testOutputProcedureBatchInorder( - "{call " + AbstractSQLGenerator.escapeIdentifier(outputProcedureBatch) + "(?,?,?,?)}"); + testOutputProcedureBatchInorder("{call " + outputProcedureBatch + "(?,?,?,?)}"); } @ParameterizedTest @@ -365,51 +367,50 @@ public void testOutputProcedure4(String serverName, String url, String protocol) private static void dropProcedures() throws SQLException { try (Statement stmt = connection.createStatement()) { - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(multiStatementsProcedure), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(inputProcedure), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(inputProcedure2), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedure), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedure2), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedure3), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedure4), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedureChar), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedureNumeric), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedureBinary), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedureDate), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedureDateScale), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(outputProcedureBatch), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(inoutProcedure), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(mixedProcedure), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(mixedProcedure2), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(mixedProcedure3), stmt); - TestUtils.dropProcedureIfExists(AbstractSQLGenerator.escapeIdentifier(mixedProcedureNumericPrcisionScale), - stmt); + TestUtils.dropProcedureIfExists(multiStatementsProcedure, stmt); + TestUtils.dropProcedureIfExists(inputProcedure, stmt); + TestUtils.dropProcedureIfExists(inputProcedure2, stmt); + TestUtils.dropProcedureIfExists(outputProcedure, stmt); + TestUtils.dropProcedureIfExists(outputProcedure2, stmt); + TestUtils.dropProcedureIfExists(outputProcedure3, stmt); + TestUtils.dropProcedureIfExists(outputProcedure4, stmt); + TestUtils.dropProcedureIfExists(outputProcedureChar, stmt); + TestUtils.dropProcedureIfExists(outputProcedureNumeric, stmt); + TestUtils.dropProcedureIfExists(outputProcedureBinary, stmt); + TestUtils.dropProcedureIfExists(outputProcedureDate, stmt); + TestUtils.dropProcedureIfExists(outputProcedureDateScale, stmt); + TestUtils.dropProcedureIfExists(outputProcedureBatch, stmt); + TestUtils.dropProcedureIfExists(inoutProcedure, stmt); + TestUtils.dropProcedureIfExists(mixedProcedure, stmt); + TestUtils.dropProcedureIfExists(mixedProcedure2, stmt); + TestUtils.dropProcedureIfExists(mixedProcedure3, stmt); + TestUtils.dropProcedureIfExists(mixedProcedureNumericPrecisionScale, stmt); } } private static void dropTables() throws SQLException { try (Statement stmt = connection.createStatement()) { - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table1), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table2), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table3), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table4), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table5), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table6), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(SCALE_DATE_TABLE_AE), stmt); + TestUtils.dropTableIfExists(table1, stmt); + TestUtils.dropTableIfExists(table2, stmt); + TestUtils.dropTableIfExists(table3, stmt); + TestUtils.dropTableIfExists(table4, stmt); + TestUtils.dropTableIfExists(CHAR_TABLE_AE, stmt); + TestUtils.dropTableIfExists(NUMERIC_TABLE_AE, stmt); + TestUtils.dropTableIfExists(BINARY_TABLE_AE, stmt); + TestUtils.dropTableIfExists(DATE_TABLE_AE, stmt); + TestUtils.dropTableIfExists(table5, stmt); + TestUtils.dropTableIfExists(table6, stmt); + TestUtils.dropTableIfExists(SCALE_DATE_TABLE_AE, stmt); } } - private static void createTables(String cekName) throws SQLException { + private static void createSPTables(String cekName) throws SQLException { createTable(table1, cekJks, SP_table1); createTable(table2, cekJks, SP_table2); createTable(table3, cekJks, SP_table3); createTable(table4, cekJks, SP_table4); - String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(table5) + " (" + String sql = "create table " + table5 + " (" + "c1 int ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = " + cekJks + ") NULL," + "c2 smallint ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = " @@ -424,7 +425,7 @@ private static void createTables(String cekName) throws SQLException { fail("enclaveProperties: " + enclaveProperties + "\n" + e.getMessage()); } - sql = "create table " + AbstractSQLGenerator.escapeIdentifier(table6) + " (" + sql = "create table " + table6 + " (" + "c1 int ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = " + cekName + ") NULL," + "c2 smallint ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = " @@ -434,8 +435,8 @@ private static void createTables(String cekName) throws SQLException { try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); Statement stmt = con.createStatement()) { - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table5), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table6), stmt); + TestUtils.dropTableIfExists(table5, stmt); + TestUtils.dropTableIfExists(table6, stmt); stmt.execute(sql); } catch (SQLException e) { fail("enclaveProperties: " + enclaveProperties + "\n" + e.getMessage()); @@ -443,7 +444,7 @@ private static void createTables(String cekName) throws SQLException { } private static void populateTable4() throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(table4) + " values( " + "?,?,?" + ")"; + String sql = "insert into " + table4 + " values( " + "?,?,?" + ")"; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); PreparedStatement pstmt = TestUtils.getPreparedStmt(con, sql, stmtColEncSetting)) { @@ -458,9 +459,9 @@ private static void populateTable4() throws SQLException { } private static void populateTable3() throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(table3) + " values( " + "?,?,?," + "?,?,?," + String sql = "insert into " + table3 + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -567,28 +568,24 @@ private static void populateTable3() throws SQLException { private void createMultiInsertionSelection() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(multiStatementsProcedure) - + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" + " DROP PROCEDURE " - + AbstractSQLGenerator.escapeIdentifier(multiStatementsProcedure); + + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" + " DROP PROCEDURE " + multiStatementsProcedure; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(multiStatementsProcedure) + sql = "CREATE PROCEDURE " + multiStatementsProcedure + " (@p0 char(20) = null, @p1 char(20) = null, @p2 char(20) = null, " + "@p3 varchar(50) = null, @p4 varchar(50) = null, @p5 varchar(50) = null)" + " AS" - + " INSERT INTO " + AbstractSQLGenerator.escapeIdentifier(table1) - + " values (@p0,@p1,@p2,@p3,@p4,@p5)" + " INSERT INTO " - + AbstractSQLGenerator.escapeIdentifier(table2) + " values (@p0,@p1,@p2,@p3,@p4,@p5)" - + " SELECT * FROM " + AbstractSQLGenerator.escapeIdentifier(table1) + " SELECT * FROM " - + AbstractSQLGenerator.escapeIdentifier(table2); + + " INSERT INTO " + table1 + " values (@p0,@p1,@p2,@p3,@p4,@p5)" + " INSERT INTO " + table2 + + " values (@p0,@p1,@p2,@p3,@p4,@p5)" + " SELECT * FROM " + table1 + " SELECT * FROM " + table2; stmt.execute(sql); } } private void MultiInsertionSelection() throws SQLException { - String sql = "{call " + AbstractSQLGenerator.escapeIdentifier(multiStatementsProcedure) + " (?,?,?,?,?,?)}"; + String sql = "{call " + multiStatementsProcedure + " (?,?,?,?,?,?)}"; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerCallableStatement callableStatement = (SQLServerCallableStatement) TestUtils .getCallableStmt(con, sql, stmtColEncSetting)) { @@ -641,19 +638,17 @@ private void testGetString(ResultSet rs, int numberOfColumns) throws SQLExceptio private void createInputProcedure() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(inputProcedure) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(inputProcedure); + + " DROP PROCEDURE " + inputProcedure; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(inputProcedure) - + " @p0 int, @p1 decimal(18, 0), " + sql = "CREATE PROCEDURE " + inputProcedure + " @p0 int, @p1 decimal(18, 0), " + "@p2 float, @p3 real, @p4 numeric(18, 0), @p5 smallmoney, @p6 money," + "@p7 bit, @p8 smallint, @p9 bigint, @p10 float(30), @p11 decimal(10,5), @p12 numeric(8,2), " + "@p13 decimal(28,4), @p14 numeric(28,4) " + " AS" + " SELECT top 1 RandomizedInt FROM " - + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE) - + " where DeterministicInt=@p0 and DeterministicDecimalDefault=@p1 and " + + NUMERIC_TABLE_AE + " where DeterministicInt=@p0 and DeterministicDecimalDefault=@p1 and " + " DeterministicFloatDefault=@p2 and DeterministicReal=@p3 and DeterministicNumericDefault=@p4 and" + " DeterministicSmallMoney=@p5 and DeterministicMoney=@p6 and DeterministicBit=@p7 and" + " DeterministicSmallint=@p8 and DeterministicBigint=@p9 and DeterministicFloat=@p10 and" @@ -706,19 +701,18 @@ private void testInputProcedure(String sql, String[] values) throws SQLException private void createInputProcedure2() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(inputProcedure2) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(inputProcedure2); + + " DROP PROCEDURE " + inputProcedure2; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(inputProcedure2) + sql = "CREATE PROCEDURE " + inputProcedure2 + " @p0 varchar(50), @p1 uniqueidentifier, @p2 varchar(max), @p3 nchar(30), @p4 nvarchar(60), @p5 nvarchar(max), " + " @p6 varchar(8000), @p7 nvarchar(4000)" + " AS" + " SELECT top 1 RandomizedVarchar, DeterministicUniqueidentifier, DeterministicVarcharMax, RandomizedNchar, " + " DeterministicNvarchar, DeterministicNvarcharMax, DeterministicVarchar8000, RandomizedNvarchar4000 FROM " - + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE) - + " where DeterministicVarchar = @p0 and DeterministicUniqueidentifier =@p1"; + + CHAR_TABLE_AE + " where DeterministicVarchar = @p0 and DeterministicUniqueidentifier =@p1"; stmt.execute(sql); } @@ -759,16 +753,15 @@ private void testInputProcedure2(String sql) throws SQLException { private void createOutputProcedure3() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedure3) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedure3); + + " DROP PROCEDURE " + outputProcedure3; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedure3) - + " @p0 int OUTPUT, @p1 int OUTPUT " + " AS" + " SELECT top 1 @p0=DeterministicInt FROM " - + AbstractSQLGenerator.escapeIdentifier(table3) + " SELECT top 1 @p1=RandomizedInt FROM " - + AbstractSQLGenerator.escapeIdentifier(table4); + sql = "CREATE PROCEDURE " + outputProcedure3 + " @p0 int OUTPUT, @p1 int OUTPUT " + " AS" + + " SELECT top 1 @p0=DeterministicInt FROM " + table3 + " SELECT top 1 @p1=RandomizedInt FROM " + + table4; stmt.execute(sql); } @@ -850,18 +843,18 @@ private void testOutputProcedure3ReverseOrder(String sql) throws SQLException { private void createOutputProcedure2() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedure2) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedure2); + + " DROP PROCEDURE " + outputProcedure2; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedure2) + sql = "CREATE PROCEDURE " + outputProcedure2 + " @p0 int OUTPUT, @p1 int OUTPUT, @p2 smallint OUTPUT, @p3 smallint OUTPUT, @p4 tinyint OUTPUT, @p5 tinyint OUTPUT, @p6 smallmoney OUTPUT," + " @p7 smallmoney OUTPUT, @p8 money OUTPUT, @p9 money OUTPUT " + " AS" + " SELECT top 1 @p0=PlainInt, @p1=DeterministicInt, @p2=PlainSmallint," + " @p3=RandomizedSmallint, @p4=PlainTinyint, @p5=DeterministicTinyint, @p6=DeterministicSmallMoney, @p7=PlainSmallMoney," - + " @p8=PlainMoney, @p9=DeterministicMoney FROM " + AbstractSQLGenerator.escapeIdentifier(table3); + + " @p8=PlainMoney, @p9=DeterministicMoney FROM " + table3; stmt.execute(sql); } @@ -1030,18 +1023,17 @@ private void testOutputProcedure2ReverseOrder(String sql, String[] values) throw private void createOutputProcedure() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedure) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedure); + + " DROP PROCEDURE " + outputProcedure; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedure) - + " @p0 int OUTPUT, @p1 float OUTPUT, @p2 smallint OUTPUT, " + sql = "CREATE PROCEDURE " + outputProcedure + " @p0 int OUTPUT, @p1 float OUTPUT, @p2 smallint OUTPUT, " + "@p3 bigint OUTPUT, @p4 tinyint OUTPUT, @p5 smallmoney OUTPUT, @p6 money OUTPUT " + " AS" + " SELECT top 1 @p0=RandomizedInt, @p1=DeterministicFloatDefault, @p2=RandomizedSmallint," + " @p3=RandomizedBigint, @p4=DeterministicTinyint, @p5=DeterministicSmallMoney, @p6=DeterministicMoney FROM " - + AbstractSQLGenerator.escapeIdentifier(table3); + + table3; stmt.execute(sql); } @@ -1182,15 +1174,14 @@ private void testOutputProcedureReverseOrder(String sql, String[] values) throws private void createInOutProcedure() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(inoutProcedure) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(inoutProcedure); + + " DROP PROCEDURE " + inoutProcedure; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(inoutProcedure) + " @p0 int OUTPUT" - + " AS" + " SELECT top 1 @p0=DeterministicInt FROM " + AbstractSQLGenerator.escapeIdentifier(table3) - + " where DeterministicInt=@p0"; + sql = "CREATE PROCEDURE " + inoutProcedure + " @p0 int OUTPUT" + " AS" + + " SELECT top 1 @p0=DeterministicInt FROM " + table3 + " where DeterministicInt=@p0"; stmt.execute(sql); } @@ -1217,16 +1208,14 @@ private void testInOutProcedure(String sql) throws SQLException { private void createMixedProcedure() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(mixedProcedure) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure); + + " DROP PROCEDURE " + mixedProcedure; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure) - + " @p0 int OUTPUT, @p1 float OUTPUT, @p3 decimal " + " AS" - + " SELECT top 1 @p0=DeterministicInt2, @p1=RandomizedFloatDefault FROM " - + AbstractSQLGenerator.escapeIdentifier(table3) + sql = "CREATE PROCEDURE " + mixedProcedure + " @p0 int OUTPUT, @p1 float OUTPUT, @p3 decimal " + " AS" + + " SELECT top 1 @p0=DeterministicInt2, @p1=RandomizedFloatDefault FROM " + table3 + " where DeterministicInt=@p0 and DeterministicDecimalDefault=@p3" + " return 123"; stmt.execute(sql); @@ -1265,16 +1254,14 @@ private void testMixedProcedure(String sql) throws SQLException { private void createMixedProcedure2() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(mixedProcedure2) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure2); + + " DROP PROCEDURE " + mixedProcedure2; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure2) - + " @p0 int OUTPUT, @p1 float OUTPUT, @p3 int, @p4 float " + " AS" - + " SELECT top 1 @p0=DeterministicInt, @p1=PlainFloatDefault FROM " - + AbstractSQLGenerator.escapeIdentifier(table3) + sql = "CREATE PROCEDURE " + mixedProcedure2 + " @p0 int OUTPUT, @p1 float OUTPUT, @p3 int, @p4 float " + + " AS" + " SELECT top 1 @p0=DeterministicInt, @p1=PlainFloatDefault FROM " + table3 + " where PlainInt=@p3 and DeterministicFloatDefault=@p4"; stmt.execute(sql); @@ -1341,16 +1328,16 @@ private void testMixedProcedure2Inorder(String sql) throws SQLException { private void createMixedProcedure3() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(mixedProcedure3) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure3); + + " DROP PROCEDURE " + mixedProcedure3; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(mixedProcedure3) + sql = "CREATE PROCEDURE " + mixedProcedure3 + " @p0 bigint OUTPUT, @p1 float OUTPUT, @p2 int OUTPUT, @p3 smallint" + " AS" - + " SELECT top 1 @p0=PlainBigint, @p1=PlainFloatDefault FROM " - + AbstractSQLGenerator.escapeIdentifier(table3) + " where PlainInt=@p2 and PlainSmallint=@p3"; + + " SELECT top 1 @p0=PlainBigint, @p1=PlainFloatDefault FROM " + table3 + + " where PlainInt=@p2 and PlainSmallint=@p3"; stmt.execute(sql); } @@ -1434,28 +1421,27 @@ private void testMixedProcedure3ReverseOrder(String sql) throws SQLException { } } - private void createMixedProcedureNumericPrcisionScale() throws SQLException { + private void createmixedProcedureNumericPrecisionScale() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" - + TestUtils.escapeSingleQuotes(mixedProcedureNumericPrcisionScale) + + TestUtils.escapeSingleQuotes(mixedProcedureNumericPrecisionScale) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" + " DROP PROCEDURE " - + AbstractSQLGenerator.escapeIdentifier(mixedProcedureNumericPrcisionScale); + + mixedProcedureNumericPrecisionScale; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(mixedProcedureNumericPrcisionScale) + sql = "CREATE PROCEDURE " + mixedProcedureNumericPrecisionScale + " @p1 decimal(18,0) OUTPUT, @p2 decimal(10,5) OUTPUT, @p3 numeric(18, 0) OUTPUT, @p4 numeric(8,2) OUTPUT " + " AS" + " SELECT top 1 @p1=RandomizedDecimalDefault, @p2=DeterministicDecimal," - + " @p3=RandomizedNumericDefault, @p4=DeterministicNumeric FROM " - + AbstractSQLGenerator.escapeIdentifier(table3) + + " @p3=RandomizedNumericDefault, @p4=DeterministicNumeric FROM " + table3 + " where DeterministicDecimal=@p2 and DeterministicNumeric=@p4" + " return 123"; stmt.execute(sql); } } - private void testMixedProcedureNumericPrcisionScaleInorder(String sql) throws SQLException { + private void testmixedProcedureNumericPrecisionScaleInorder(String sql) throws SQLException { try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerCallableStatement callableStatement = (SQLServerCallableStatement) TestUtils @@ -1486,7 +1472,7 @@ private void testMixedProcedureNumericPrcisionScaleInorder(String sql) throws SQ } } - private void testMixedProcedureNumericPrcisionScaleParameterName(String sql) throws SQLException { + private void testmixedProcedureNumericPrecisionScaleParameterName(String sql) throws SQLException { try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerCallableStatement callableStatement = (SQLServerCallableStatement) TestUtils @@ -1520,19 +1506,19 @@ private void testMixedProcedureNumericPrcisionScaleParameterName(String sql) thr private void createOutputProcedureChar() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedureChar) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureChar); + + " DROP PROCEDURE " + outputProcedureChar; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureChar) + sql = "CREATE PROCEDURE " + outputProcedureChar + " @p0 char(20) OUTPUT,@p1 varchar(50) OUTPUT,@p2 nchar(30) OUTPUT," + "@p3 nvarchar(60) OUTPUT, @p4 uniqueidentifier OUTPUT, @p5 varchar(max) OUTPUT, @p6 nvarchar(max) OUTPUT, @p7 varchar(8000) OUTPUT, @p8 nvarchar(4000) OUTPUT" + " AS" + " SELECT top 1 @p0=DeterministicChar,@p1=RandomizedVarChar,@p2=RandomizedNChar," + " @p3=DeterministicNVarChar, @p4=DeterministicUniqueidentifier, @p5=DeterministicVarcharMax," + " @p6=DeterministicNvarcharMax, @p7=DeterministicVarchar8000, @p8=RandomizedNvarchar4000 FROM " - + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE); + + CHAR_TABLE_AE; stmt.execute(sql); } @@ -1644,14 +1630,13 @@ private void testOutputProcedureCharInorderObject(String sql) throws SQLExceptio private void createOutputProcedureNumeric() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedureNumeric) - + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" + " DROP PROCEDURE " - + AbstractSQLGenerator.escapeIdentifier(outputProcedureNumeric); + + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" + " DROP PROCEDURE " + outputProcedureNumeric; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureNumeric) + sql = "CREATE PROCEDURE " + outputProcedureNumeric + " @p0 bit OUTPUT, @p1 tinyint OUTPUT, @p2 smallint OUTPUT, @p3 int OUTPUT," + " @p4 bigint OUTPUT, @p5 float OUTPUT, @p6 float(30) output, @p7 real output, @p8 decimal(18, 0) output, @p9 decimal(10,5) output," + " @p10 numeric(18, 0) output, @p11 numeric(8,2) output, @p12 smallmoney output, @p13 money output, @p14 decimal(28,4) output, @p15 numeric(28,4) output" @@ -1659,8 +1644,7 @@ private void createOutputProcedureNumeric() throws SQLException { + " @p3=RandomizedInt, @p4=DeterministicBigint, @p5=RandomizedFloatDefault, @p6=DeterministicFloat," + " @p7=RandomizedReal, @p8=DeterministicDecimalDefault, @p9=RandomizedDecimal," + " @p10=DeterministicNumericDefault, @p11=RandomizedNumeric, @p12=RandomizedSmallMoney, @p13=DeterministicMoney," - + " @p14=DeterministicDecimal2, @p15=DeterministicNumeric2 FROM " - + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE); + + " @p14=DeterministicDecimal2, @p15=DeterministicNumeric2 FROM " + NUMERIC_TABLE_AE; stmt.execute(sql); } @@ -2041,18 +2025,17 @@ private Object getxxx(int ordinal, Class coercion, private void createOutputProcedureBinary() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedureBinary) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureBinary); + + " DROP PROCEDURE " + outputProcedureBinary; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureBinary) + sql = "CREATE PROCEDURE " + outputProcedureBinary + " @p0 binary(20) OUTPUT,@p1 varbinary(50) OUTPUT,@p2 varbinary(max) OUTPUT," + " @p3 binary(512) OUTPUT,@p4 varbinary(8000) OUTPUT " + " AS" + " SELECT top 1 @p0=RandomizedBinary,@p1=DeterministicVarbinary,@p2=DeterministicVarbinaryMax," - + " @p3=DeterministicBinary512,@p4=DeterministicBinary8000 FROM " - + AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE); + + " @p3=DeterministicBinary512,@p4=DeterministicBinary8000 FROM " + BINARY_TABLE_AE; stmt.execute(sql); } @@ -2188,8 +2171,7 @@ private void testOutputProcedureBinaryInorderString(String sql) throws SQLExcept } protected static void createDateTableCallableStatement(String cekName) throws SQLException { - String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " (" - + "PlainDate date null," + String sql = "create table " + DATE_TABLE_AE + " (" + "PlainDate date null," + "RandomizedDate date ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = " + cekName + ") NULL," + "DeterministicDate date ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = " @@ -2247,7 +2229,7 @@ protected static void createDateTableCallableStatement(String cekName) throws SQ try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE), stmt); + TestUtils.dropTableIfExists(DATE_TABLE_AE, stmt); stmt.execute(sql); stmt.execute("DBCC FREEPROCCACHE"); } catch (SQLException e) { @@ -2282,8 +2264,8 @@ private static LinkedList createTemporalTypesCallableStatement(boolean n } private static void populateDateNormalCase() throws SQLException { - String sql = "insert into " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE) + " values( " + "?,?,?," - + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; + String sql = "insert into " + DATE_TABLE_AE + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")"; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement sqlPstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -2340,13 +2322,13 @@ private static void populateDateNormalCase() throws SQLException { private void createOutputProcedureDate() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedureDate) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureDate); + + " DROP PROCEDURE " + outputProcedureDate; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureDate) + sql = "CREATE PROCEDURE " + outputProcedureDate + " @p0 date OUTPUT, @p01 date OUTPUT, @p1 datetime2 OUTPUT, @p11 datetime2 OUTPUT," + " @p2 datetimeoffset OUTPUT, @p21 datetimeoffset OUTPUT, @p3 time OUTPUT, @p31 time OUTPUT, @p4 datetime OUTPUT, @p41 datetime OUTPUT," + " @p5 smalldatetime OUTPUT, @p51 smalldatetime OUTPUT, @p6 datetime2(2) OUTPUT, @p61 datetime2(2) OUTPUT, @p7 time(2) OUTPUT, @p71 time(2) OUTPUT, " @@ -2356,8 +2338,7 @@ private void createOutputProcedureDate() throws SQLException { + " @p3=PlainTimeDefault,@p31=DeterministicTimeDefault," + " @p4=PlainDateTime,@p41=DeterministicDateTime, @p5=PlainSmallDateTime,@p51=RandomizedSmallDateTime, " + " @p6=PlainDatetime2,@p61=RandomizedDatetime2, @p7=PlainTime,@p71=Deterministictime, " - + " @p8=PlainDatetimeoffset, @p81=RandomizedDatetimeoffset" + " FROM " - + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE); + + " @p8=PlainDatetimeoffset, @p81=RandomizedDatetimeoffset" + " FROM " + DATE_TABLE_AE; stmt.execute(sql); } @@ -2468,7 +2449,7 @@ private void testOutputProcedureDateInorderObject(String sql) throws SQLExceptio private void createOutputProcedureBatch() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedureBatch) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureBatch); + + " DROP PROCEDURE " + outputProcedureBatch; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { @@ -2476,13 +2457,12 @@ private void createOutputProcedureBatch() throws SQLException { // If a procedure contains more than one SQL statement, it is considered // to be a batch of SQL statements. - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureBatch) + sql = "CREATE PROCEDURE " + outputProcedureBatch + " @p0 int OUTPUT, @p1 float OUTPUT, @p2 smallint OUTPUT, @p3 smallmoney OUTPUT " + " AS" - + " select top 1 @p0=RandomizedInt FROM " + AbstractSQLGenerator.escapeIdentifier(table3) - + " select top 1 @p1=DeterministicFloatDefault FROM " - + AbstractSQLGenerator.escapeIdentifier(table3) + " select top 1 @p2=RandomizedSmallint FROM " - + AbstractSQLGenerator.escapeIdentifier(table3) + " select top 1 @p3=DeterministicSmallMoney FROM " - + AbstractSQLGenerator.escapeIdentifier(table3); + + " select top 1 @p0=RandomizedInt FROM " + table3 + + " select top 1 @p1=DeterministicFloatDefault FROM " + table3 + + " select top 1 @p2=RandomizedSmallint FROM " + table3 + + " select top 1 @p3=DeterministicSmallMoney FROM " + table3; stmt.execute(sql); } @@ -2519,20 +2499,18 @@ private void testOutputProcedureBatchInorder(String sql) throws SQLException { private void createOutputProcedure4() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedure4) + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" - + " DROP PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedure4); + + " DROP PROCEDURE " + outputProcedure4; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "create procedure " + AbstractSQLGenerator.escapeIdentifier(outputProcedure4) + sql = "create procedure " + outputProcedure4 + " @in1 int, @in2 smallint, @in3 bigint, @in4 int, @in5 smallint, @in6 bigint, @out1 int output, @out2 smallint output, @out3 bigint output, @out4 int output, @out5 smallint output, @out6 bigint output" - + " as " + " insert into " + AbstractSQLGenerator.escapeIdentifier(table5) - + " values (@in1, @in2, @in3)" + " insert into " + AbstractSQLGenerator.escapeIdentifier(table6) - + " values (@in4, @in5, @in6)" + " select * from " + AbstractSQLGenerator.escapeIdentifier(table5) - + " select * from " + AbstractSQLGenerator.escapeIdentifier(table6) - + " select @out1 = c1, @out2=c2, @out3=c3 from " + AbstractSQLGenerator.escapeIdentifier(table5) - + " select @out4 = c1, @out5=c2, @out6=c3 from " + AbstractSQLGenerator.escapeIdentifier(table6); + + " as " + " insert into " + table5 + " values (@in1, @in2, @in3)" + " insert into " + table6 + + " values (@in4, @in5, @in6)" + " select * from " + table5 + " select * from " + table6 + + " select @out1 = c1, @out2=c2, @out3=c3 from " + table5 + + " select @out4 = c1, @out5=c2, @out6=c3 from " + table6; stmt.execute(sql); } @@ -2541,20 +2519,17 @@ private void createOutputProcedure4() throws SQLException { private void createMixedProcedureDateScale() throws SQLException { String sql = " IF EXISTS (select * from sysobjects where id = object_id(N'" + TestUtils.escapeSingleQuotes(outputProcedureDateScale) - + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" + " DROP PROCEDURE " - + AbstractSQLGenerator.escapeIdentifier(outputProcedureDateScale); + + "') and OBJECTPROPERTY(id, N'IsProcedure') = 1)" + " DROP PROCEDURE " + outputProcedureDateScale; try (Connection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { stmt.execute(sql); - sql = "CREATE PROCEDURE " + AbstractSQLGenerator.escapeIdentifier(outputProcedureDateScale) - + " @p1 datetime2(2) OUTPUT, @p2 datetime2(2) OUTPUT," + sql = "CREATE PROCEDURE " + outputProcedureDateScale + " @p1 datetime2(2) OUTPUT, @p2 datetime2(2) OUTPUT," + " @p3 time(2) OUTPUT, @p4 time(2) OUTPUT, @p5 datetimeoffset(2) OUTPUT, @p6 datetimeoffset(2) OUTPUT " + " AS" + " SELECT top 1 @p1=DeterministicDatetime2,@p2=RandomizedDatetime2,@p3=DeterministicTime,@p4=RandomizedTime," - + " @p5=DeterministicDatetimeoffset,@p6=RandomizedDatetimeoffset " + " FROM " - + AbstractSQLGenerator.escapeIdentifier(SCALE_DATE_TABLE_AE) + + " @p5=DeterministicDatetimeoffset,@p6=RandomizedDatetimeoffset " + " FROM " + SCALE_DATE_TABLE_AE + " where DeterministicDatetime2 = @p1 and DeterministicTime = @p3 and DeterministicDatetimeoffset=@p5"; stmt.execute(sql); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/EnclaveTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/EnclaveTest.java index bb7005a6e..65f5aab06 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/EnclaveTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/EnclaveTest.java @@ -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; @@ -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); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/JDBCEncryptionDecryptionTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/JDBCEncryptionDecryptionTest.java index 4c74d3835..9c8b8b4b6 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/JDBCEncryptionDecryptionTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/JDBCEncryptionDecryptionTest.java @@ -41,7 +41,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; @@ -382,6 +381,7 @@ public void testCharSpecificSetter(String serverName, String url, String protoco */ @ParameterizedTest @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) public void testCharSpecificSetterWindows(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); @@ -395,6 +395,25 @@ public void testCharSpecificSetterWindows(String serverName, String url, String } } + /** + * Junit test case for char set object for string values using AKV + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testCharSetObjectAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + String[] values = createCharValues(nullable); + + testChars(stmt, cekAkv, charTable, values, TestCase.SETOBJECT, false); + } + } + /** * Junit test case for char set object for string values * @@ -410,7 +429,6 @@ public void testCharSetObject(String serverName, String url, String protocol) th String[] values = createCharValues(nullable); testChars(stmt, cekJks, charTable, values, TestCase.SETOBJECT, false); - testChars(stmt, cekAkv, charTable, values, TestCase.SETOBJECT, false); } } @@ -421,513 +439,971 @@ public void testCharSetObject(String serverName, String url, String protocol) th */ @ParameterizedTest @MethodSource("enclaveParams") - public void testCharSetObjectWithJDBCTypes(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testCharSetObjectWithJDBCTypesAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { String[] values = createCharValues(nullable); - testChars(stmt, cekJks, charTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); testChars(stmt, cekAkv, charTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); } } /** - * Junit test case for char set string for null values + * Junit test case for char set object for jdbc string values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testCharSpecificSetterNull(String serverName, String url, String protocol) throws Exception { + public void testCharSetObjectWithJDBCTypes(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - String[] values = {null, null, null, null, null, null, null, null, null}; + String[] values = createCharValues(nullable); - testChars(stmt, cekJks, charTable, values, TestCase.NORMAL, false); - testChars(stmt, cekAkv, charTable, values, TestCase.NORMAL, false); + testChars(stmt, cekJks, charTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); } } /** - * Junit test case for char set object for null values + * Junit test case for char set string for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testCharSetObjectNull(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testCharSpecificSetterNullAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { String[] values = {null, null, null, null, null, null, null, null, null}; - testChars(stmt, cekJks, charTable, values, TestCase.SETOBJECT, false); - testChars(stmt, cekAkv, charTable, values, TestCase.SETOBJECT, false); + testChars(stmt, cekAkv, charTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for char set null for null values + * Junit test case for char set string for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testCharSetNull(String serverName, String url, String protocol) throws Exception { + public void testCharSpecificSetterNull(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { String[] values = {null, null, null, null, null, null, null, null, null}; - testChars(stmt, cekJks, charTable, values, TestCase.NULL, false); - testChars(stmt, cekAkv, charTable, values, TestCase.NULL, false); + testChars(stmt, cekJks, charTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for binary set binary for binary values + * Junit test case for char set object for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testBinarySpecificSetter(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testCharSetObjectNullAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createBinaryValues(false); + String[] values = {null, null, null, null, null, null, null, null, null}; - testBinaries(stmt, cekJks, binaryTable, values, TestCase.NORMAL, false); - testBinaries(stmt, cekAkv, binaryTable, values, TestCase.NORMAL, false); + testChars(stmt, cekAkv, charTable, values, TestCase.SETOBJECT, false); } } /** - * Junit test case for binary set binary for binary values using windows certificate store + * Junit test case for char set object for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testBinarySpecificSetterWindows(String serverName, String url, String protocol) throws Exception { - org.junit.Assume.assumeTrue(isWindows); - + public void testCharSetObjectNull(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createBinaryValues(false); + String[] values = {null, null, null, null, null, null, null, null, null}; - testBinaries(stmt, cekWin, binaryTable, values, TestCase.NORMAL, false); + testChars(stmt, cekJks, charTable, values, TestCase.SETOBJECT, false); } } /** - * Junit test case for binary set object for binary values + * Junit test case for char set null for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testBinarySetobject(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testCharSetNullAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createBinaryValues(false); + String[] values = {null, null, null, null, null, null, null, null, null}; - testBinaries(stmt, cekJks, binaryTable, values, TestCase.SETOBJECT, false); - testBinaries(stmt, cekAkv, binaryTable, values, TestCase.SETOBJECT, false); + testChars(stmt, cekAkv, charTable, values, TestCase.NULL, false); } } /** - * Junit test case for binary set null for binary values + * Junit test case for char set null for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testBinarySetNull(String serverName, String url, String protocol) throws Exception { + public void testCharSetNull(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createBinaryValues(true); + String[] values = {null, null, null, null, null, null, null, null, null}; - testBinaries(stmt, cekJks, binaryTable, values, TestCase.NULL, false); - testBinaries(stmt, cekAkv, binaryTable, values, TestCase.NULL, false); + testChars(stmt, cekJks, charTable, values, TestCase.NULL, false); } } /** - * Junit test case for binary set binary for null values + * Junit test case for binary set binary for binary values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testBinarySpecificSetterNull(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testBinarySpecificSetterAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createBinaryValues(true); + LinkedList values = createBinaryValues(false); - testBinaries(stmt, cekJks, binaryTable, values, TestCase.NORMAL, false); testBinaries(stmt, cekAkv, binaryTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for binary set object for null values + * Junit test case for binary set binary for binary values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testBinarysetObjectNull(String serverName, String url, String protocol) throws Exception { + public void testBinarySpecificSetter(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createBinaryValues(true); + LinkedList values = createBinaryValues(false); - testBinaries(stmt, cekJks, binaryTable, values, TestCase.SETOBJECT_NULL, false); - testBinaries(stmt, cekAkv, binaryTable, values, TestCase.SETOBJECT_NULL, false); + testBinaries(stmt, cekJks, binaryTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for binary set object for jdbc type binary values + * Junit test case for binary set binary for binary values using windows certificate store * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testBinarySetObjectWithJDBCTypes(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testBinarySpecificSetterWindows(String serverName, String url, String protocol) throws Exception { + org.junit.Assume.assumeTrue(isWindows); + checkAESetup(serverName, url, protocol); + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { LinkedList values = createBinaryValues(false); - testBinaries(stmt, cekJks, binaryTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); - testBinaries(stmt, cekAkv, binaryTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); + testBinaries(stmt, cekWin, binaryTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for date set date for date values + * Junit test case for binary set object for binary values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testDateSpecificSetter(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testBinarySetobjectAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createTemporalTypes(nullable); + LinkedList values = createBinaryValues(false); - testDates(stmt, cekJks, dateTable, values, TestCase.NORMAL, false); - testDates(stmt, cekAkv, dateTable, values, TestCase.NORMAL, false); + testBinaries(stmt, cekAkv, binaryTable, values, TestCase.SETOBJECT, false); } } /** - * Junit test case for date set date for date values using windows certificate store + * Junit test case for binary set object for binary values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testDateSpecificSetterWindows(String serverName, String url, String protocol) throws Exception { - org.junit.Assume.assumeTrue(isWindows); - + public void testBinarySetobject(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createTemporalTypes(nullable); + LinkedList values = createBinaryValues(false); - testDates(stmt, cekWin, dateTable, values, TestCase.NORMAL, false); + testBinaries(stmt, cekJks, binaryTable, values, TestCase.SETOBJECT, false); } } /** - * Junit test case for date set object for date values + * Junit test case for binary set null for binary values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testDateSetObject(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testBinarySetNullAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createTemporalTypes(nullable); + LinkedList values = createBinaryValues(true); - testDates(stmt, cekJks, dateTable, values, TestCase.SETOBJECT, false); - testDates(stmt, cekAkv, dateTable, values, TestCase.SETOBJECT, false); + testBinaries(stmt, cekAkv, binaryTable, values, TestCase.NULL, false); } } /** - * Junit test case for date set object for java date values + * Junit test case for binary set null for binary values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testDateSetObjectWithJavaType(String serverName, String url, String protocol) throws Exception { + public void testBinarySetNull(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createTemporalTypes(nullable); + LinkedList values = createBinaryValues(true); - testDates(stmt, cekJks, dateTable, values, TestCase.SETOBJECT_WITH_JAVATYPES, false); - testDates(stmt, cekAkv, dateTable, values, TestCase.SETOBJECT_WITH_JAVATYPES, false); + testBinaries(stmt, cekJks, binaryTable, values, TestCase.NULL, false); } } /** - * Junit test case for date set object for jdbc date values + * Junit test case for binary set binary for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testDateSetObjectWithJDBCType(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testBinarySpecificSetterNullAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createTemporalTypes(nullable); + LinkedList values = createBinaryValues(true); - testDates(stmt, cekJks, dateTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); - testDates(stmt, cekAkv, dateTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); + testBinaries(stmt, cekAkv, binaryTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for date set date for min/max date values + * Junit test case for binary set binary for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testDateSpecificSetterMinMaxValue(String serverName, String url, String protocol) throws Exception { + public void testBinarySpecificSetterNull(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - RandomData.returnMinMax = true; - LinkedList values = createTemporalTypes(nullable); + LinkedList values = createBinaryValues(true); - testDates(stmt, cekJks, dateTable, values, TestCase.NORMAL, false); - testDates(stmt, cekAkv, dateTable, values, TestCase.NORMAL, false); + testBinaries(stmt, cekJks, binaryTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for date set date for null values + * Junit test case for binary set object for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testDateSetNull(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testBinarysetObjectNullAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - RandomData.returnNull = true; - nullable = true; - LinkedList values = createTemporalTypes(nullable); + LinkedList values = createBinaryValues(true); - testDates(stmt, cekJks, dateTable, values, TestCase.NULL, false); - testDates(stmt, cekAkv, dateTable, values, TestCase.NULL, false); + testBinaries(stmt, cekAkv, binaryTable, values, TestCase.SETOBJECT_NULL, false); } - - nullable = false; - RandomData.returnNull = false; } /** - * Junit test case for date set object for null values + * Junit test case for binary set object for null values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testDateSetObjectNull(String serverName, String url, String protocol) throws Exception { + public void testBinarysetObjectNull(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); - RandomData.returnNull = true; - nullable = true; - try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - LinkedList values = createTemporalTypes(nullable); + LinkedList values = createBinaryValues(true); - testDates(stmt, cekJks, dateTable, values, TestCase.SETOBJECT_NULL, false); - testDates(stmt, cekAkv, dateTable, values, TestCase.SETOBJECT_NULL, false); + testBinaries(stmt, cekJks, binaryTable, values, TestCase.SETOBJECT_NULL, false); } - - nullable = false; - RandomData.returnNull = false; } /** - * Junit test case for numeric set numeric for numeric values + * Junit test case for binary set object for jdbc type binary values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testNumericSpecificSetter(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testBinarySetObjectWithJDBCTypesAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); - try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createBinaryValues(false); - String[] values1 = createNumericValues(nullable); - String[] values2 = new String[values1.length]; - System.arraycopy(values1, 0, values2, 0, values1.length); - - testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NORMAL, false); - testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NORMAL, false); + testBinaries(stmt, cekAkv, binaryTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); } } /** - * Junit test case for numeric set numeric for numeric values using windows certificate store + * Junit test case for binary set object for jdbc type binary values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testNumericSpecificSetterWindows(String serverName, String url, String protocol) throws Exception { - org.junit.Assume.assumeTrue(isWindows); - + public void testBinarySetObjectWithJDBCTypes(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); - try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createBinaryValues(false); - String[] values1 = createNumericValues(nullable); - String[] values2 = new String[values1.length]; - System.arraycopy(values1, 0, values2, 0, values1.length); - - testNumerics(stmt, cekWin, numericTable, values1, values2, TestCase.NORMAL, false); + testBinaries(stmt, cekJks, binaryTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); } } /** - * Junit test case for numeric set object for numeric values + * Junit test case for date set date for date values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testNumericSetObject(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testDateSpecificSetterAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - String[] values1 = createNumericValues(nullable); - String[] values2 = new String[values1.length]; - System.arraycopy(values1, 0, values2, 0, values1.length); + LinkedList values = createTemporalTypes(nullable); - testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.SETOBJECT, false); - testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.SETOBJECT, false); + testDates(stmt, cekAkv, dateTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for numeric set object for jdbc type numeric values + * Junit test case for date set date for date values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testNumericSetObjectWithJDBCTypes(String serverName, String url, String protocol) throws Exception { + public void testDateSpecificSetter(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - String[] values1 = createNumericValues(nullable); - String[] values2 = new String[values1.length]; - System.arraycopy(values1, 0, values2, 0, values1.length); + LinkedList values = createTemporalTypes(nullable); - testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.SETOBJECT_WITH_JDBCTYPES, false); - testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.SETOBJECT_WITH_JDBCTYPES, false); + testDates(stmt, cekJks, dateTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for numeric set numeric for max numeric values + * Junit test case for date set date for date values using windows certificate store * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testNumericSpecificSetterMaxValue(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testDateSpecificSetterWindows(String serverName, String url, String protocol) throws Exception { + org.junit.Assume.assumeTrue(isWindows); + checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createTemporalTypes(nullable); - String[] values1 = {Boolean.TRUE.toString(), "255", "32767", "2147483647", "9223372036854775807", - "1.79E308", "1.123", "3.4E38", "999999999999999999", "12345.12345", "999999999999999999", - "567812.78", "214748.3647", "922337203685477.5807", "999999999999999999999999.9999", - "999999999999999999999999.9999"}; - String[] values2 = {Boolean.TRUE.toString(), "255", "32767", "2147483647", "9223372036854775807", - "1.79E308", "1.123", "3.4E38", "999999999999999999", "12345.12345", "999999999999999999", - "567812.78", "214748.3647", "922337203685477.5807", "999999999999999999999999.9999", - "999999999999999999999999.9999"}; - - testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NORMAL, false); - testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NORMAL, false); + testDates(stmt, cekWin, dateTable, values, TestCase.NORMAL, false); } } /** - * Junit test case for numeric set numeric for min numeric values + * Junit test case for date set object for date values * * @throws SQLException */ @ParameterizedTest @MethodSource("enclaveParams") - public void testNumericSpecificSetterMinValue(String serverName, String url, String protocol) throws Exception { + @Tag(Constants.reqExternalSetup) + public void testDateSetObjectAkv(String serverName, String url, String protocol) throws Exception { checkAESetup(serverName, url, protocol); try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { - String[] values1 = {Boolean.FALSE.toString(), "0", "-32768", "-2147483648", "-9223372036854775808", - "-1.79E308", "1.123", "-3.4E38", "999999999999999999", "12345.12345", "999999999999999999", - "567812.78", "-214748.3648", "-922337203685477.5808", "999999999999999999999999.9999", - "999999999999999999999999.9999"}; - String[] values2 = {Boolean.FALSE.toString(), "0", "-32768", "-2147483648", "-9223372036854775808", + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekAkv, dateTable, values, TestCase.SETOBJECT, false); + } + } + + /** + * Junit test case for date set object for date values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testDateSetObject(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekJks, dateTable, values, TestCase.SETOBJECT, false); + } + } + + /** + * Junit test case for date set object for java date values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testDateSetObjectWithJavaTypeAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekAkv, dateTable, values, TestCase.SETOBJECT_WITH_JAVATYPES, false); + } + } + + /** + * Junit test case for date set object for java date values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testDateSetObjectWithJavaType(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekJks, dateTable, values, TestCase.SETOBJECT_WITH_JAVATYPES, false); + } + } + + /** + * Junit test case for date set object for jdbc date values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testDateSetObjectWithJDBCTypeAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekAkv, dateTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); + } + } + + /** + * Junit test case for date set object for jdbc date values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testDateSetObjectWithJDBCType(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekJks, dateTable, values, TestCase.SETOBJECT_WITH_JDBCTYPES, false); + } + } + + /** + * Junit test case for date set date for min/max date values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testDateSpecificSetterMinMaxValueAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + RandomData.returnMinMax = true; + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekAkv, dateTable, values, TestCase.NORMAL, false); + } + } + + /** + * Junit test case for date set date for min/max date values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testDateSpecificSetterMinMaxValue(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + RandomData.returnMinMax = true; + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekJks, dateTable, values, TestCase.NORMAL, false); + } + } + + /** + * Junit test case for date set date for null values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testDateSetNullAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + RandomData.returnNull = true; + nullable = true; + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekAkv, dateTable, values, TestCase.NULL, false); + } + + nullable = false; + RandomData.returnNull = false; + } + + /** + * Junit test case for date set date for null values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testDateSetNull(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + RandomData.returnNull = true; + nullable = true; + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekJks, dateTable, values, TestCase.NULL, false); + } + + nullable = false; + RandomData.returnNull = false; + } + + /** + * Junit test case for date set object for null values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testDateSetObjectNullAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + RandomData.returnNull = true; + nullable = true; + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekAkv, dateTable, values, TestCase.SETOBJECT_NULL, false); + } + + nullable = false; + RandomData.returnNull = false; + } + + /** + * Junit test case for date set object for null values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testDateSetObjectNull(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + RandomData.returnNull = true; + nullable = true; + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + LinkedList values = createTemporalTypes(nullable); + + testDates(stmt, cekJks, dateTable, values, TestCase.SETOBJECT_NULL, false); + } + + nullable = false; + RandomData.returnNull = false; + } + + /** + * Junit test case for numeric set numeric for numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericSpecificSetterAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + + testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NORMAL, false); + } + } + + /** + * Junit test case for numeric set numeric for numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testNumericSpecificSetter(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + + testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NORMAL, false); + } + } + + /** + * Junit test case for numeric set numeric for numeric values using windows certificate store + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericSpecificSetterWindows(String serverName, String url, String protocol) throws Exception { + org.junit.Assume.assumeTrue(isWindows); + + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + + testNumerics(stmt, cekWin, numericTable, values1, values2, TestCase.NORMAL, false); + } + } + + /** + * Junit test case for numeric set object for numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericSetObjectAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + + testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.SETOBJECT, false); + } + } + + /** + * Junit test case for numeric set object for numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testNumericSetObject(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + + testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.SETOBJECT, false); + } + } + + /** + * Junit test case for numeric set object for jdbc type numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericSetObjectWithJDBCTypesAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + + testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.SETOBJECT_WITH_JDBCTYPES, false); + } + } + + /** + * Junit test case for numeric set object for jdbc type numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testNumericSetObjectWithJDBCTypes(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + + testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.SETOBJECT_WITH_JDBCTYPES, false); + } + } + + /** + * Junit test case for numeric set numeric for max numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericSpecificSetterMaxValueAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + + String[] values1 = {Boolean.TRUE.toString(), "255", "32767", "2147483647", "9223372036854775807", + "1.79E308", "1.123", "3.4E38", "999999999999999999", "12345.12345", "999999999999999999", + "567812.78", "214748.3647", "922337203685477.5807", "999999999999999999999999.9999", + "999999999999999999999999.9999"}; + String[] values2 = {Boolean.TRUE.toString(), "255", "32767", "2147483647", "9223372036854775807", + "1.79E308", "1.123", "3.4E38", "999999999999999999", "12345.12345", "999999999999999999", + "567812.78", "214748.3647", "922337203685477.5807", "999999999999999999999999.9999", + "999999999999999999999999.9999"}; + + testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NORMAL, false); + } + } + + /** + * Junit test case for numeric set numeric for max numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testNumericSpecificSetterMaxValue(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + + String[] values1 = {Boolean.TRUE.toString(), "255", "32767", "2147483647", "9223372036854775807", + "1.79E308", "1.123", "3.4E38", "999999999999999999", "12345.12345", "999999999999999999", + "567812.78", "214748.3647", "922337203685477.5807", "999999999999999999999999.9999", + "999999999999999999999999.9999"}; + String[] values2 = {Boolean.TRUE.toString(), "255", "32767", "2147483647", "9223372036854775807", + "1.79E308", "1.123", "3.4E38", "999999999999999999", "12345.12345", "999999999999999999", + "567812.78", "214748.3647", "922337203685477.5807", "999999999999999999999999.9999", + "999999999999999999999999.9999"}; + + testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NORMAL, false); + } + } + + /** + * Junit test case for numeric set numeric for min numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericSpecificSetterMinValueAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + String[] values1 = {Boolean.FALSE.toString(), "0", "-32768", "-2147483648", "-9223372036854775808", + "-1.79E308", "1.123", "-3.4E38", "999999999999999999", "12345.12345", "999999999999999999", + "567812.78", "-214748.3648", "-922337203685477.5808", "999999999999999999999999.9999", + "999999999999999999999999.9999"}; + String[] values2 = {Boolean.FALSE.toString(), "0", "-32768", "-2147483648", "-9223372036854775808", "-1.79E308", "1.123", "-3.4E38", "999999999999999999", "12345.12345", "999999999999999999", "567812.78", "-214748.3648", "-922337203685477.5808", "999999999999999999999999.9999", "999999999999999999999999.9999"}; - testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NORMAL, false); testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NORMAL, false); } } + /** + * Junit test case for numeric set numeric for min numeric values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + public void testNumericSpecificSetterMinValue(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + String[] values1 = {Boolean.FALSE.toString(), "0", "-32768", "-2147483648", "-9223372036854775808", + "-1.79E308", "1.123", "-3.4E38", "999999999999999999", "12345.12345", "999999999999999999", + "567812.78", "-214748.3648", "-922337203685477.5808", "999999999999999999999999.9999", + "999999999999999999999999.9999"}; + String[] values2 = {Boolean.FALSE.toString(), "0", "-32768", "-2147483648", "-9223372036854775808", + "-1.79E308", "1.123", "-3.4E38", "999999999999999999", "12345.12345", "999999999999999999", + "567812.78", "-214748.3648", "-922337203685477.5808", "999999999999999999999999.9999", + "999999999999999999999999.9999"}; + + testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NORMAL, false); + } + } + + /** + * Junit test case for numeric set numeric for null values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericSpecificSetterNullAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + nullable = true; + RandomData.returnNull = true; + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + + testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NULL, false); + } + + nullable = false; + RandomData.returnNull = false; + } + /** * Junit test case for numeric set numeric for null values * @@ -947,6 +1423,31 @@ public void testNumericSpecificSetterNull(String serverName, String url, String System.arraycopy(values1, 0, values2, 0, values1.length); testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NULL, false); + } + + nullable = false; + RandomData.returnNull = false; + } + + /** + * Junit test case for numeric set object for null values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericSpecificSetterSetObjectNullAkv(String serverName, String url, + String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + nullable = true; + RandomData.returnNull = true; + String[] values1 = createNumericValues(nullable); + String[] values2 = new String[values1.length]; + System.arraycopy(values1, 0, values2, 0, values1.length); + testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NULL, false); } @@ -973,13 +1474,36 @@ public void testNumericSpecificSetterSetObjectNull(String serverName, String url System.arraycopy(values1, 0, values2, 0, values1.length); testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NULL, false); - testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NULL, false); } nullable = false; RandomData.returnNull = false; } + /** + * Junit test case for numeric set numeric for null normalization values + * + * @throws SQLException + */ + @ParameterizedTest + @MethodSource("enclaveParams") + @Tag(Constants.reqExternalSetup) + public void testNumericNormalizationAkv(String serverName, String url, String protocol) throws Exception { + checkAESetup(serverName, url, protocol); + + try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); + SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) { + String[] values1 = {Boolean.TRUE.toString(), "1", "127", "100", "100", "1.123", "1.123", "1.123", + "123456789123456789", "12345.12345", "987654321123456789", "567812.78", "7812.7812", "7812.7812", + "999999999999999999999999.9999", "999999999999999999999999.9999"}; + String[] values2 = {Boolean.TRUE.toString(), "1", "127", "100", "100", "1.123", "1.123", "1.123", + "123456789123456789", "12345.12345", "987654321123456789", "567812.78", "7812.7812", "7812.7812", + "999999999999999999999999.9999", "999999999999999999999999.9999"}; + + testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NORMAL, false); + } + } + /** * Junit test case for numeric set numeric for null normalization values * @@ -1000,10 +1524,17 @@ public void testNumericNormalization(String serverName, String url, String proto "999999999999999999999999.9999", "999999999999999999999999.9999"}; testNumerics(stmt, cekJks, numericTable, values1, values2, TestCase.NORMAL, false); - testNumerics(stmt, cekAkv, numericTable, values1, values2, TestCase.NORMAL, false); } } + /** + * Junit test case for testing FMTOnly + * + * @param serverName + * @param url + * @param protocol + * @throws Exception + */ @ParameterizedTest @MethodSource("enclaveParams") public void testAEFMTOnly(String serverName, String url, String protocol) throws Exception { @@ -1011,11 +1542,10 @@ public void testAEFMTOnly(String serverName, String url, String protocol) throws 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); @@ -1024,7 +1554,7 @@ public void testAEFMTOnly(String serverName, String url, String protocol) throws } void testChar(SQLServerStatement stmt, String[] values) throws SQLException { - String sql = "select * from " + AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE); + String sql = "select * from " + CHAR_TABLE_AE; try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1041,7 +1571,7 @@ void testChar(SQLServerStatement stmt, String[] values) throws SQLException { } void testBinary(SQLServerStatement stmt, LinkedList values) throws SQLException { - String sql = "select * from " + AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE.toString()); + String sql = "select * from " + BINARY_TABLE_AE; try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1058,7 +1588,7 @@ void testBinary(SQLServerStatement stmt, LinkedList values) throws SQLEx } void testDate(SQLServerStatement stmt, LinkedList values1) throws SQLException { - String sql = "select * from " + AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE); + String sql = "select * from " + DATE_TABLE_AE; try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1439,7 +1969,7 @@ void testGetDate(ResultSet rs, int numberOfColumns, LinkedList values) t } void testNumeric(Statement stmt, String[] numericValues, boolean isNull) throws SQLException { - String sql = "select * from " + AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE); + String sql = "select * from " + NUMERIC_TABLE_AE; try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo); SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, @@ -1627,8 +2157,8 @@ private void testAlterColumnEncryption(SQLServerStatement stmt, String tableName try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo)) { for (int i = 0; i < table.length; i++) { // alter deterministic to randomized - String sql = "ALTER TABLE " + AbstractSQLGenerator.escapeIdentifier(tableName) + " ALTER COLUMN " - + ColumnType.DETERMINISTIC.name() + table[i][0] + " " + table[i][1] + String sql = "ALTER TABLE " + tableName + " ALTER COLUMN " + ColumnType.DETERMINISTIC.name() + + table[i][0] + " " + table[i][1] + String.format(encryptSql, ColumnType.RANDOMIZED.name(), cekName) + ")"; try (SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, stmtColEncSetting)) { @@ -1654,8 +2184,7 @@ private void testRichQuery(SQLServerStatement stmt, String tableName, String tab String[] values) throws SQLException { try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo)) { for (int i = 0; i < table.length; i++) { - String sql = "SELECT * FROM " + AbstractSQLGenerator.escapeIdentifier(tableName) + " WHERE " - + ColumnType.PLAIN.name() + table[i][0] + "= ?"; + String sql = "SELECT * FROM " + tableName + " WHERE " + ColumnType.PLAIN.name() + table[i][0] + "= ?"; try (SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, stmtColEncSetting)) { switch (table[i][2]) { @@ -1780,8 +2309,7 @@ private void testRichQueryDate(SQLServerStatement stmt, String tableName, String LinkedList values) throws SQLException { try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo)) { for (int i = 0; i < table.length; i++) { - String sql = "SELECT * FROM " + AbstractSQLGenerator.escapeIdentifier(tableName) + " WHERE " - + ColumnType.PLAIN.name() + table[i][0] + "= ?"; + String sql = "SELECT * FROM " + tableName + " WHERE " + ColumnType.PLAIN.name() + table[i][0] + "= ?"; try (SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, stmtColEncSetting)) { switch (table[i][2]) { @@ -1840,8 +2368,7 @@ private void testRichQuery(SQLServerStatement stmt, String tableName, String tab LinkedList values) throws SQLException { try (SQLServerConnection con = PrepUtil.getConnection(AETestConnectionString, AEInfo)) { for (int i = 0; i < table.length; i++) { - String sql = "SELECT * FROM " + AbstractSQLGenerator.escapeIdentifier(tableName) + " WHERE " - + ColumnType.PLAIN.name() + table[i][0] + "= ?"; + String sql = "SELECT * FROM " + tableName + " WHERE " + ColumnType.PLAIN.name() + table[i][0] + "= ?"; try (SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) TestUtils.getPreparedStmt(con, sql, stmtColEncSetting)) { switch (table[i][2]) { @@ -1907,7 +2434,7 @@ void Compare(String expectedValue, String value1, String value2, String value3) void testChars(SQLServerStatement stmt, String cekName, String[][] table, String[] values, TestCase testCase, boolean isTestEnclave) throws SQLException { - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(CHAR_TABLE_AE), stmt); + TestUtils.dropTableIfExists(CHAR_TABLE_AE, stmt); createTable(CHAR_TABLE_AE, cekName, table); switch (testCase) { @@ -1947,7 +2474,7 @@ void testChars(SQLServerStatement stmt, String cekName, String[][] table, String void testBinaries(SQLServerStatement stmt, String cekName, String[][] table, LinkedList values, TestCase testCase, boolean isTestEnclave) throws SQLException { - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(BINARY_TABLE_AE), stmt); + TestUtils.dropTableIfExists(BINARY_TABLE_AE, stmt); createTable(BINARY_TABLE_AE, cekName, table); switch (testCase) { @@ -1986,7 +2513,7 @@ void testBinaries(SQLServerStatement stmt, String cekName, String[][] table, Lin void testDates(SQLServerStatement stmt, String cekName, String[][] table, LinkedList values, TestCase testCase, boolean isTestEnclave) throws SQLException { - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(DATE_TABLE_AE), stmt); + TestUtils.dropTableIfExists(DATE_TABLE_AE, stmt); createTable(DATE_TABLE_AE, cekName, table); switch (testCase) { @@ -2029,7 +2556,7 @@ void testDates(SQLServerStatement stmt, String cekName, String[][] table, Linked void testNumerics(SQLServerStatement stmt, String cekName, String[][] table, String[] values1, String[] values2, TestCase testCase, boolean isTestEnclave) throws SQLException { - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(NUMERIC_TABLE_AE), stmt); + TestUtils.dropTableIfExists(NUMERIC_TABLE_AE, stmt); createTable(NUMERIC_TABLE_AE, cekName, table); boolean isNull = false; diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/PrecisionScaleTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/PrecisionScaleTest.java index e154365f0..6df71a88f 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/PrecisionScaleTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/PrecisionScaleTest.java @@ -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; @@ -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 skipMax = new ArrayList<>(); @@ -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 skipMax = new ArrayList<>(); @@ -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, @@ -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, @@ -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)) { @@ -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, @@ -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, diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/RegressionAlwaysEncryptedTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/RegressionAlwaysEncryptedTest.java index 6dd9da2f3..8b45b1735 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/RegressionAlwaysEncryptedTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/RegressionAlwaysEncryptedTest.java @@ -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; @@ -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); @@ -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"); @@ -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); @@ -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); @@ -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); @@ -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()); @@ -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)); @@ -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)); @@ -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); } } diff --git a/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java b/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java index 3fcf1d1b3..246785546 100644 --- a/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java +++ b/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java @@ -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 {