Skip to content

Commit 001bfd2

Browse files
committed
Simplified checking of expected exception
1 parent 85f525d commit 001bfd2

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,5 @@ protected Object[][] getContents() {
216216
{"R_expectedClassDoesNotMatchActualClass",
217217
"Expected column class {0} does not match actual column class {1} for column {2}."},
218218
{"R_loginFailedMI", "Login failed for user '<token-identified principal>'"},
219-
{"R_MInotAvailable", "Managed Identity authentication is not available"},
220-
{"R_featureNotSupported", "{0} is not supported."},};
219+
{"R_MInotAvailable", "Managed Identity authentication is not available"},};
221220
}

src/test/java/com/microsoft/sqlserver/jdbc/unit/SavepointTest.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.microsoft.sqlserver.jdbc.RandomUtil;
2424
import com.microsoft.sqlserver.jdbc.SQLServerSavepoint;
2525
import com.microsoft.sqlserver.jdbc.TestResource;
26+
import com.microsoft.sqlserver.jdbc.TestUtils;
2627
import com.microsoft.sqlserver.testframework.AbstractTest;
2728
import com.microsoft.sqlserver.testframework.Constants;
2829

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

154-
MessageFormat form = new MessageFormat(TestResource.getResource("R_featureNotSupported"));
155-
Object[] msgArgs = {"releaseSavepoint"};
156-
String expectedExceptionMsg = form.format(msgArgs);
157-
String receivedExceptionMsg = e.getMessage();
158-
assertEquals(expectedExceptionMsg, receivedExceptionMsg, "Expected exception message " + expectedExceptionMsg + ", but received " + receivedExceptionMsg);;
155+
assertTrue(e.getMessage().matches(TestUtils.formatErrorMsg("R_featureNotSupported")));
159156
}
160157
}
161158
}

0 commit comments

Comments
 (0)