Commit 48aa95a 1 parent e93d998 commit 48aa95a Copy full SHA for 48aa95a
File tree 1 file changed +13
-13
lines changed
src/test/java/com/microsoft/sqlserver/jdbc/connection
1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -93,21 +93,21 @@ public void testDMLoginTimeoutApplied() {
93
93
public void testDMLoginTimeoutNotApplied () {
94
94
long timerEnd = 0 ;
95
95
int timeout = 10 ;
96
+ try {
97
+ DriverManager .setLoginTimeout (timeout * 3 ); // 30 seconds
98
+ long timerStart = System .currentTimeMillis ();
96
99
97
- DriverManager .setLoginTimeout (timeout * 3 ); // 30 seconds
98
- long timerStart = System .currentTimeMillis ();
99
-
100
- try (Connection con = PrepUtil
101
- .getConnection ("jdbc:sqlserver://" + randomServer + ";user=sa;password=pwd;loginTimeout=" + timeout )) {
102
- fail (TestResource .getResource ("R_shouldNotConnect" ));
103
- } catch (Exception e ) {
104
- assertTrue (e .getMessage ().contains (TestResource .getResource ("R_tcpipConnectionToHost" )));
105
- timerEnd = System .currentTimeMillis ();
100
+ try (Connection con = PrepUtil .getConnection (
101
+ "jdbc:sqlserver://" + randomServer + ";user=sa;password=pwd;loginTimeout=" + timeout )) {
102
+ fail (TestResource .getResource ("R_shouldNotConnect" ));
103
+ } catch (Exception e ) {
104
+ assertTrue (e .getMessage ().contains (TestResource .getResource ("R_tcpipConnectionToHost" )));
105
+ timerEnd = System .currentTimeMillis ();
106
+ }
107
+ verifyTimeout (timerEnd - timerStart , timeout );
108
+ } finally {
109
+ DriverManager .setLoginTimeout (0 ); // Default to 0 again
106
110
}
107
-
108
- verifyTimeout (timerEnd - timerStart , timeout );
109
-
110
- DriverManager .setLoginTimeout (0 ); // Default to 0 again
111
111
}
112
112
113
113
@ Test
You can’t perform that action at this time.
0 commit comments