diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java b/src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java index 8b2ca84b4b..b043898784 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java @@ -153,6 +153,8 @@ protected Object[][] getContents() { {"R_expectedValue", "Expected value: "}, {"R_expectedValueAtIndex", "Expected value at index: "}, {"R_switchFailed", "Switch case is not matched with data"}, {"R_resultsetNotInstance", "Result set is not instance of SQLServerResultSet"}, - + {"R_incorrectColumnNum", "Column name or number of supplied values does not match table definition."}, + {"R_incorrectColumnNumInsert", "There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement."}, + {"R_incorrectSyntaxTable", "Incorrect syntax near the keyword 'table'."}, }; } diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/preparedStatement/BatchExecutionWithBulkCopyTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/preparedStatement/BatchExecutionWithBulkCopyTest.java index 80f13604c6..fdac78e14d 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/preparedStatement/BatchExecutionWithBulkCopyTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/preparedStatement/BatchExecutionWithBulkCopyTest.java @@ -30,6 +30,7 @@ import com.microsoft.sqlserver.jdbc.SQLServerConnection; import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement; 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.AbstractTest; @@ -536,9 +537,9 @@ public void testIllegalNumberOfArgNoColumnList() throws Exception { pstmt.addBatch(); pstmt.executeBatch(); - throw new Exception("Test did not throw an exception when it was expected."); + throw new Exception(TestResource.getResource("R_expectedExceptionNotThrown")); } catch (BatchUpdateException e) { - assertEquals("Column name or number of supplied values does not match table definition.", e.getMessage()); + assertEquals(TestResource.getResource("R_incorrectColumnNum"), e.getMessage()); } invalid = "insert into " + AbstractSQLGenerator.escapeIdentifier(tableName) @@ -558,11 +559,9 @@ public void testIllegalNumberOfArgNoColumnList() throws Exception { pstmt.addBatch(); pstmt.executeBatch(); - throw new Exception("Test did not throw an exception when it was expected."); + throw new Exception(TestResource.getResource("R_expectedExceptionNotThrown")); } catch (BatchUpdateException e) { - assertEquals( - "There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.", - e.getMessage()); + assertEquals(TestResource.getResource("R_incorrectColumnNumInsert"), e.getMessage()); } } @@ -585,9 +584,9 @@ public void testNonParameterizedQuery() throws Exception { pstmt.addBatch(); pstmt.executeBatch(); - throw new Exception("Test did not throw an exception when it was expected."); + throw new Exception(TestResource.getResource("R_expectedExceptionNotThrown")); } catch (BatchUpdateException e) { - assertEquals("Incorrect syntax near the keyword 'table'.", e.getMessage()); + assertEquals(TestResource.getResource("R_incorrectSyntaxTable"), e.getMessage()); } invalid = "insert into " + AbstractSQLGenerator.escapeIdentifier(tableName) + " values ('?', ?,? ,?) "; @@ -605,9 +604,9 @@ public void testNonParameterizedQuery() throws Exception { pstmt.addBatch(); pstmt.executeBatch(); - throw new Exception("Test did not throw an exception when it was expected."); + throw new Exception(TestResource.getResource("R_expectedExceptionNotThrown")); } catch (BatchUpdateException e) { - assertEquals("Column name or number of supplied values does not match table definition.", e.getMessage()); + assertEquals(TestResource.getResource("R_incorrectColumnNum"), e.getMessage()); } }