From a7889e5bb16b2ee6b22d0377a1a94fed280b44a4 Mon Sep 17 00:00:00 2001 From: Muskan Gupta Date: Tue, 31 Dec 2024 12:45:45 +0530 Subject: [PATCH] Added test to validate appName using select app_name() query --- .../sqlserver/jdbc/SQLServerDriverTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/SQLServerDriverTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/SQLServerDriverTest.java index 2d2fee89d..e3601437c 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/SQLServerDriverTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/SQLServerDriverTest.java @@ -211,6 +211,24 @@ public void testApplicationName() throws SQLException { } } + /** + * test application name by executing select app_name() + * + * @throws SQLException + */ + @Test + public void testApplicationNameUsingApp_Name() throws SQLException { + try (Connection conn = DriverManager.getConnection(connectionString); + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT app_name()")) { + if (rs.next()) { + assertEquals(SQLServerDriver.constructedAppName, rs.getString(1)); + } + } catch (SQLException e) { + fail(e.getMessage()); + } + } + /** * test application name when system properties are empty *