Skip to content

Commit

Permalink
Simplified checking of expected exception
Browse files Browse the repository at this point in the history
  • Loading branch information
machavan committed Jan 15, 2025
1 parent 85f525d commit 001bfd2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,5 @@ protected Object[][] getContents() {
{"R_expectedClassDoesNotMatchActualClass",
"Expected column class {0} does not match actual column class {1} for column {2}."},
{"R_loginFailedMI", "Login failed for user '<token-identified principal>'"},
{"R_MInotAvailable", "Managed Identity authentication is not available"},
{"R_featureNotSupported", "{0} is not supported."},};
{"R_MInotAvailable", "Managed Identity authentication is not available"},};
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.microsoft.sqlserver.jdbc.RandomUtil;
import com.microsoft.sqlserver.jdbc.SQLServerSavepoint;
import com.microsoft.sqlserver.jdbc.TestResource;
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.Constants;

Expand Down Expand Up @@ -151,11 +152,7 @@ public void testReleaseSavepoint() throws SQLException {
} catch (SQLException e) {
assertEquals(e.getClass(), SQLFeatureNotSupportedException.class, "Expected exception type " + SQLFeatureNotSupportedException.class.getName() + ", but received " + e.getClass().getName());

MessageFormat form = new MessageFormat(TestResource.getResource("R_featureNotSupported"));
Object[] msgArgs = {"releaseSavepoint"};
String expectedExceptionMsg = form.format(msgArgs);
String receivedExceptionMsg = e.getMessage();
assertEquals(expectedExceptionMsg, receivedExceptionMsg, "Expected exception message " + expectedExceptionMsg + ", but received " + receivedExceptionMsg);;
assertTrue(e.getMessage().matches(TestUtils.formatErrorMsg("R_featureNotSupported")));
}
}
}
Expand Down

0 comments on commit 001bfd2

Please sign in to comment.