Skip to content

Commit

Permalink
Added test case for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
muskan124947 committed Dec 17, 2024
1 parent 1cdcac4 commit 51be560
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.sql.Connection;
Expand Down Expand Up @@ -208,4 +210,22 @@ public void testApplicationName() throws SQLException {
fail(e.getMessage());
}
}

/**
* test application name when system properties are empty
*
*/
@Test
public void testGetAppName() {
String appName = SQLServerDriver.getAppName();
assertNotNull(appName, "Application name should not be null");
assertFalse(appName.isEmpty(), "Application name should not be empty");

System.setProperty("os.name", "");
System.setProperty("os.arch", "");
System.setProperty("java.vm.name", "");
System.setProperty("java.vm.version", "");
String defaultAppName = SQLServerDriver.getAppName();
assertEquals(SQLServerDriver.DEFAULT_APP_NAME, defaultAppName, "Application name should be the default one");
}
}

0 comments on commit 51be560

Please sign in to comment.