Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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'."},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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());
}
}

Expand All @@ -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 ('?', ?,? ,?) ";
Expand All @@ -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());
}
}

Expand Down